cancel
Showing results for 
Search instead for 
Did you mean: 

Is STM32CubeIDE newlib with FreeRTOS now really thread safe?

msch
Associate III

I'm using STM32Cube IDE with FreeRTOS. The Errata for STM32CubeIDE 1.7.0 state "70505 Implemented a newlib-malloc solution that is thread safe by default."

Is newlib truly thread safe now? As far as I can tell, when building a project in STM32CubeIDE 1.8.0 with newlib-nano (3.3.0) no __malloc_lock()/unlock() is provided. There seem to be no calls to vTaskSuspendAll() nor to vPortEnterCritical() from inside newlib. So if newlib's malloc has been made thread safe, how? And the_ sbrk() provided in the file sysmem.c does not have any reentrancy protections.

Can someone from ST provide a definitive statement about this? And best, can you provide the source code that is used to build your version of newlib?

11 REPLIES 11
bb1
Associate III

That's a bug in the version of newlib included with ST's latest toolchain distribution.

https://community.st.com/t5/embedded-software-mcus/error-after-calling-printf/m-p/576313#M41556

DRega.1
Associate III

Thanks. I had just reached the concusion that the lock was not being initialised. The workaround does work.

I now need to implement the mods suggested by BCowp https://community.st.com/t5/stm32cubemx-mcu/cubemx-generated-threadsafe-stm32-lock-h-potential-bug/td-p/77220