cancel
Showing results for 
Search instead for 
Did you mean: 

Still fighting to setup SWO trace on STM32H7

Gpeti
Senior II

Hello,

A few months ago I tried without success to setup ITM on a STM32H753I-EVAL2 board (and STM32CubeIDE). Now I'm trying again. There is a precise point I'm not sure about: the signal SWO is multiplexed on GPIO PB3, so I have to setup PB3 with alternate function SWO in my software. But is the SWO signal routed to the STLink ? Or in other terms: is it enough to plus the board through USB to the STLink to get the ITM outputs ?

Thank you

PS: I'm well aware of the following thread: https://community.st.com/s/feed/0D50X00009nNBBHSA4

29 REPLIES 29

The schematic should be pretty definitive about what wires connect to what.

I have some of the earlier H743I-EVAL boards, with an ST-LINK V2.

The board with the V3 will likely not use 2 MHz SWD clock, but rather a 15 MHz one. Watch this value when setting baud rate dividers vs core clock.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Gpeti
Senior II

Clive, did you manage to make SWO work ? I understand from this link that you could not : https://community.st.com/s/question/0D50X00009XkhURSAZ/stm32h7-swo-printf-not-working

About the clock, STM32CubeIDE does not allow to setup a SWO clock faster than 2MHz.

The link cited in the top post showed that I did.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

OK. I've read this message from you "Yeah, bit frustrated with the response here too. Not seen SWV connectivity work on any H7 board (have EVAL and DISCO here), and fiddled with it a lot, although " but the date of the post was confusing.

At the end, do you remember what was your problem / how you fixed it ? Sorry but there are multiple threads on the topic and I am a bit lost, depsite having implemented the C code that you posted.

SWO print works fine here on STM32H753I-EVAL2 , wth Atollic 9.3.0 and Keil 5.27 - set up in debugger config as usual, at 400 MHz.

Maybe the problem is in the CubeIDE. Not using it, because of other people's feedback.

-- pa

Than you for the feedback.

Could you confirm that you are using STLink GDB server (in Atollic) and SWV Core clock is set to 400MHz, SWO clock to 2000 kHz ?

Could you share the function to init SWD ? (unless it's exactly the same that the one posted by Clive)

Guillaume

In September 2019 one might hope the tools have evolved to understand the requirements of the H7 plumbing.

The criticality here is two fold, a) the plumbing of the swv funnel must be correct, the b) clock and dividers need to be coherent and match reality.

This can be achieved in a number of ways, a) the tools can do it all transparently, b) you can configure it with a Debugger Script, or c) you can do it in-line with C code in your application.

The 0xC7 setting (199, or 200-1) comes from a 400 MHz clock being divided by 2 MHz, if you are running at 480 MHz the divider will need to be different, if your debugger clock is not actually 2 MHz it will also need to be different. But whatever, it needs to match reality, otherwise the gears are going to grind.

Keil reports different frequencies for the ST-LINK V2 vs V3, what CubeIDE does, and how OpenOCD works, I don't know, these are not tools I have chosen to use. Perhaps review the output/connection logs, review the debugger scripts. Perhaps output telemetry via a USART to understand how the board sees the settings internally. In the top post cited, you'll see a screen shot where I was outputting to SWV and USART. Here I made sure my "putchar" function used the USART and ITM_SendChar() function.

Amel or Nawres posted a document and example for the GNU stuff, but the functionality is notionally the same, the syntax might differ. Most of this stuff assumes some level of familiarity with the tools you've chosen to use.

There are two LAR writes because multiple different units of the debug hardware are getting involved, and each has its own locking mechanism.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Yes. The debugger itself initializes the interface, I don't touch it in the code,

0690X00000ARYO3QAP.jpg

The only annoying thing is that the SVW console in Atollic must be activated manually every time after starting debug session.

Anyone knows how to start it automatically?