Build a mini ST-LINK/V2 programmer/debugger for the STM32

I enjoy working with the STM32 processors. They are easy to use, powerful and cheap and there are lots of options for developing code. One minor annoyance is the question of a programmer.

ST-LINK/V2

One of the most commonly available and widely supported commercial programmers is the ST-LINK/V2. This is a handy little device that can do a lot of jobs. It is not too expensive (about £22 from Farnell). I didn’t really need all that functionality and, while not very big, it was clumsy to carry about.

ST-LINK/V2

I had previously determined that I needed only four wires from this to my target board. They supply SWDIO, SWDCK, GND and VCC for use with SWD programming and debugging. I have more details in this previous post. The VCC line seems only to be needed to power level converters in the ST-LINK/V2. That meant that I could get away with just three wires going to my target board so long as I was confident that the programmer and target voltages were the same.

Elsewhere, [see Taylor Killian's site] there is information on how to extract the ST-LINK/V2 firmware from the upgrade package and program your own device. With that in mind, I decided to build my own SWD-only programmer based on the ST-LINK/V2. But I didn’t want to faff about extracting firmware and programming up bare devices or putting ST code to dodgy use.

STM32F0Discovery

Then it occurred to me that there is a ST-LINK/V2 on all the recent crop of ST Discovery boards. They are cheap and the processor on them is already full of the right code. The cheapest of them seemed to be the STM32F0Discovery – available at Farnell for about £8. And it comes with a handy prototyping board.

STM32F0Discovery

A blank chip from the same source would be £4. It would be easy to extract the processor from ST-LINK portion of the discovery board. After that I would still have a full discovery board and a spare prototyping board. Hard to see a downside really.

DIY board

It didn’t take long to extract the relevant circuit details from the discovery documents and turn that into a small PCB. I wanted something as small as I could manage but still reasonably easy to build. It must replicate the functionality of the original ST-LINK/V2, take power from the USB connection and provide the three programming connections that I needed. There would be no extra bells and whistles – just a simple SWD programmer/debugger. I sent the board files off to Seeed Studios and waited – impatiently – over Christmas for the boards to arrive.

IMG_0456 Mini ST-LINK/V2

I left the silkscreen too small but that is OK. Once assembled I don’t much care what it says. It is easily populated with 0805 size components. The connector and the processor are taken straight off the discovery board as is the crystal. I know the crystal is enormous but I quite like the look of it there.

IMG_0465

Good to go

Once assembled, it powered up just fine and the ST-LINK utility checked it out and updated the firmware for me without any fuss. I used a simple servo connection lead to connect it to my target board and verified operation. No fuss – it just works. Since I am forgetful, I labelled the connector to be sure I get it the right way round. Nor harm will befall it if reversed though.

IMG_0468

I have a few more boards so I need to make a couple of spares. On the others, I will use a right-angle pin header for the output and cover the whole thing in a length of clear heat-shrink to protect it. Not a bad day’s work I would say.

Here is a copy of the schematic:

mini-st-link-v2

 

 

Incoming search terms:

  • st link v2 schematic (8)
  • stlink firmware (6)
  • ST-Link schematic (5)
  • stlink v2 STM32F4 (5)
  • stm32 discovery board programming debug no target found (3)
  • st link v2 source code (3)
  • st link v2 mini (2)
  • stlink v2 schematic (2)
  • st-link/v2 (2)
  • mini stlink (2)
This entry was posted in ARM, Hardware. Bookmark the permalink.

18 Responses to Build a mini ST-LINK/V2 programmer/debugger for the STM32

  1. Derek says:

    Very nice! How did you unsolder the processor?

  2. Peter Harrison says:

    Hot air gun. Took no time at all. I used a ‘proper’ one but Some hobby stored sell a cheap hot air gun that gets hot enough. I think. Even a paint-stripper would do with care.

  3. dragonet80 says:

    Very interesting Peter. I also have that 32F0 Discovery board lying at home, do you have a pair of pcbs to sell me?

  4. Thats a useful technique. Will any hot air gun do it, or do I need to acquire one in particular that reaches a certain temperature?

    Also how do you recommend we get our soldering skills up so that we can hand solder processors like you have done quite nicely?

  5. Peter Harrison says:

    Your hot air gun would need to get up to about 250 degrees C and you need to take great care to avoid damaging the components, the board or the surface upon which it is all sitting. I have a ‘proper’ hot air rework tool but I have used a paint stripper before. These are pretty brutal though.

    As for soldering it back on – that is actually easier if you take care. I would suggest a trawl around YuTube for videos that look like you could manage the same. I do not have any favourites bookmarked.

    If these are not techniques that you are already happy with, you need to get some practice. The easiest way is to find some old broken equipment – USB hubs or flash disks for example – and try removing and replacing the components.

  6. Green says:

    If solder is an issue for you, there are tons of cheap mini version of ST-Link V2 on Ebay sold under $10 USD, works same as the official one.

  7. Tomasz says:

    it is possible to get this FW as HEX ? t.o.m.a.s.z.1.9.8.7.@.g.m.a.i.l.c.o.m.

  8. Peter Harrison says:

    Not that I know of. If you follow the links through from Taylor Killian’s site [http://www.taylorkillian.com/2013/01/retrieving-st-linkv2-firmware-from.html]
    you may find out how to do that.

  9. Fraser says:

    I am experimenting programming my STM32F4DISCOVERY with an off-board ST-Link V2 via SWD. It will only work with the two jumpers (CN3) that connect the on-board st-link and the stm32 present. (I am not connecting the inbuilt st-link to the PC (USB)). I would have imagined the off board programmer would work with the on board programmers jumpers disconnected. That doesn’t seem to be the case.

    Any Info on this would be helpful!

    Many Thanks

  10. Peter Harrison says:

    I have had no trouble doing exactly that. If I understand you correctly.

    I can connect an external programmer via SWD directly to the PA13/PA14 pins on the discovery and program away merrily.

    The stand-alone STLINK/V2 does need the 3V connection though – so that is four wires in total. I think it uses that to power level convertors or. My adaptation does without that only because I know that the target board has an appropriate voltage.

  11. dragonet80 says:

    Hello and thanks again Peter. I went to mount the board last weekend but realized that I do not have the voltage regulator (I assumed it was in the discovery board, my fault), so I have to order it and wait it arrives.

    In the meantime I have subscribed to this interesting course, starts today night:
    https://www.edx.org/course/utaustinx/utaustinx-ut-6-01x-embedded-systems-1172
    I also had that Stellaris board lying at home, so this is a great oportunity to start learning on Cortex M4 microcontrollers.

  12. Peter Harrison says:

    Ah – yes – the voltage regulator. I should have warned you. Sorry, I just used what was on hand. Interesting-looking course.

  13. Randy says:

    There are new STM-Nucleo board series with a detachable ST-LINK/V2. The Nucleo boards are very cheap at about $10.33 USD at mouser .com.

  14. Green Ye says:

    that’s very interesting! I think I will buy that F401 version. Customized programmer is more fun to use though.

  15. Raul Forigua says:

    Hello, I am very interested in doing a mini developer of this type, I have two questions, this can be done with programming and debugging of code, and if so could you share the card designs to make your own. Thanks for the input from your blog, they have served me a lot!!

  16. Peter Harrison says:

    I will try and get the board files up in the next few days. Feel free to remind me if I forget.

  17. Travis Estep says:

    I have a question regarding powering the target board. I understand the the Mini-STLINK gets power from USB. How is the target powered? Do I just power it up with the regular USB cable like normal? Do I need to worry about resetting the board before programming? How does this work?

  18. Peter Harrison says:

    Sorry for the delay.

    Fo my small board, the target has its own power. As far as I know the power line on the programmer cable from the actual STLINK/V2 is used only to power voltage translators in the programmer. I have no need of hose and know for certain that the target has a 3V3 supply. Or none of course but the programmer soon finds out there is nothing there.

    You could power a target from the programmer of the current requirement were small. I figured that the target power requirements were not predictable enough to make it worth adding to the board. The main requirement was small size.

Leave a Reply