cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7B0 SWO over ITM doesn't work

ypiotrp
Senior

Hi!

I have a problem setting up Serial Wire Output over ITM. I followed every tutorial on the Internet (including this forum) and I still haven't made any progress.

I run the MCU on 280 Mhz:

0693W00000Y92EsQAJ.pngIn Pinout & Configuration -> DEBUG I configured Serial Wire as debug interface.

I've implemented my own _write() function as below:

int _write(int file, char *ptr, int len) {
  int DataIdx;
  for (DataIdx = 0; DataIdx < len; DataIdx++) {
    ITM_SendChar(*ptr++);
  }
  return len;
}

Next I just call printf inside some loop in main():

while(1) {
	  printf("counter = %d\n", counter++);
	  delay = 280000;
	  while(delay--);
  }

 My debug configuration looks like this:

0693W00000Y92H3QAJ.pngAnd my SWV ITM configuration looks like this:

0693W00000Y92IzQAJ.png 

Please help me figure out how to get it up and running, because I'm getting frustrated after all my failures in tutorials.

Regards,

Piotr

14 REPLIES 14
RomainR.
ST Employee

Hello @ypiotrp (Community Member) 

"In Pinout & Configuration -> DEBUG I configured Serial Wire as debug interface."

You must set Trace Asynchronous SWO with PB3 as JTDO-SWO.

0693W00000Y92NkQAJ.pngRegards,

Romain,

In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hi Romain,

I tired also this option but the result was the same - empty SWV ITM Data Console. Have you got any other idea?

Regards,

Piotr

AScha.3
Chief II

i tried many hours, until i see something... so dont be surprised to get nothing at first.

  1. you have set >>  Trace Asynchronous SWO << ?
  2. you connected SWO to STlink SWD input ?
  3. your STlink is original V2 or V3 ?
  4. set speed in debug configuration ? max. 2 MHz for V2 , or >> auto detect <<
  5. click (in debug mode - at start) red trace/start button ? (if bright red, dark red = not active)
  6. in opened view console for text, graph or timing ?
  7. you can only start trace , when debug paused !
  8. sometimes not working, try : pause debug, click >once on red start button, run debug again....

(is buggy, not really reliable ; but when working, is very useful... )

If you feel a post has answered your question, please click "Accept as Solution".
  1. Yes, I set Trace Asynchronous SWO - still no result.
  2. Yes, these two are connected.
  3. Original STLink V2.
  4. As you can see on the screenshot from debug configuration STLink's speed is set to "auto detect"
  5. Yes, the button is clicked and trace started.
  6. Don't understand what do you mean by that. I open ITM Data Console and it remains empty.
  7. I start trace on the start of the debug (default breakpoint in main()). The MCU is halted.
ypiotrp
Senior

What's more my _write() function implementation gets called properly and in consequence ITM_SendChar().

AScha.3
Chief II

> 6. yes, the ITM Data Console (i opened also time line dia. and Statistic Profiling )

> 7. ok. sometimes it dont start working, need open cofiguration, close it, > red button, change window to Profiling , > red button, change back to DataConsole , > red button ; debug > run , then it working;

funny: stop debug, modify program, compile, debug -> ITM Data Console still /again working ! (as been set on last debug session..)

If you feel a post has answered your question, please click "Accept as Solution".
Pavel A.
Evangelist III

@Community member​ Have you already used the SWO printf redirection with any other STM32 (to make sure you know how to set it up and start SWO console in the debugger)?

IIRC the STM32H7A/B family has some subtle difference in ITM settings, compared with older STM32H7. Do you use the latest CubeIDE?

@AScha.3​ This issue already has been reported to ST, they should be working on a fix. @Markus GIRDLAND​  ?

AScha.3
Chief II

this is, what comes from USB host , with debug on:

0693W00000Y9AA0QAN.png+ i didnt click red button or anything, still setup is running like i set it 3 days ago , on last debug of this project.

If you feel a post has answered your question, please click "Accept as Solution".

To be honest I haven't done it before, this is my first time.

But I took some Nucleo-F429ZI from my drawer and gave it a try. It worked like a charm in both scenarios - using embedded STLinkV2 and an external one I'm using for my custom board. It looks like I can set it up properly 😁

Can you tell me something more about these 'subtle difference'?

Regards,

Piotr