Memory Allocation Hangs in CMSIS RTOS Threads, FPU Enabled, and Memory Allocation for sprintf func
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-16 3:02 AM - edited ‎2024-02-16 3:02 AM
Hi Community,
I'm currently facing a critical issue in my STM32 project involving FreeRTOS tasks, FPU (Floating-Point Unit) usage, and memory allocation for floating-point formatting. This problem has emerged after enabling FPU support and configuring project properties to accommodate floating-point operations.
Problem Overview:
My application relies heavily on FreeRTOS for task management, and recently I enabled FPU support to facilitate floating-point operations. However, upon attempting to format floating-point values with sprintf within FreeRTOS tasks, I encountered memory allocation hangs and failures. These issues occur consistently when utilizing memory allocation functions such as `malloc`, particularly within tasks involving floating-point formatting.
1. FPU Configuration: I've ensured that FPU support is properly enabled in my STM32 project, and I've configured project properties to accommodate floating-point operations.
2. Memory Allocation Hangs: The application hangs or encounters failures at memory allocation functions such as `pvPortMalloc` or `malloc`, specifically when attempting to format floating-point values within FreeRTOS tasks.
3. STM32_LOCK_BLOCK(): The application gets stuck at the `STM32_LOCK_BLOCK()` instruction within `__retarget_lock_init_recursive`, with the comment indicating /*Unable to allocate memory*/.
Have anyone encountered similar challenges with memory allocation in FPU-enabled STM32 projects, particularly when involving floating-point formatting with sprintf/snprintf within FreeRTOS tasks ?
Thank you.
- Labels:
-
Bug-report
-
STM32CubeIDE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-16 6:06 AM
Hello
not sure it is related but if you use STM32CubeIDE with "newlib-nano" C library, there is an option to be checked to use printf and scanf with floats.
It's in the STM32CubeIDE project properties, in "C/C++ build"/ "Settings" / "tool settings" / "MCU settings", "use float with printf from newlib-nano ( -u _printf_float)" (for STM32Cube 1.14.1)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-16 7:33 AM
@Guillaume K Was there a regression with the locks in one of recent CubeIDE releases? Someone reported not long ago broken locks in the newlib. Is this fixed (if was broken) in the latest release?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-16 7:53 AM
Yes, I already configured it, but I think the problem is in the newlib_lock library, as I'm using the thread safe library
