I am trying to find a way to allocate all remaining RAM in my application to the heap. Basically a variable heap size that will allow the use of all available memory. I have tried different things with the scatter file, but keep running into needing to specify a size.
I would like the RAM memory map to look like this:
RAM Base Address:
Processor: STM32L552
Tools: uVision 5
Existing Scatter File:
; Vector tableLR_VECTOR_TABLE 0x08000000 0x00000200{ ER_VECTOR_TABLE 0x20000000 0x00000200 { *.o (RESET, +First) ; Vector table location in RAM. }}
; load region size_regionLR_IROM1 (0x08000000 + 0x00000200) (0x00080000 - 0x00000200){ ; load address = execution address ER_IROM1 (0x08000000 + 0x00000200) (0x00080000 - 0x00000200) { *(InRoot$$Sections) .ANY (+RO) .ANY (+XO) }
; RW data RW_IRAM1 (0x20000000 + 0x00000200) (0x00040000 - 0x00000200) { .ANY (+RW +ZI) }
}
Default Keil/STM Cube MX stack and heap setup in "startup_stm32l552xx.s":
; Amount of memory (in bytes) allocated for Stack; Tailor this value to your application needs; <h> Stack Configuration; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>; </h>
Stack_Size EQU 0x00002000
AREA STACK, NOINIT, READWRITE, ALIGN=3Stack_Mem SPACE Stack_Size__initial_sp
; <h> Heap Configuration; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>; </h> Heap_Size EQU 0x00001000
AREA HEAP, NOINIT, READWRITE, ALIGN=3__heap_baseHeap_Mem SPACE Heap_Size__heap_limit
You can try this in the the scatter file:
heap_init heap_start heap_size { } ;; ;; Now place endmark. ;; The linker will issue a warning if the ;; two sections overlap. ;; heap_endmark heap_end EMPTY -0 { }
and use the $$ symbols to define __heap_base and __heap_size