We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi,
I'm currently using CMSIS 5.7.0 with ARM compiler 5.I noticed that there are 2 locations where HEAP, STACK size are defined.files are located in CMSIS 5.7.0 directory: ARM.CMSIS.5.7.0/Device/_Template_Vendor/Vendor/Device/Source/ARM
In the scatter file, it defines STACK/HEAP size and it's placement defined as ARM_LIB_HEAP and ARM_LIB_STACK.
/*--------------------- Stack / Heap Configuration --------------------------- ; <h> Stack / Heap Configuration ; <o0> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> ; <o1> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> ; </h> *----------------------------------------------------------------------------*/ #define __STACK_SIZE 0x00000200 #define __HEAP_SIZE 0x00000C00 . . . LR_ROM __RO_BASE __RO_SIZE { ; load region size_region ER_ROM __RO_BASE __RO_SIZE { ; load address = execution address *.o (RESET, +First) *(InRoot$$Sections) .ANY (+RO) .ANY (+XO) } RW_RAM __RW_BASE __RW_SIZE { ; RW data .ANY (+RW +ZI) } #if __HEAP_SIZE > 0 ARM_LIB_HEAP __HEAP_BASE EMPTY __HEAP_SIZE { ; Reserve empty region for heap } #endif ARM_LIB_STACK __STACK_TOP EMPTY -__STACK_SIZE { ; Reserve empty region for stack } }
In the assembly startup file, it also defines STACK/HEAP size as below.
;<h> Stack Configuration ; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> ;</h> Stack_Size EQU 0x00000400 AREA STACK, NOINIT, READWRITE, ALIGN=3 __stack_limit Stack_Mem SPACE Stack_Size __initial_sp ;<h> Heap Configuration ; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> ;</h> Heap_Size EQU 0x00000C00 IF Heap_Size != 0 ; Heap is provided AREA HEAP, NOINIT, READWRITE, ALIGN=3 __heap_base Heap_Mem SPACE Heap_Size __heap_limit ENDIF PRESERVE8 THUMB
I find this troublesome since if I have to modify both files at the same time.
Is there a reason for this?
I have also noticed the corresponding new startup_Device.c does not redefine stack/heap size like in the assembly startup file.
Thanks ahead for the help!
The mentioned assembly startup is based on the older approach where startup was standalone and STACK/HEAP was configured within the startup file rather than with the linker scatter file. This is being deprecated.
The newer “C Startup” variant includes the C startup combined with linker scatter file that configures STACK/HEAP. The new scatter file should only be used together with the C startup and is not needed when using the legacy assembly startup.
Thanks for the reply, I will use the new C startup file from now on.