cancel
Showing results for 
Search instead for 
Did you mean: 

FreeRTOS float printf STM32L476RG hardfault NOCP

Romain Mahieu
Associate II

Hello,

When I do a simple printf("%f",onefloat); in freertos task (code generated with STM32CubeIde 1.3.1, using HAL L5_V1.15.1), I have an hardfault, UFSR register tell me that an NOCP error occur, -mfloat-abi=hard, GNU Toolchain. On internet someone propose patch https://github.com/leech001/STM32-FreeRTOS-float but it require to be reimplemented everytime when the code is regenerated.

Is there another clean solution ?

Thank you

1 REPLY 1
Bob S
Principal

This is a known issue - newlib's printf() for floats calls malloc. ST's FreeRTOS and malloc support is broken (in most implementations, I don't know about the L5 version, but it is likely still broken). @Dave Nadler​ had some good posts on this. Search for "nadler freetos bug", or go directly:

https://community.st.com/s/question/0D50X0000BB1eL7SQJ/bug-cubemx-freertos-projects-corrupt-memory

And then also follow the link to Dave's web page that describes how to fix it.