2020-12-15 04:51 AM
2020-12-15 05:25 AM
Heap and Stack are at the top end of the RAM (unless you're using an RTOS).
from generated sysmem.c:
* ############################################################################
* # .data # .bss # newlib heap # MSP stack #
* # # # # Reserved by _Min_Stack_Size #
* ############################################################################
* ^-- RAM start ^-- _end _estack, RAM end --^
So, the heap does not waste space except you're using it at runtime.
The .ld linker file reserves some space for the heap at link time using the symbol _Min_Heap_Size. Linking fails if less than _Min_Heap_Size + _Min_Stack_Size are free in RAM. You can adjust these linker values in the .ioc file's Project Manager tab. But, if linking succeeds you can gain nothing from changing these values.
Keep in mind that some C runtime functions may use the heap internally, so you might set a breakpoint or do some debug print in sysmem.c function _sbrk to find out whats happening in your system at runtime or study the sources.
2020-12-15 05:25 AM
Heap and Stack are at the top end of the RAM (unless you're using an RTOS).
from generated sysmem.c:
* ############################################################################
* # .data # .bss # newlib heap # MSP stack #
* # # # # Reserved by _Min_Stack_Size #
* ############################################################################
* ^-- RAM start ^-- _end _estack, RAM end --^
So, the heap does not waste space except you're using it at runtime.
The .ld linker file reserves some space for the heap at link time using the symbol _Min_Heap_Size. Linking fails if less than _Min_Heap_Size + _Min_Stack_Size are free in RAM. You can adjust these linker values in the .ioc file's Project Manager tab. But, if linking succeeds you can gain nothing from changing these values.
Keep in mind that some C runtime functions may use the heap internally, so you might set a breakpoint or do some debug print in sysmem.c function _sbrk to find out whats happening in your system at runtime or study the sources.
2020-12-15 05:41 AM
Thanks, just setting _Min_Heap_Size = 0, solved my problem
2020-12-15 07:00 AM
You can e.g. reduce the heap size while creating the project in STM32CubeIDE and editing the IOC file:
Project Manager > Project > Linker Settings
This will modify the .ld file and set the entry _Min_Heap_Size accordingly.
Regards
/Peter