AnsweredAssumed Answered

Placing Stack and Heap at specific location

Question asked by bamford.konrad on Jul 31, 2012

I have the following scatter file,

LR_IROM1 0x08000000 0x00100000
{    ; load region size_region
;ARM_LIB_HEAP 0x20000000 EMPTY 0x200{}  ; Heap starts at 1MB
                                               ; and grows upwards
;ARM_LIB_STACK 0x20020000 EMPTY -0x400{}         ; Stack space starts at the end
                                               ; of the 2MB of RAM
                                               ; And grows downwards for 32KB
  ER_IROM1 0x08000000 0x00100000
  {  ; load address = execution address
   *.o (RESET, +First)
   .ANY (+RO)
  RW_IRAM1 0x20000000 0x00020000
   .ANY3 (+RW +ZI)
  RW_IRAM2 0x10000000 0x00010000
   .ANY2 (+RW +ZI)
  RW_RAM1 0x68000000 0x00080000
  {  ; RW data
   .ANY1 (+RW +ZI)

If I uncomment the two Stack and Heap directives and remove the priorities of the .ANY, the linker puts the Stack in RAM1 which is external RAM. What is the correct syntax to specify the location of the Stack.

I am using the "startup_stm32f4xx.s" which contains Stack initialisation,

; User Stack and Heap initialization
                 IF      :DEF:__MICROLIB
                 EXPORT  __initial_sp
                 EXPORT  __heap_base
                 EXPORT  __heap_limit
                 IMPORT  __use_two_region_memory
                 EXPORT  __user_setup_stackheap
                 LDR     R0, =  Heap_Mem
                 LDR     R1, =(Stack_Mem + Stack_Size)
                 LDR     R2, = (Heap_Mem +  Heap_Size)
                 LDR     R3, = Stack_Mem
                 BX      LR

The ARM_LIB_STACK directive is taken straight from the Keil help.