Change Stack Location for Cortex M3 in Startup.s file

607 views Asked by At

I am trying to change STACK location for user application. In my system, user application has own RAM section (Data + Stack) andlinker puts STACK at the end of user RAM section. But I need to put STACK at beginning instead of end.

I am working with Keil uVision IDE and startup.s file and startup.s file does not provide any option to change location of change STACK location, probably, linker hides it

Stack_Size      EQU     0x00000200

                AREA    STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem       SPACE   Stack_Size
__initial_sp

It is possible to locate STACK in a special address or especially at the beginning of RAM Section?

Thanks.

1

There are 1 answers

2
muratcakmak On BEST ANSWER

If I create RAM two regions using scatter file and if I put *(STACK) directive to first one and , it seems OK and STACK is located to start of User RAM. For now, it solves my issue, but possible better solutions exist. Thanks.

  RW_IRAM1 0x10005000 0x00000200  {  ; STACK
   *(STACK)
  }
  RW_IRAM2 0x10005200 0x00000E00  {  ; RW data
   .ANY (+RW +ZI)
  }