diff --git a/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/flash.ld b/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/flash.ld index c081401f7..53f2b5f1f 100644 --- a/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/flash.ld +++ b/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/flash.ld @@ -40,9 +40,6 @@ MEMORY ram (rwx) : ORIGIN = 0x20070000, LENGTH = 0x00018000 /* sram, 96K */ } -/* The stack size used by the application. NOTE: you need to adjust */ -STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : 0x8000 ; - /* Section Definitions */ SECTIONS { @@ -129,16 +126,21 @@ SECTIONS _ezero = .; } > ram - /* stack section */ - .stack (NOLOAD): - { - . = ALIGN(8); - _sstack = .; - . = . + STACK_SIZE; - . = ALIGN(8); - _estack = .; - } > ram - . = ALIGN(4); _end = . ; + + /* .stack_dummy section doesn't contains any symbols. It is only + used for linker to calculate size of stack sections, and assign + values to stack symbols later */ + .stack_dummy : + { + *(.stack*) + } > ram + + /* Set stack top to end of ram, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(ram) + LENGTH(ram); + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(_sstack = __StackLimit); + PROVIDE(_estack = __StackTop); }