From 888f49dade7ff8aadf1e91df9c0f16d6ee727e41 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Fri, 21 Dec 2018 09:00:03 +0100 Subject: [PATCH] [NORDIC] Support boot stack size configuration option --- .../TARGET_MCU_NORDIC_32K/nRF51822.sct | 6 ++++++ .../TARGET_MCU_NRF51_16K_S110/nRF51822.sct | 6 ++++++ .../TARGET_MCU_NRF51_16K_S130/nRF51822.sct | 6 ++++++ .../TARGET_MCU_NORDIC_32K/NRF51822.ld | 8 ++++++-- .../TARGET_MCU_NRF51_16K_S110/NRF51822.ld | 8 ++++++-- .../TARGET_MCU_NRF51_16K_S130/NRF51822.ld | 8 ++++++-- .../device/TOOLCHAIN_GCC_ARM/startup_NRF51822.S | 7 ------- .../TARGET_MCU_NORDIC_16K/nRF51822_QFAA.icf | 5 ++++- .../TARGET_MCU_NORDIC_32K/nRF51822_QFAA.icf | 6 ++++-- .../TARGET_MCU_NORDIC_32K/nRF51822.sct | 6 ++++++ .../TARGET_MCU_NRF51_16K_S110/nRF51822.sct | 6 ++++++ .../TARGET_MCU_NRF51_16K_S130/nRF51822.sct | 6 ++++++ .../TARGET_MCU_NORDIC_32K/NRF51822.ld | 8 ++++++-- .../TARGET_MCU_NRF51_16K_S110/NRF51822.ld | 8 ++++++-- .../TARGET_MCU_NRF51_16K_S130/NRF51822.ld | 8 ++++++-- .../device/TOOLCHAIN_GCC_ARM/startup_NRF51822.S | 7 ------- .../TARGET_MCU_NORDIC_16K/nRF51822_QFAA.icf | 5 ++++- .../TARGET_MCU_NORDIC_32K/nRF51822_QFAA.icf | 6 ++++-- .../device/TOOLCHAIN_ARM_STD/nRF52832.sct | 4 ++++ .../device/TOOLCHAIN_GCC_ARM/NRF52832.ld | 12 ++++++++---- .../device/TOOLCHAIN_IAR/nRF52832.icf | 7 +++++-- .../device/TOOLCHAIN_ARM_STD/nRF52840.sct | 4 ++++ .../device/TOOLCHAIN_GCC_ARM/NRF52840.ld | 12 ++++++++---- .../device/TOOLCHAIN_IAR/nRF52840.icf | 7 +++++-- 24 files changed, 122 insertions(+), 44 deletions(-) diff --git a/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_ARM_STD/TARGET_MCU_NORDIC_32K/nRF51822.sct b/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_ARM_STD/TARGET_MCU_NORDIC_32K/nRF51822.sct index cbbea83ae7..b063955385 100644 --- a/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_ARM_STD/TARGET_MCU_NORDIC_32K/nRF51822.sct +++ b/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_ARM_STD/TARGET_MCU_NORDIC_32K/nRF51822.sct @@ -1,3 +1,5 @@ +#! armcc -E + ;WITHOUT SOFTDEVICE: ;LR_IROM1 0x00000000 0x00040000 { ; ER_IROM1 0x00000000 0x00040000 { @@ -12,6 +14,8 @@ ; ;WITH SOFTDEVICE: +#define Stack_Size MBED_BOOT_STACK_SIZE + LR_IROM1 0x1C000 0x0024000 { ER_IROM1 0x1C000 0x0024000 { *.o (RESET, +First) @@ -21,4 +25,6 @@ LR_IROM1 0x1C000 0x0024000 { RW_IRAM1 0x20002800 0x00005800 { .ANY (+RW +ZI) } + ARM_LIB_STACK 0x20002800+0x00005800 EMPTY -Stack_Size { ; Stack region growing down + } } diff --git a/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_ARM_STD/TARGET_MCU_NRF51_16K_S110/nRF51822.sct b/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_ARM_STD/TARGET_MCU_NRF51_16K_S110/nRF51822.sct index 62638400f2..1a3cd8ec11 100644 --- a/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_ARM_STD/TARGET_MCU_NRF51_16K_S110/nRF51822.sct +++ b/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_ARM_STD/TARGET_MCU_NRF51_16K_S110/nRF51822.sct @@ -1,3 +1,5 @@ +#! armcc -E + ;WITHOUT SOFTDEVICE: ;LR_IROM1 0x00000000 0x00040000 { ; ER_IROM1 0x00000000 0x00040000 { @@ -12,6 +14,8 @@ ; ;WITH SOFTDEVICE: +#define Stack_Size MBED_BOOT_STACK_SIZE + LR_IROM1 0x18000 0x0028000 { ER_IROM1 0x18000 0x0028000 { *.o (RESET, +First) @@ -21,4 +25,6 @@ LR_IROM1 0x18000 0x0028000 { RW_IRAM1 0x20002000 0x00002000 { .ANY (+RW +ZI) } + ARM_LIB_STACK 0x20002000+0x00002000 EMPTY -Stack_Size { ; Stack region growing down + } } diff --git a/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_ARM_STD/TARGET_MCU_NRF51_16K_S130/nRF51822.sct b/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_ARM_STD/TARGET_MCU_NRF51_16K_S130/nRF51822.sct index 212c545f25..acdeb8ba15 100644 --- a/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_ARM_STD/TARGET_MCU_NRF51_16K_S130/nRF51822.sct +++ b/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_ARM_STD/TARGET_MCU_NRF51_16K_S130/nRF51822.sct @@ -1,3 +1,5 @@ +#! armcc -E + ;WITHOUT SOFTDEVICE: ;LR_IROM1 0x00000000 0x00040000 { ; ER_IROM1 0x00000000 0x00040000 { @@ -12,6 +14,8 @@ ; ;WITH SOFTDEVICE: +#define Stack_Size MBED_BOOT_STACK_SIZE + LR_IROM1 0x1C000 0x0024000 { ER_IROM1 0x1C000 0x0024000 { *.o (RESET, +First) @@ -21,4 +25,6 @@ LR_IROM1 0x1C000 0x0024000 { RW_IRAM1 0x20002800 0x00001800 { .ANY (+RW +ZI) } + ARM_LIB_STACK 0x20002800+0x00001800 EMPTY -Stack_Size { ; Stack region growing down + } } diff --git a/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NORDIC_32K/NRF51822.ld b/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NORDIC_32K/NRF51822.ld index 41546f2c78..88357ce3e9 100644 --- a/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NORDIC_32K/NRF51822.ld +++ b/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NORDIC_32K/NRF51822.ld @@ -1,5 +1,9 @@ /* Linker script to configure memory regions. */ +#if !defined(MBED_BOOT_STACK_SIZE) + #define MBED_BOOT_STACK_SIZE 0x800 +#endif + MEMORY { FLASH (rx) : ORIGIN = 0x0001C000, LENGTH = 0x24000 @@ -130,7 +134,7 @@ SECTIONS end = __end__; __HeapBase = .; *(.heap*) - . = ORIGIN(RAM) + LENGTH(RAM) - Stack_Size; + . = ORIGIN(RAM) + LENGTH(RAM) - MBED_BOOT_STACK_SIZE; __HeapLimit = .; } > RAM @@ -145,7 +149,7 @@ SECTIONS /* 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); + __StackLimit = __StackTop - MBED_BOOT_STACK_SIZE; PROVIDE(__stack = __StackTop); /* Check if data + heap + stack exceeds RAM limit */ diff --git a/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S110/NRF51822.ld b/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S110/NRF51822.ld index f4eaf88e05..98c31c677f 100644 --- a/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S110/NRF51822.ld +++ b/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S110/NRF51822.ld @@ -1,5 +1,9 @@ /* Linker script to configure memory regions. */ +#if !defined(MBED_BOOT_STACK_SIZE) + #define MBED_BOOT_STACK_SIZE 0x800 +#endif + MEMORY { FLASH (rx) : ORIGIN = 0x00018000, LENGTH = 0x28000 @@ -130,7 +134,7 @@ SECTIONS end = __end__; __HeapBase = .; *(.heap*) - . = ORIGIN(RAM) + LENGTH(RAM) - Stack_Size; + . = ORIGIN(RAM) + LENGTH(RAM) - MBED_BOOT_STACK_SIZE; __HeapLimit = .; } > RAM @@ -145,7 +149,7 @@ SECTIONS /* 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); + __StackLimit = __StackTop - MBED_BOOT_STACK_SIZE; PROVIDE(__stack = __StackTop); /* Check if data + heap + stack exceeds RAM limit */ diff --git a/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S130/NRF51822.ld b/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S130/NRF51822.ld index e7b9ee53fe..b342ad8db0 100644 --- a/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S130/NRF51822.ld +++ b/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S130/NRF51822.ld @@ -1,5 +1,9 @@ /* Linker script to configure memory regions. */ +#if !defined(MBED_BOOT_STACK_SIZE) + #define MBED_BOOT_STACK_SIZE 0x800 +#endif + MEMORY { FLASH (rx) : ORIGIN = 0x0001C000, LENGTH = 0x24000 @@ -130,7 +134,7 @@ SECTIONS end = __end__; __HeapBase = .; *(.heap*) - . = ORIGIN(RAM) + LENGTH(RAM) - Stack_Size; + . = ORIGIN(RAM) + LENGTH(RAM) - MBED_BOOT_STACK_SIZE; __HeapLimit = .; } > RAM @@ -145,7 +149,7 @@ SECTIONS /* 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); + __StackLimit = __StackTop - MBED_BOOT_STACK_SIZE; PROVIDE(__stack = __StackTop); /* Check if data + heap + stack exceeds RAM limit */ diff --git a/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_GCC_ARM/startup_NRF51822.S b/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_GCC_ARM/startup_NRF51822.S index 7fb929dd26..f9a7f9fb35 100644 --- a/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_GCC_ARM/startup_NRF51822.S +++ b/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_GCC_ARM/startup_NRF51822.S @@ -38,16 +38,9 @@ expected to be copied into the application project folder prior to its use! .section .stack .align 3 -#ifdef __STACK_SIZE - .equ Stack_Size, __STACK_SIZE -#else - .equ Stack_Size, 2048 -#endif - .globl Stack_Size .globl __StackTop .globl __StackLimit __StackLimit: - .space Stack_Size .size __StackLimit, . - __StackLimit __StackTop: .size __StackTop, . - __StackTop diff --git a/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_IAR/TARGET_MCU_NORDIC_16K/nRF51822_QFAA.icf b/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_IAR/TARGET_MCU_NORDIC_16K/nRF51822_QFAA.icf index d71c75cb3f..a269934a6c 100644 --- a/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_IAR/TARGET_MCU_NORDIC_16K/nRF51822_QFAA.icf +++ b/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_IAR/TARGET_MCU_NORDIC_16K/nRF51822_QFAA.icf @@ -3,13 +3,16 @@ /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */ /*-Specials-*/ define symbol __ICFEDIT_intvec_start__ = 0x00016000; +if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) { + define symbol MBED_BOOT_STACK_SIZE = 0x400; +} /*-Memory Regions-*/ define symbol __ICFEDIT_region_ROM_start__ = 0x000160c0; define symbol __ICFEDIT_region_ROM_end__ = 0x0003FFFF; define symbol __ICFEDIT_region_RAM_start__ = 0x20002000; define symbol __ICFEDIT_region_RAM_end__ = 0x20003FFF; /*-Sizes-*/ -define symbol __ICFEDIT_size_cstack__ = 0x400; +define symbol __ICFEDIT_size_cstack__ = MBED_BOOT_STACK_SIZE; define symbol __ICFEDIT_size_heap__ = 0x900; /**** End of ICF editor section. ###ICF###*/ diff --git a/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_IAR/TARGET_MCU_NORDIC_32K/nRF51822_QFAA.icf b/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_IAR/TARGET_MCU_NORDIC_32K/nRF51822_QFAA.icf index e53b889cc8..14274a6f2d 100644 --- a/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_IAR/TARGET_MCU_NORDIC_32K/nRF51822_QFAA.icf +++ b/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/device/TOOLCHAIN_IAR/TARGET_MCU_NORDIC_32K/nRF51822_QFAA.icf @@ -3,14 +3,16 @@ /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */ /*-Specials-*/ define symbol __ICFEDIT_intvec_start__ = 0x00016000; +if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) { + define symbol MBED_BOOT_STACK_SIZE = 0x400; +} /*-Memory Regions-*/ define symbol __ICFEDIT_region_ROM_start__ = 0x000160c0; define symbol __ICFEDIT_region_ROM_end__ = 0x0003FFFF; define symbol __ICFEDIT_region_RAM_start__ = 0x20002000; define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF; /*-Sizes-*/ -/*Heap 1/4 of ram and stack 1/8*/ -define symbol __ICFEDIT_size_cstack__ = 0xc00; +define symbol __ICFEDIT_size_cstack__ = MBED_BOOT_STACK_SIZE; define symbol __ICFEDIT_size_heap__ = 0x1800; /**** End of ICF editor section. ###ICF###*/ diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_ARM_STD/TARGET_MCU_NORDIC_32K/nRF51822.sct b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_ARM_STD/TARGET_MCU_NORDIC_32K/nRF51822.sct index 0d10720cf1..c3ec0e86ff 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_ARM_STD/TARGET_MCU_NORDIC_32K/nRF51822.sct +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_ARM_STD/TARGET_MCU_NORDIC_32K/nRF51822.sct @@ -1,3 +1,5 @@ +#! armcc -E + ;WITHOUT SOFTDEVICE: ;LR_IROM1 0x00000000 0x00040000 { ; ER_IROM1 0x00000000 0x00040000 { @@ -12,6 +14,8 @@ ; ;WITH SOFTDEVICE: +#define Stack_Size MBED_BOOT_STACK_SIZE + LR_IROM1 0x1B000 0x0025000 { ER_IROM1 0x1B000 0x0025000 { *.o (RESET, +First) @@ -24,4 +28,6 @@ LR_IROM1 0x1B000 0x0025000 { RW_IRAM1 0x20002FB8 0x00005048 { .ANY (+RW +ZI) } + ARM_LIB_STACK 0x20002FB8+0x00005048 EMPTY -Stack_Size { ; Stack region growing down + } } diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_ARM_STD/TARGET_MCU_NRF51_16K_S110/nRF51822.sct b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_ARM_STD/TARGET_MCU_NRF51_16K_S110/nRF51822.sct index 7baf111cbe..8da3f804c2 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_ARM_STD/TARGET_MCU_NRF51_16K_S110/nRF51822.sct +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_ARM_STD/TARGET_MCU_NRF51_16K_S110/nRF51822.sct @@ -1,3 +1,5 @@ +#! armcc -E + ;WITHOUT SOFTDEVICE: ;LR_IROM1 0x00000000 0x00040000 { ; ER_IROM1 0x00000000 0x00040000 { @@ -12,6 +14,8 @@ ; ;WITH SOFTDEVICE: +#define Stack_Size MBED_BOOT_STACK_SIZE + LR_IROM1 0x18000 0x0028000 { ER_IROM1 0x18000 0x0028000 { *.o (RESET, +First) @@ -24,4 +28,6 @@ LR_IROM1 0x18000 0x0028000 { RW_IRAM1 0x200020C0 0x00001F40 { .ANY (+RW +ZI) } + ARM_LIB_STACK 0x200020C0+0x00001F40 EMPTY -Stack_Size { ; Stack region growing down + } } diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_ARM_STD/TARGET_MCU_NRF51_16K_S130/nRF51822.sct b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_ARM_STD/TARGET_MCU_NRF51_16K_S130/nRF51822.sct index 96fbdd496b..8311c162a1 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_ARM_STD/TARGET_MCU_NRF51_16K_S130/nRF51822.sct +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_ARM_STD/TARGET_MCU_NRF51_16K_S130/nRF51822.sct @@ -1,3 +1,5 @@ +#! armcc -E + ;WITHOUT SOFTDEVICE: ;LR_IROM1 0x00000000 0x00040000 { ; ER_IROM1 0x00000000 0x00040000 { @@ -12,6 +14,8 @@ ; ;WITH SOFTDEVICE: +#define Stack_Size MBED_BOOT_STACK_SIZE + LR_IROM1 0x0001B000 0x0025000 { ER_IROM1 0x0001B000 0x0025000 { *.o (RESET, +First) @@ -24,4 +28,6 @@ LR_IROM1 0x0001B000 0x0025000 { RW_IRAM1 0x20002FB8 0x00001048 { .ANY (+RW +ZI) } + ARM_LIB_STACK 0x20002FB8+0x00001048 EMPTY -Stack_Size { ; Stack region growing down + } } diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NORDIC_32K/NRF51822.ld b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NORDIC_32K/NRF51822.ld index 9ddce97f40..6d4f2b6f6b 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NORDIC_32K/NRF51822.ld +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NORDIC_32K/NRF51822.ld @@ -1,5 +1,9 @@ /* Linker script to configure memory regions. */ +#if !defined(MBED_BOOT_STACK_SIZE) + #define MBED_BOOT_STACK_SIZE 0x800 +#endif + MEMORY { FLASH (rx) : ORIGIN = 0x0001B000, LENGTH = 0x25000 @@ -144,7 +148,7 @@ SECTIONS end = __end__; __HeapBase = .; *(.heap*) - . = ORIGIN(RAM) + LENGTH(RAM) - Stack_Size; + . = ORIGIN(RAM) + LENGTH(RAM) - MBED_BOOT_STACK_SIZE; __HeapLimit = .; } > RAM @@ -159,7 +163,7 @@ SECTIONS /* 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); + __StackLimit = __StackTop - MBED_BOOT_STACK_SIZE; PROVIDE(__stack = __StackTop); /* Check if data + heap + stack exceeds RAM limit */ diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S110/NRF51822.ld b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S110/NRF51822.ld index f4eaf88e05..98c31c677f 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S110/NRF51822.ld +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S110/NRF51822.ld @@ -1,5 +1,9 @@ /* Linker script to configure memory regions. */ +#if !defined(MBED_BOOT_STACK_SIZE) + #define MBED_BOOT_STACK_SIZE 0x800 +#endif + MEMORY { FLASH (rx) : ORIGIN = 0x00018000, LENGTH = 0x28000 @@ -130,7 +134,7 @@ SECTIONS end = __end__; __HeapBase = .; *(.heap*) - . = ORIGIN(RAM) + LENGTH(RAM) - Stack_Size; + . = ORIGIN(RAM) + LENGTH(RAM) - MBED_BOOT_STACK_SIZE; __HeapLimit = .; } > RAM @@ -145,7 +149,7 @@ SECTIONS /* 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); + __StackLimit = __StackTop - MBED_BOOT_STACK_SIZE; PROVIDE(__stack = __StackTop); /* Check if data + heap + stack exceeds RAM limit */ diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S130/NRF51822.ld b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S130/NRF51822.ld index 1b520bdf01..e6f2352d54 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S130/NRF51822.ld +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S130/NRF51822.ld @@ -1,5 +1,9 @@ /* Linker script to configure memory regions. */ +#if !defined(MBED_BOOT_STACK_SIZE) + #define MBED_BOOT_STACK_SIZE 0x800 +#endif + MEMORY { FLASH (rx) : ORIGIN = 0x0001B000, LENGTH = 0x25000 @@ -142,7 +146,7 @@ SECTIONS end = __end__; __HeapBase = .; *(.heap*) - . = ORIGIN(RAM) + LENGTH(RAM) - Stack_Size; + . = ORIGIN(RAM) + LENGTH(RAM) - MBED_BOOT_STACK_SIZE; __HeapLimit = .; } > RAM @@ -157,7 +161,7 @@ SECTIONS /* 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); + __StackLimit = __StackTop - MBED_BOOT_STACK_SIZE; PROVIDE(__stack = __StackTop); /* Check if data + heap + stack exceeds RAM limit */ diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_GCC_ARM/startup_NRF51822.S b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_GCC_ARM/startup_NRF51822.S index 491e712313..baaec11d4c 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_GCC_ARM/startup_NRF51822.S +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_GCC_ARM/startup_NRF51822.S @@ -47,16 +47,9 @@ expected to be copied into the application project folder prior to its use! .section .stack .align 3 -#ifdef __STACK_SIZE - .equ Stack_Size, __STACK_SIZE -#else - .equ Stack_Size, 2048 -#endif - .globl Stack_Size .globl __StackTop .globl __StackLimit __StackLimit: - .space Stack_Size .size __StackLimit, . - __StackLimit __StackTop: .size __StackTop, . - __StackTop diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_IAR/TARGET_MCU_NORDIC_16K/nRF51822_QFAA.icf b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_IAR/TARGET_MCU_NORDIC_16K/nRF51822_QFAA.icf index 98c6cdea45..4d2fe9d568 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_IAR/TARGET_MCU_NORDIC_16K/nRF51822_QFAA.icf +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_IAR/TARGET_MCU_NORDIC_16K/nRF51822_QFAA.icf @@ -3,6 +3,9 @@ /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */ /*-Specials-*/ define symbol __ICFEDIT_intvec_start__ = 0x0001b000; +if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) { + define symbol MBED_BOOT_STACK_SIZE = 0x400; +} /*-Memory Regions-*/ define symbol __ICFEDIT_region_ROM_start__ = 0x0001b0c0; define symbol __ICFEDIT_region_ROM_end__ = 0x0003FFFF; @@ -11,7 +14,7 @@ define symbol __ICFEDIT_region_RAM_end__ = 0x20003FFF; export symbol __ICFEDIT_region_RAM_start__; export symbol __ICFEDIT_region_RAM_end__; /*-Sizes-*/ -define symbol __ICFEDIT_size_cstack__ = 0x800; +define symbol __ICFEDIT_size_cstack__ = MBED_BOOT_STACK_SIZE; define symbol __ICFEDIT_size_heap__ = 0x900; /**** End of ICF editor section. ###ICF###*/ diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_IAR/TARGET_MCU_NORDIC_32K/nRF51822_QFAA.icf b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_IAR/TARGET_MCU_NORDIC_32K/nRF51822_QFAA.icf index d55af37da7..22bc35e2de 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_IAR/TARGET_MCU_NORDIC_32K/nRF51822_QFAA.icf +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/device/TOOLCHAIN_IAR/TARGET_MCU_NORDIC_32K/nRF51822_QFAA.icf @@ -2,6 +2,9 @@ /*-Editor annotation file-*/ /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */ /*-Specials-*/ +if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) { + define symbol MBED_BOOT_STACK_SIZE = 0x400; +} define symbol __ICFEDIT_intvec_start__ = 0x0001b000; /*-Memory Regions-*/ define symbol __ICFEDIT_region_ROM_start__ = 0x0001b0c0; @@ -11,8 +14,7 @@ define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF; export symbol __ICFEDIT_region_RAM_start__; export symbol __ICFEDIT_region_RAM_end__; /*-Sizes-*/ -/*Heap 1/4 of ram and stack 1/8*/ -define symbol __ICFEDIT_size_cstack__ = 0x800; +define symbol __ICFEDIT_size_cstack__ = MBED_BOOT_STACK_SIZE; define symbol __ICFEDIT_size_heap__ = 0x1800; /**** End of ICF editor section. ###ICF###*/ diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/device/TOOLCHAIN_ARM_STD/nRF52832.sct b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/device/TOOLCHAIN_ARM_STD/nRF52832.sct index 2db7508c19..06d9dbddc2 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/device/TOOLCHAIN_ARM_STD/nRF52832.sct +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/device/TOOLCHAIN_ARM_STD/nRF52832.sct @@ -9,6 +9,8 @@ #define MBED_APP_SIZE 0x80000 #endif +#define Stack_Size MBED_BOOT_STACK_SIZE + /* If softdevice is present, set aside space for it */ #if !defined(MBED_RAM_START) #if defined(SOFTDEVICE_PRESENT) @@ -38,4 +40,6 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { RW_IRAM1 MBED_RAM1_START MBED_RAM1_SIZE { .ANY (+RW +ZI) } + ARM_LIB_STACK MBED_RAM1_START+MBED_RAM1_SIZE EMPTY -Stack_Size { ; Stack region growing down + } } diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/device/TOOLCHAIN_GCC_ARM/NRF52832.ld b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/device/TOOLCHAIN_GCC_ARM/NRF52832.ld index e30c4f2121..c37b11ae44 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/device/TOOLCHAIN_GCC_ARM/NRF52832.ld +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/device/TOOLCHAIN_GCC_ARM/NRF52832.ld @@ -36,6 +36,10 @@ #endif #endif +#if !defined(MBED_BOOT_STACK_SIZE) + #define MBED_BOOT_STACK_SIZE 0x800 +#endif + #define MBED_RAM0_START MBED_RAM_START #define MBED_RAM0_SIZE 0xE0 #define MBED_RAM1_START (MBED_RAM_START + MBED_RAM0_SIZE) @@ -232,8 +236,8 @@ SECTIONS *(.heap*); /* Expand the heap to reach the stack boundary. */ - ASSERT(. <= (ORIGIN(RAM) + LENGTH(RAM) - 0x800), "heap region overflowed into stack"); - . += (ORIGIN(RAM) + LENGTH(RAM) - 0x800) - .; + ASSERT(. <= (ORIGIN(RAM) + LENGTH(RAM) - MBED_BOOT_STACK_SIZE), "heap region overflowed into stack"); + . = ORIGIN(RAM) + LENGTH(RAM) - MBED_BOOT_STACK_SIZE; } > RAM PROVIDE(__heap_start = ADDR(.heap)); PROVIDE(__heap_size = SIZEOF(.heap)); @@ -247,12 +251,12 @@ SECTIONS { __StackLimit = .; *(.stack*) - . += (ORIGIN(RAM) + LENGTH(RAM) - .); + . = ORIGIN(RAM) + LENGTH(RAM); } > RAM /* Set the stack top to the end of RAM and move down the stack limit by * the size of the stack_dummy section. */ __StackTop = ORIGIN(RAM) + LENGTH(RAM); - __StackLimit = __StackTop - SIZEOF(.stack); + __StackLimit = __StackTop - MBED_BOOT_STACK_SIZE; PROVIDE(__stack = __StackTop); } diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/device/TOOLCHAIN_IAR/nRF52832.icf b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/device/TOOLCHAIN_IAR/nRF52832.icf index 714b59a9e8..f116c49455 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/device/TOOLCHAIN_IAR/nRF52832.icf +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/device/TOOLCHAIN_IAR/nRF52832.icf @@ -22,6 +22,10 @@ if (!isdefinedsymbol(MBED_RAM_START)) { } } +if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) { + define symbol MBED_BOOT_STACK_SIZE = 0x400; +} + define symbol MBED_RAM0_START = MBED_RAM_START; define symbol MBED_RAM0_SIZE = 0xE0; /* 8-byte aligned(0xDC) = 0xE0 */ define symbol MBED_RAM1_START = (MBED_RAM_START + MBED_RAM0_SIZE); @@ -41,8 +45,7 @@ export symbol __ICFEDIT_region_RAM_start__; export symbol __ICFEDIT_region_RAM_end__; /*-Sizes-*/ -/*Heap 1/4 of ram and stack 1/8*/ -define symbol __ICFEDIT_size_cstack__ = 0x800; +define symbol __ICFEDIT_size_cstack__ = MBED_BOOT_STACK_SIZE; define symbol __ICFEDIT_size_heap__ = 0x5800; /**** End of ICF editor section. ###ICF###*/ diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/device/TOOLCHAIN_ARM_STD/nRF52840.sct b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/device/TOOLCHAIN_ARM_STD/nRF52840.sct index 57626d9714..d510188439 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/device/TOOLCHAIN_ARM_STD/nRF52840.sct +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/device/TOOLCHAIN_ARM_STD/nRF52840.sct @@ -20,6 +20,8 @@ #endif #endif +#define Stack_Size MBED_BOOT_STACK_SIZE + #define MBED_RAM0_START MBED_RAM_START #define MBED_RAM0_SIZE 0x100 @@ -43,4 +45,6 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { RW_IRAM1 MBED_RAM1_START MBED_RAM1_SIZE { .ANY (+RW +ZI) } + ARM_LIB_STACK MBED_RAM1_START+MBED_RAM1_SIZE EMPTY -Stack_Size { ; Stack region growing down + } } diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/device/TOOLCHAIN_GCC_ARM/NRF52840.ld b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/device/TOOLCHAIN_GCC_ARM/NRF52840.ld index 7cb1621ac6..eb739c16f2 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/device/TOOLCHAIN_GCC_ARM/NRF52840.ld +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/device/TOOLCHAIN_GCC_ARM/NRF52840.ld @@ -25,6 +25,10 @@ #define MBED_APP_SIZE 0x100000 #endif +#if !defined(MBED_BOOT_STACK_SIZE) + #define MBED_BOOT_STACK_SIZE 0x800 +#endif + /* If softdevice is present, set aside space for it */ #if !defined(MBED_RAM_START) #if defined(SOFTDEVICE_PRESENT) @@ -248,8 +252,8 @@ SECTIONS *(.heap*); /* Expand the heap to reach the stack boundary. */ - ASSERT(. <= (ORIGIN(RAM) + LENGTH(RAM) - 0x800), "heap region overflowed into stack"); - . += (ORIGIN(RAM) + LENGTH(RAM) - 0x800) - .; + ASSERT(. <= (ORIGIN(RAM) + LENGTH(RAM) - MBED_BOOT_STACK_SIZE), "heap region overflowed into stack"); + . = ORIGIN(RAM) + LENGTH(RAM) - MBED_BOOT_STACK_SIZE; } > RAM PROVIDE(__heap_start = ADDR(.heap)); PROVIDE(__heap_size = SIZEOF(.heap)); @@ -263,12 +267,12 @@ SECTIONS { __StackLimit = .; *(.stack*) - . += (ORIGIN(RAM) + LENGTH(RAM) - .); + . = ORIGIN(RAM) + LENGTH(RAM); } > RAM /* Set the stack top to the end of RAM and move down the stack limit by * the size of the stack_dummy section. */ __StackTop = ORIGIN(RAM) + LENGTH(RAM); - __StackLimit = __StackTop - SIZEOF(.stack); + __StackLimit = __StackTop - MBED_BOOT_STACK_SIZE; PROVIDE(__stack = __StackTop); } diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/device/TOOLCHAIN_IAR/nRF52840.icf b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/device/TOOLCHAIN_IAR/nRF52840.icf index 9396c998b0..8402657f30 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/device/TOOLCHAIN_IAR/nRF52840.icf +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/device/TOOLCHAIN_IAR/nRF52840.icf @@ -22,6 +22,10 @@ if (!isdefinedsymbol(MBED_RAM_START)) { } } +if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) { + define symbol MBED_BOOT_STACK_SIZE = 0x400; +} + define symbol MBED_RAM0_START = MBED_RAM_START; define symbol MBED_RAM0_SIZE = 0x100; define symbol MBED_CRASH_REPORT_RAM_START = (MBED_RAM_START + MBED_RAM0_SIZE); @@ -45,8 +49,7 @@ export symbol __ICFEDIT_region_RAM_start__; export symbol __ICFEDIT_region_RAM_end__; /*-Sizes-*/ -/*Heap 1/4 of ram and stack 1/8*/ -define symbol __ICFEDIT_size_cstack__ = 0x800; +define symbol __ICFEDIT_size_cstack__ = MBED_BOOT_STACK_SIZE; define symbol __ICFEDIT_size_heap__ = 0x17800; /**** End of ICF editor section. ###ICF###*/