6 years, 11 months ago.

mbed-RTOS, printf in thread, freeze - pb with stack size ?

Hello,

I tried to include some "printf" in a threads of mbed-rtos... and this results in a program freeze/crash. While similar "printf" statements added in the main loop does not lead to a program freeze.

I'am wondering if the stack or heap size allocated to the thread is sufficient for the printf to operate correctly. Do anyone know how to configure RTOS / threads in order to get printf working in these threads ?

Thanks in advance.

1 Answer

6 years, 11 months ago.

Hi Bernard,

As you think its about thread size. I have same problem. And I changed stack size of thread and printf is working well .

Chanceing thread stack size ,

in main function you can create a thread with parameters,

for example , creating system thread,

include the mbed library with this snippet

Thread SYSTEM_THREAD(SYSTEM);
change to
Thread SYSTEM_THREAD(SYSTEM,NULL,osPriorityNormal,1024);  // Stack size will be 1024byte

I'm using STM32F 401RE and it has 96KB RAM. 1024 byte thread is not too much. Default paramteres should be in somewhere in RTOS library. Online compiler is not capability of search etc.