Adding Trace support to ST-Link clones

When it comes to programming ST microcontrollers, I prefer to use Discovery boards (mainly because you can turn them into J-Link). However, I got tired of carrying around the whole dev-board just for the programmer, so I ordered a cheap st-link clone due to it’s small form-factor.

The clone

ST-Link clone

For less than 3$ you get a nice dongle in aluminium case and some wires. After taking a closer look I noticed that there is no SWO pin on the pinout. Perhaps SWIM pin would dual-function as SWO when working with STM32? Unfortunately this wasn’t the case. So what, does it mean I have to use another USB cable just for UART? No way, I’m not going back to the stone age, I want my Trace!


Trace is a very neat feature. One of the common uses is redirecting stdout stream to stimulus port 0 in order to printf debugging information. All recent versions of ST-Link v2 support this feature, so the first thing I did was check if the dongle is running the original ST-Link firmware. I launched ST-LINK Utility and updated the firmware with no issues whatsoever. So now we know that the dongle is running the latest official firmware and supports trace functionality.

ST-Link schematic

I couldn’t find schematics for a stand-alone programmer so I assumed it would be identical to the one present on Discovery board. PA10 is used for SWO so the next step would be pretty straight-forward.


5V pin converted into SWO

I’ve cut the trace from 5V pin right after the via and soldered some bodge-wire to PA10 (pin 31). I also added a 22Ω resistor in case something goes horribly wrong. Initially I wanted to use SWIM pin since I don’t care about STM8 and it would only require desoldering one resistor without cutting any traces, but the 5V pin was easier to reach.

Time for some testing.

SWO Trace works perfectly fine which makes the dongle much more useful.