I'm working on an embedded project with FreeRTOS, where I only use static memory allocation.
Looking at my linker script, I find that the following are taking up RAM space:
.data
.bss
._user_heap_stack
To my knowledge, ._user_heap_stack
is used during the linking process to see if there is enough RAM space for the user-specified minimum MSP stack size. Here is a relevant snippet in my linker script:
/* User_heap_stack section, used to check that there is enough RAM left */
._user_heap_stack :
{
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(8);
} >RAM
I believe that MSP will always be initialized to point to the end of RAM regardless of _Min_Stack_Size
, and decrement from there and data is pushed onto the stack. I see that my startup .S
file configures sp
as follows:
_estack = 0x20004000; /* end of RAM */
Reset_Handler:
ldr sp, =_estack /* Atollic update: set stack pointer */
As for FreeRTOS tasks, they each have stack space that is statically allocated, so it has nothing to do with _user_heap_stack
I think?
My question is, with the RAM allocated .data
, .bss
, and _user_heap_stack
, I still have some unallocated RAM, so what happens to those RAM? Is it used by anything? Is it ever useful to reserve some free RAM (i.e. non-statically allocated RAM) or is it just wasted? Or perhaps it is just extra space for MSP to use if the main stack ever grows larger in size than what's specified in _Min_Stack_Size
?