Page 1 of 1

Trouble getting printf() redirection using SWV/ITM to work

Posted: Thu Feb 07, 2019 9:12 pm
by blargian
Hello world,

I am an STM32 newbie. I recently got an STM32F429 Discovery dev board which I have been playing around with. Currently I'm trying to figure out how to use the debugging functions of this M4 Cortex, specifically the SWV ones.

I used STM32CubeMX to generate a project and then modified the main.c files infinite loop as follows to blink an LED on and off every 2 seconds and to printf a message to the console.

Code: Select all

  while (1)
  {
     HAL_GPIO_TogglePin(GPIOG,GPIO_PIN_13);
     HAL_Delay(2000);
     printf("hello");

  }


When I run the debug it programs the board fine. I followed the steps in this http://blog.atollic.com/cortex-m-debugging-printf-redirection-to-a-debugger-console-using-swv/itm-part-1 article which explains how to setup printf redirect to the console however I can't get it to do so. When I step through my code and get to that printf("hello") line it just skips over it like it doesn't exist and nothing is printed to the console.

I've attached a picture of my debug settings and below I have placed the modified version of int _write which resides in my syscalls.c file. I also have "#include "stm32f4xx.h" in that file.

Code: Select all

int _write(int32_t file, uint8_t *ptr, int32_t len)
{
   int i=0;
     for(i=0 ; i<len ; i++)
       ITM_SendChar((*ptr++));
     return len;
   
   errno = ENOSYS;
   return -1;
}


I would greatly appreciate if anyone could assist me in getting the printf to console to work.

Re: Trouble getting printf() redirection using SWV/ITM to work

Posted: Sun Feb 10, 2019 8:18 pm
by frank_ee
Hello,

Did you select the debugger window to select ITM?