Hello,
I'm using s32studio ARM v.2.0 and s32k144 EVB.
there is one thing that I don't understand in s32k1xx_flash.ld from SDK.
as you can see below, .stack segment is located next to .heap not in the end of m_data_2.
[ m_data_2 ]
[bss][heap][stack]
however, __StackTop is set to the end address of m_data_2 as depicted in the below.
[ m_data_2 ]
[bss][heap][stack] ^
|---- __StackTop
I believe it should be like the below.
[ m_data_2 ]
[bss][heap][stack]
|---- __StackTop
Plus, stack limit indicates the wrong position according to the linker script from SDK.
[ m_data_2 ]
[bss][heap][stack] [--1K--]
^ |---- stack limit position.
should be here --|
Did I understand incorrectly?
s32k1xx_flash.ld
/* Specify the memory areas */ /* SRAM_L */ /* SRAM_U */ |
.customSectionBlock ORIGIN(m_data_2) : /* Uninitialized data section. */ .heap : .stack : /* Initializes stack on the end of block */ .ARM.attributes 0 : { *(.ARM.attributes) } |
Startup_S32k144.S
/* Initialize the stack pointer */ ldr r0,=__StackTop mov r13,r0 |
Hi,
the Stack is filled backward - from StackTop down to StackLimit. So - the location is okay.
Anyway - you can change stack location/size as you needed. Only not so "safe" thing on stack location at the end of RAM is that by stack overflow you may (but also may not) re-write data in RAM. With stacktop location on the beginning of RAM + StackSize you got exception on stack overflow because you are trying write out of memory range.
Jiri