cancel
Showing results for 
Search instead for 
Did you mean: 

What does malloc() do in an STM32 MCU run without an OS ?

Shiina
Associate III

How does STM32 dynamically allocate memory ?

1 ACCEPTED SOLUTION

Accepted Solutions

https://stackoverflow.com/questions/77829982/how-does-arm-none-eabi-gcc-9-2-implement-malloc-free

 

EDIT

You didn't state what compiler you're asking about.

The above relates to the GCC/ARM compiler, as used in the STM32CubeIDE, using the newlib library.

Other compilers & libraries are available; eg,

https://developer.arm.com/documentation/dui0067/d/the-c-and-c---libraries/tailoring-storage-management/support-for-malloc

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

View solution in original post

4 REPLIES 4

https://stackoverflow.com/questions/77829982/how-does-arm-none-eabi-gcc-9-2-implement-malloc-free

 

EDIT

You didn't state what compiler you're asking about.

The above relates to the GCC/ARM compiler, as used in the STM32CubeIDE, using the newlib library.

Other compilers & libraries are available; eg,

https://developer.arm.com/documentation/dui0067/d/the-c-and-c---libraries/tailoring-storage-management/support-for-malloc

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

It allocates memory from the heap. In the GNU/GCC sense this is from the top of the statics to the bottom of the stack via sbrk().

On Keil/IAR it would be a section of heap memory of defined size that the linker places after the statics. 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mƎALLEm
ST Employee

From the title I understand: in which situation the dynamic allocation is used if no rtos is used, but in the text I understand something else. Need to be concise.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

thanks