STMicroelectronics / x-cube-azrtos-h7

X-CUBE-AZRTOS-H7 (Azure RTOS Software Expansion for STM32Cube) provides a full integration of Microsoft Azure RTOS in the STM32Cube environment for the STM32H7 series of microcontrollers.
https://www.st.com/en/embedded-software/x-cube-azrtos-h7.html
Other
149 stars 56 forks source link

newLib heap and ThreadX memory managment #2

Closed bytesontherocks closed 3 years ago

bytesontherocks commented 3 years ago

Hello,

I have some experience with FreeRTOS, and the integration with the newLib heap and the heap mechanism for FreeRTOS was not fully integrated (see http://www.nadler.com/embedded/newlibAndFreeRTOS.html).

In the current ThreadX example I understand that the RAM map looks like that

image

The newLib heap can expand to _estack (ORIGIN(RAM) + LENGTH(RAM)) - _Min_Stack_Size according to the current "_sbrk" implementation that would mean that if you use malloc/new() at any point in your system, you could potentially be overwriting the ThreadX memory pool.

The NewLib heap and the ThreadX allocation are working completely unaware one of an other. If it is up to the user to be aware of that, that should be documented, it can cause quite a lot of problems. Otherwise, are you planing to offer a better integration?

Looking forward to reading your thoughts.

Thanks.

ALABSTM commented 3 years ago

Hi @bytesontherocks,

Thank you for this contribution. Your report will be forwarded to our development teams. I will get back to you as soon as they provide me with their feedback.

With regards,

ALABSTM commented 3 years ago

Hi @bytesontherocks,

Our development teams confirmed your point. However, they said good management of allocations in both NewLib heap and ThreadX memory pool falls on the "shoulders" of the user application.

From our side, we will try to highlight such an important point in our documentation.

Thank you again for having reported this point.

With regards,

ALABSTM commented 3 years ago

ST Internal Reference: 107765