DIY JTAG/ST LINK STM32 programmer? - Page 1
Forum section: electronics / general

author: Boscoe
author_rank: Frequent Contributor
timestamp: March 09, 2016, 10:22:25 am
content: Does anyone have any resources or info on how to implement a JTAG/ST LINK programmer for STM32 MCUs? I often create prototypes and would like to be able to include the programmer on board so I don't have to carry one around externally. I understand you can do it from one MCU but have no idea on the JTAG protocol and how to implement the USB drivers. I'm not particularly bothered in doing it from scratch myself so if there's a design out there already with some source code that would be great.Thanks

author: rolycat
author_rank: Super Contributor
timestamp: March 09, 2016, 10:54:10 am
content: STM offer inexpensive development boards like the F0 Discovery with onboard ST-LINK/V2.There is a descriptionhereof how to build a small programmer/debugger using one of these as a donor board.

author: Boscoe
author_rank: Frequent Contributor
timestamp: March 09, 2016, 11:20:37 am
content: Thanks, I did find that but I don't want to have to buy a dev board every time I want a prototype. I would have to buy a lot of them.Thanks

author: Boscoe
author_rank: Frequent Contributor
timestamp: March 09, 2016, 11:37:23 am
content: However as he did say in the article the price of the microcontroller and the cheapest dev kit are similar - just £1 difference on Farnell.

author: Skashkash
author_rank: Regular Contributor
timestamp: March 09, 2016, 12:52:48 pm
content: Black magic probe maybe?Not sure of status / compatibility.http://www.blacksphere.co.nz/main/blackmagicOr just put the SWD connector on your PCB and then carry one of these around.http://www.ebay.com/itm/ST-Link-V2-Shell-STM8-STM32-Emulator-Downloader-Programming-Debugger-Unit-/371295635365?hash=item5672f1c7a5:g:48wAAOSwPhdVG67zHard to find smaller, cheaper, more compatible.

author: hans
author_rank: Super Contributor
timestamp: March 09, 2016, 04:01:06 pm
content: The most important question is: what toolchain will the programmer be used with?Some toolchains wont work with all debugger hardware.If you use OpenOCD you can probably use a FT2232D chip with it's MPSSE/JTAG extensions. It also adds as a bonus a serial debug port for printfs().Unfortunately I don't have experience with those programmers. I personally use St-link from a discovery board.

author: donotdespisethesnake
author_rank: Super Contributor
timestamp: March 09, 2016, 06:49:41 pm
content: I haven't seen any open projects for an onboard STlink, ST have never published the code AFIAK. If you fancy reverse engineering the code from a USB download have a look athttp://www.taylorkillian.com/2013/01/retrieving-st-linkv2-firmware-from.html.The cheap STLink programmers you get on ebay use cracked code I think.The other common "industry standard" is Jlink, which is proprietary. Segger license it for onboard debuggers.I've seen some published/open examples for CMSIS-DAP jtags, which as something close to an open standard might be more sustainable. Mbed project have some Open Source firmware for a few chip types, including some STM32.

author: __daz__
author_rank: Newbie
timestamp: March 09, 2016, 07:46:14 pm
content: Yes, I've been using this CMSIS-DAP implementation for STM32F103https://github.com/x893/CMSIS-DAPand works like a charm on a ST-Link clone both with OpenOCD and Keil.Should be quite easy to port it to other MCUs.

author: janoc
author_rank: Super Contributor
timestamp: March 09, 2016, 08:19:02 pm
content: Making your own ST-Link makes little sense. Just get one of these (or similar STLink v2 dongle) from eBay:http://www.ebay.fr/itm/ST-Link-STLink-V2-Programmer-Debugger-STM8-STM32-latest-Firmware-cables-UK-/262087067780Or any SWD debugger/dongle will work, at least if you are using OpenOCD. There are plenty of these around. I have used the Dangerous Prototypes Bus Blaster and the OpenJTAG FTDI-based dongle without issues. You do not need the official ST Link one to develop with STM32s.

author: donotdespisethesnake
author_rank: Super Contributor
timestamp: March 09, 2016, 10:50:23 pm
content: I found a project based on LPC11U35, which says it is open hardwarehttp://armstart.co/products/ibdap-cmsis-dap-jtag-swd-firmware-debug-probe.Runs mbed firmware.Sometime I might get round to creating a reference design for an onboard JTAG. I think it would be useful.

author: marus25
author_rank: Newbie
timestamp: March 10, 2016, 02:31:58 am
content: If you really want to put a debugger on board I'd look into the black magic probe that was mentioned. Completely open source hardware and software wise - I've built my own for a stand alone debugger before I got my other debuggers. Really nice to use in some situations as there is no special software required - the GDB server is built into the firmware. So arm-none-eabi-gdb can just connect directly to the serial port - no messing with anything like OpenOCD.The current firmware is able to program most of the STM32 line (don't know if they've done the new F7 and all of the L variants); as well as several lines from other vendors (NRF58122 I believe as well as some of the LPC and Kinetis lines I think).

author: richardman
author_rank: Frequent Contributor
timestamp: March 10, 2016, 06:56:11 am
content: Unless it's for "educational purpose", I cannot see why anyone would not just spend $10.50 for a ST-Nucleo board that can be used as a ST-LINK.V2 or $21 or a unit in nice plastic case.

author: michaeliv
author_rank: Frequent Contributor
timestamp: March 12, 2016, 03:03:33 am
content: Why not get a cheap Chinese STLINK V2, reverse the schematic ( shouldn't be that difficult ) then embed that onto your board ? The part cost is probably around $1.5-$2.Of course you have to dump the firmware / write it to the chip on your board.http://www.aliexpress.com/item/FREE-SHIPPING-1PCS-ST-Link-V2-stlink-mini-STM8STM32-STLINK-simulator-download-programming-With-Cover/32329418477.html

author: Buriedcode
author_rank: Super Contributor
timestamp: March 14, 2016, 07:15:55 pm
content: Quote from: Boscoe on March 09, 2016, 11:20:37 amIf you checked that dev board you would see in the manual it highlights its ability to be used as a 'stand alone ST Link/v2' with a switch. So even if you don't use it as a dev board, its a programmer out of the box.

author: Kilrah
author_rank: Unknown
timestamp: March 14, 2016, 08:11:57 pm
content: Yeah but he said he wants to have the programmer integrated right on his own boards, not as a separate unit.

author: ade
author_rank: Unknown
timestamp: March 14, 2016, 08:36:23 pm
content: There's no need to reverse engineer. The ST Link schematics are published (e.g., as part of the Discovery & Nucleo board schematics) and the firmware is available for download as well.So it's fairly straightforward to incorporate an ST Link programmer into your own board. Whether that might violate any ST copyrights, etc., I have no idea.

author: DEHiCKA
author_rank: Contributor
timestamp: March 14, 2016, 09:34:58 pm
content: I have couple $2 chinese ST-Links. Both work more or less reliably only at 480kHz or less with ST-Link utility, when Discovery board STLink works all up to 4MHz.Maybe it is because cheepoos are made on STM32F101 which doesn't have USB interface per ST datasheet.I believe ST just marks F103 chips as F101 if they are out of USB specs.Also, Openocd config that works fine with discovery StLink is not working with chepoo STLink for me.

author: michaeliv
author_rank: Frequent Contributor
timestamp: March 15, 2016, 01:07:40 am
content: Quote from: DEHiCKA on March 14, 2016, 09:34:58 pmDidnt know that they have reliability issues, never tested it at higher sppeds.Where did you get your cheapos ?Mine has a F103, is yours marked differently ?

author: DEHiCKA
author_rank: Contributor
timestamp: March 15, 2016, 10:24:36 am
content: Mine are from Ali and they are F101:http://www.aliexpress.com/item/1PCS-ST-LINK-Stlink-ST-Link-V2-Mini-STM8-STM32-Simulator-Download-Programmer-Programming-With-Cover/32583327648.htmlAlso F101 from another seller's feedback:http://g02.a.alicdn.com/kf/UT8J7e2XpJaXXagOFbXx.jpg

author: chickenHeadKnob
author_rank: Super Contributor
timestamp: March 15, 2016, 11:25:38 am
content: Quote from: Boscoe on March 09, 2016, 10:22:25 amWell there was GNU licensedVersaloonproject started by Simon Qian around 2010. I thought he had abandoned the project as his website Versaloon.com is no more. However there is still activity on Github. here:https://github.com/versaloonThis was/is complete JTAG running on an STM32f103 and recognized by OpenOcd. Hardware files (Kicad I think) available on Github as well. The first version hardware is no more complicated than an ST-LINK.

author: michaeliv
author_rank: Frequent Contributor
timestamp: March 15, 2016, 09:17:55 pm
content: Quote from: DEHiCKA on March 15, 2016, 10:24:36 amGuess I got lucky, now I'll know to look carefully at feedback if I'll be ordering another. Seems they would do anything to shave off some extra cents, the F101 is about only 10-20c cheaper from what I can find on Ali