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
Andrew Neil
Evangelist III

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

 

View solution in original post

4 REPLIES 4
Andrew Neil
Evangelist III

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

 

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..
SofLit
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