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

Share code examples or discuss embedded software, including device drivers, interrupt handlers, middleware and application code.

Moderators: Markus Girdland, Mattias Norlander

blargian
Posts: 1
Joined: Thu Feb 07, 2019 8:23 pm

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

Postby blargian » Thu Feb 07, 2019 9:12 pm

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.
You do not have the required permissions to view the files attached to this post.

frank_ee
Posts: 74
Joined: Wed Apr 05, 2017 5:08 pm
Location: USA

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

Postby frank_ee » Sun Feb 10, 2019 8:18 pm

Hello,

Did you select the debugger window to select ITM?


Return to “Embedded target code development discussions”

Who is online

Users browsing this forum: No registered users and 1 guest