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

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

If my memory serves, the ITM clock has additional divisor or multiplier. New ST tools know this and compensate.

Which tools are you talking about? I use STM32CubeIDE v.1.9.0, CuveMX v.6.5.0

RomainR.
ST Employee

Hello @ypiotrp (Community Member) 

I successfully tested printf stdio redirected to ITM SWO on STM32H7A3VIT on custom board with STLinkV2-1 standalone and STM32CubeIDE v1.11.0 (but it also works with v1.9.0)

Here a screenshot of SWV ITM Data Console, SWV Data Trace Timeline Graph and Live Expression:

0693W00000Y9DbYQAV.pngI can suggest to check following point:

  • Debug is configured as Trace Asynchronuous Sw in CubeMx
  • PB3 is connected to STLinkV2-1 Debugger on pin TDO-SWO (13)

If you have syscalls.c in your project, simply re define __io_putchar in the main.c.

/* USER CODE BEGIN 4 */
int __io_putchar(int ch)
{
 ITM_SendChar(ch);
 return(ch);
}
/* USER CODE END 4 */

Include stdio.h header and your code to printf and increment counter variable.

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "stdio.h"
/* USER CODE END Includes */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
uint8_t counter = 0;
/* USER CODE END PV */
/* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    printf("Counter= %d\r\n", counter);
    counter++;
    HAL_Delay(500);
    /* USER CODE END WHILE */
 
    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */

In the debug configuration, enable SWV with the same CPU clock (280MHz)

0693W00000Y9DdoQAF.pngLaunch the debugger, open SWV ITM Data Console, enable ITM Stimulus Ports 0 (optionally set counter variable in data trace comparator)

0693W00000Y9DewQAF.pngStart Trace (red button icon) and resume debugger.

0693W00000Y9DfkQAF.png

Good luck,

Best regards,

Romain,

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.

ypiotrp
Senior

OK, I got it working!

Sorry for the trouble explaining it to me. It turned out I made a mistake and soldered SWO wire to wrong pin in my custom SWD plug.

I have the last question. Is there some simple way to access SWO data from localhost:61235? I tried connecting to that port using PuTTy but without any success :(

Regards,

Piotr

AScha.3
Chief III

putty :)

you need a "debug" connection; new version of Cube programmer should work...(i didnt test)

0693W00000Y9bRSQAZ.png 

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