I bought a cheap "st-link v2 emulator programmer" and an STM32f013C8T6 of Ebay. Using Atollic on Windows 8 and the SWD interface of the MCU, I am able to upload and run code, set breakpoints and watch variables but I canĀ“t use printf over ITM or SWV Trace.
I have also tried using a genuine ST-LINK v2 of a Nucleo stm32l152re board with the same results.
The connections between ST-LINK and MCU are as follows:
ST-LINK - MCU:
SWDIO - SWDIO, GND - GND, SWCLK - SWCLK, 3.3V - 3.3V
Unused pins on the ebay ST-LINK: RST, SWIM
Unused pins on the genuine ST-LINK: NRST, SWO
Any advice in this matter would be appreciated and I would be happy to provide more information if needed.
I have faced the same problem today. I'm using the STLink V2 clone which doesn't have the SWO(SWV) pin, and I found two solutions:
HW modification for the clone board as other people answered here which is Adding Trace support to ST-Link clones.
Semihosting technique using openOCD:
2.1 in debug configurations select "ST-LINK (OpenOCD)" from Debug probe list as shown here.
2.2 in startup tab, scroll down and in Run Commands placeholder, type "monitor arm semihosting enable" as shown here.
2.3 click on apply and then close debug configurations.
2.4 open project properties. From C/C++ Build, open Tool settings. From MCU GCC Linker, select Miscellaneous. on Other flags, click on Add button and type
"-specs=rdimon.specs -lc -lrdimon"
as shown here.2.5 click Apply, then Apply and Close.
2.6 then you need to exclude
syscalls.c
. open it's properties. from C/C++ Build, select Settings and check button Exclude source from build, then click Apply and Close as shown here.2.7 The final step is before any
printf
, you should callinitialise_monitor_handles()
, and it's prototype should be included as shown below and after building and entering debug mode and hit resume, the message is printed on the console itself as shown here.