No SWV or ITM with st-link v2 emulator programmer and stm32f103c8t6

3.6k views Asked by At

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.

4

There are 4 answers

0
Mahmoud Karam On

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:

  1. HW modification for the clone board as other people answered here which is Adding Trace support to ST-Link clones.

  2. 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 call initialise_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.

0
oclyke On

I understand this question is very old. I hope you found the solution but I'd still like to put in my two cents because I came across the same problem.

My understanding is that for SWV functionality you need the SWO pin connected. When you had this problem were you able to view exception trace logs or any SWV feature other than the printf redirect?

In light of this realization I am modifying my hardware to support the SWO pin for future use.

0
arantius On

Try reading Adding Trace support to ST-Link clones. Common cheap ST-Link clones must be modified at the hardware level to expose the SWO pin which ITM tracing depends upon. (Then, of course, you must also hook up that signal.)

I've got two different ST-Link clones, both of which connect nothing to the PA10 pin, like in the linked article.

0
SamR On

I assume you have already done what Atollic says in this link? Basically, ITM require the following things to redirect printf()

The application should send printf() output to an ITM channel

The JTAG probe must support SWV

The debugger must have SWV tracing with the corresponding ITM channel enabled

Despite your vendor, I assume all the ST-Links should support printf redirection. (Otherwise, use ST-Link utility and update your ST Link firmware)

Hope this helps.