cancel
Showing results for 
Search instead for 
Did you mean: 

FreeRTOs stuck at vsprintf

Neel
Associate III

Hi,

I have used STM32l562-edk evk hardware and stm32cubeide for software. I have enable freertos in the project. For debug print message purpose I have created one function named as logPrint.

char g_msg_buf[100];

void logPrint(const char *format, ...)

{

int DataIdx = 0;

int len = 0;

va_list args;

va_start(args, format);

vsprintf(g_msg_buf,format, args);

len = strlen(g_msg_buf);

for (DataIdx = 0; DataIdx < len; DataIdx++) {

ITM_SendChar( g_msg_buf[DataIdx] );

}

va_end (args);

}

When I have run the program and invoke the logPrint function at that time OS stuck at vsprintf.

Observation:

  1. When I have disable the freeRTOS then function is working properly and i get the data on console.
  2. When I have enable the freeRTOS then OS stuck at vsprintf.

Please help me to figure out this issue.

1 ACCEPTED SOLUTION

Accepted Solutions
hs2
Senior

1st check that the stack size of the task(s) using printf-family functions is large enough. They need a lot more than the minimal stack size often used at the beginning for whatever reason. Try e.g.. 2k and tailor it later.

Also there are FreeRTOS config items to enable stack checks and asserts. Enable them all while developing/ debugging.

View solution in original post

8 REPLIES 8
prain
Senior III

printf family of functions are not thread safe (specially gcc implementation). use a thread safe printf library like this:

https://github.com/mpaland/printf

Nikita91
Lead II

Common problem, I think. Check your configuration with:

http://www.nadler.com/embedded/newlibAndFreeRTOS.html

hs2
Senior

1st check that the stack size of the task(s) using printf-family functions is large enough. They need a lot more than the minimal stack size often used at the beginning for whatever reason. Try e.g.. 2k and tailor it later.

Also there are FreeRTOS config items to enable stack checks and asserts. Enable them all while developing/ debugging.

hs2
Senior

There is a also a doc provided by STM which could be helpful:

Developing applications on STM32Cube with RTOS

and note that FreeRTOS Support by CubeIDE v1.4.0 is broken. Maybe use CubeIDE v1.3.0 instead.

Pavel A.
Evangelist III

> and note that FreeRTOS Support by CubeIDE v1.4.0 is broken

Any details or reference, please?

-- pa

It‘s already reported and confirmed by ST here. It‘s messing up the interrupt prios.

Thanks -- pa

Neel
Associate III

Hi All,

Thank you for your quick reply.

Issue is resolved.