Author Topic: DIY JTAG/ST LINK STM32 programmer?  (Read 25405 times)

0 Members and 1 Guest are viewing this topic.

Offline BoscoeTopic starter

  • Frequent Contributor
  • **
  • Posts: 276
DIY JTAG/ST LINK STM32 programmer?
« on: March 09, 2016, 10:22:25 am »
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
 

Offline rolycat

  • Super Contributor
  • ***
  • Posts: 1101
  • Country: gb
Re: DIY JTAG/ST LINK STM32 programmer?
« Reply #1 on: March 09, 2016, 10:54:10 am »
STM offer inexpensive development boards like the  F0 Discovery with onboard ST-LINK/V2.

There is a description here of how to build a small programmer/debugger using one of these as a donor board.
 

Offline BoscoeTopic starter

  • Frequent Contributor
  • **
  • Posts: 276
Re: DIY JTAG/ST LINK STM32 programmer?
« Reply #2 on: March 09, 2016, 11:20:37 am »
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
 

Offline BoscoeTopic starter

  • Frequent Contributor
  • **
  • Posts: 276
Re: DIY JTAG/ST LINK STM32 programmer?
« Reply #3 on: March 09, 2016, 11:37:23 am »
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.
 

Offline Skashkash

  • Regular Contributor
  • *
  • Posts: 118
  • Country: us
Re: DIY JTAG/ST LINK STM32 programmer?
« Reply #4 on: March 09, 2016, 12:52:48 pm »

Black magic probe maybe?
Not sure of status / compatibility.

http://www.blacksphere.co.nz/main/blackmagic

Or 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:48wAAOSwPhdVG67z

Hard to find smaller, cheaper, more compatible.

 

Offline hans

  • Super Contributor
  • ***
  • Posts: 1640
  • Country: nl
Re: DIY JTAG/ST LINK STM32 programmer?
« Reply #5 on: March 09, 2016, 04:01:06 pm »
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.
 

Offline donotdespisethesnake

  • Super Contributor
  • ***
  • Posts: 1093
  • Country: gb
  • Embedded stuff
Re: DIY JTAG/ST LINK STM32 programmer?
« Reply #6 on: March 09, 2016, 06:49:41 pm »
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 at http://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.

Bob
"All you said is just a bunch of opinions."
 

Offline __daz__

  • Newbie
  • Posts: 4
  • Country: it
Re: DIY JTAG/ST LINK STM32 programmer?
« Reply #7 on: March 09, 2016, 07:46:14 pm »
Yes, I've been using this CMSIS-DAP implementation for STM32F103

https://github.com/x893/CMSIS-DAP

and works like a charm on a ST-Link clone both with OpenOCD and Keil.
Should be quite easy to port it to other MCUs.
 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3785
  • Country: de
Re: DIY JTAG/ST LINK STM32 programmer?
« Reply #8 on: March 09, 2016, 08:19:02 pm »
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-/262087067780

Or 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.

 

Offline donotdespisethesnake

  • Super Contributor
  • ***
  • Posts: 1093
  • Country: gb
  • Embedded stuff
Re: DIY JTAG/ST LINK STM32 programmer?
« Reply #9 on: March 09, 2016, 10:50:23 pm »
I found a project based on LPC11U35, which says it is open hardware http://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.
Bob
"All you said is just a bunch of opinions."
 

Offline marus25

  • Newbie
  • Posts: 4
Re: DIY JTAG/ST LINK STM32 programmer?
« Reply #10 on: March 10, 2016, 02:31:58 am »
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).
 

Offline richardman

  • Frequent Contributor
  • **
  • Posts: 427
  • Country: us
Re: DIY JTAG/ST LINK STM32 programmer?
« Reply #11 on: March 10, 2016, 06:56:11 am »
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.
// richard http://imagecraft.com/
JumpStart C++ for Cortex (compiler/IDE/debugger): the fastest easiest way to get productive on Cortex-M.
Smart.IO: phone App for embedded systems with no app or wireless coding
 

Offline michaeliv

  • Frequent Contributor
  • **
  • Posts: 260
Re: DIY JTAG/ST LINK STM32 programmer?
« Reply #12 on: March 12, 2016, 03:03:33 am »
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
 

Offline Buriedcode

  • Super Contributor
  • ***
  • Posts: 1611
  • Country: gb
Re: DIY JTAG/ST LINK STM32 programmer?
« Reply #13 on: March 14, 2016, 07:15:55 pm »
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

If 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.
 

Offline Kilrah

  • Supporter
  • ****
  • Posts: 1852
  • Country: ch
Re: DIY JTAG/ST LINK STM32 programmer?
« Reply #14 on: March 14, 2016, 08:11:57 pm »
Yeah but he said he wants to have the programmer integrated right on his own boards, not as a separate unit.
 

Offline ade

  • Supporter
  • ****
  • Posts: 231
  • Country: ca
Re: DIY JTAG/ST LINK STM32 programmer?
« Reply #15 on: March 14, 2016, 08:36:23 pm »
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.
 

Offline DEHiCKA

  • Contributor
  • Posts: 39
  • Country: aq
Re: DIY JTAG/ST LINK STM32 programmer?
« Reply #16 on: March 14, 2016, 09:34:58 pm »
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.
« Last Edit: March 14, 2016, 09:38:02 pm by DEHiCKA »
 

Offline michaeliv

  • Frequent Contributor
  • **
  • Posts: 260
Re: DIY JTAG/ST LINK STM32 programmer?
« Reply #17 on: March 15, 2016, 01:07:40 am »
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.
Didnt 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 ?
 

Offline DEHiCKA

  • Contributor
  • Posts: 39
  • Country: aq
Re: DIY JTAG/ST LINK STM32 programmer?
« Reply #18 on: March 15, 2016, 10:24:36 am »
« Last Edit: March 15, 2016, 12:34:37 pm by DEHiCKA »
 

Offline chickenHeadKnob

  • Super Contributor
  • ***
  • Posts: 1055
  • Country: ca
Re: DIY JTAG/ST LINK STM32 programmer?
« Reply #19 on: March 15, 2016, 11:25:38 am »
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

Well there was GNU licensed Versaloon project 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/versaloon

This 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.
 

Offline michaeliv

  • Frequent Contributor
  • **
  • Posts: 260
Re: DIY JTAG/ST LINK STM32 programmer?
« Reply #20 on: March 15, 2016, 09:17:55 pm »
Mine are from Ali and they are F101
Guess 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
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf