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.
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.
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.
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.
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.
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.
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.
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.
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:
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)
- stlink v2 schematic (2)
- stm32 nucleo (2)
- st link v2 mini (2)
- st-link/v2 (2)