From 4d9c4343a0569b9bbe4fc5a56364de2aaabdd3d8 Mon Sep 17 00:00:00 2001 From: c_jin Date: Fri, 11 Jan 2019 18:04:56 +0800 Subject: [PATCH] Support boot stack size configuration option --- .../device/TOOLCHAIN_ARM_STD/gd32e103vb.sct | 11 ++++++++++- .../device/TOOLCHAIN_GCC_ARM/GD32E103xB.ld | 7 ++++++- .../device/TOOLCHAIN_IAR/gd32e103vb.icf | 3 ++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/targets/TARGET_GigaDevice/TARGET_GD32E10X/device/TOOLCHAIN_ARM_STD/gd32e103vb.sct b/targets/TARGET_GigaDevice/TARGET_GD32E10X/device/TOOLCHAIN_ARM_STD/gd32e103vb.sct index 44243e7961..e65ee253f7 100644 --- a/targets/TARGET_GigaDevice/TARGET_GD32E10X/device/TOOLCHAIN_ARM_STD/gd32e103vb.sct +++ b/targets/TARGET_GigaDevice/TARGET_GD32E10X/device/TOOLCHAIN_ARM_STD/gd32e103vb.sct @@ -11,6 +11,12 @@ #define MBED_APP_SIZE 0x20000 #endif +#if !defined(MBED_BOOT_STACK_SIZE) + #define MBED_BOOT_STACK_SIZE 0x400 +#endif + +#define Stack_Size MBED_BOOT_STACK_SIZE + LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region (1024K) ER_IROM1 MBED_APP_START MBED_APP_SIZE { ; load address = execution address @@ -20,8 +26,11 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region (1024K) } ; 84 vectors (16 core + 68 peripheral) * 4 bytes = 336 bytes to reserve (0x150) - RW_IRAM1 (0x20000000+0x150) (0x8000-0x150) { ; RW data + RW_IRAM1 (0x20000000+0x150) (0x8000-0x150-Stack_Size) { ; RW data .ANY (+RW +ZI) } + + ARM_LIB_STACK 0x20000000+0x8000 EMPTY -Stack_Size { ; Stack region growing down + } } diff --git a/targets/TARGET_GigaDevice/TARGET_GD32E10X/device/TOOLCHAIN_GCC_ARM/GD32E103xB.ld b/targets/TARGET_GigaDevice/TARGET_GD32E10X/device/TOOLCHAIN_GCC_ARM/GD32E103xB.ld index 94ad329c38..6a01b089bd 100644 --- a/targets/TARGET_GigaDevice/TARGET_GD32E10X/device/TOOLCHAIN_GCC_ARM/GD32E103xB.ld +++ b/targets/TARGET_GigaDevice/TARGET_GD32E10X/device/TOOLCHAIN_GCC_ARM/GD32E103xB.ld @@ -6,6 +6,10 @@ #define MBED_APP_SIZE 128K #endif +#if !defined(MBED_BOOT_STACK_SIZE) + #define MBED_BOOT_STACK_SIZE 0x400 +#endif + /* specify memory regions */ MEMORY { @@ -112,6 +116,7 @@ SECTIONS __end__ = .; end = __end__; *(.heap*) + . = ORIGIN(RAM) + LENGTH(RAM) - MBED_BOOT_STACK_SIZE; __HeapLimit = .; } > RAM @@ -123,7 +128,7 @@ SECTIONS /* initializes stack on the end of block */ __StackTop = ORIGIN(RAM) + LENGTH(RAM); _estack = __StackTop; - __StackLimit = __StackTop - SIZEOF(.stack_dummy); + __StackLimit = __StackTop - MBED_BOOT_STACK_SIZE; PROVIDE(__stack = __StackTop); ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") diff --git a/targets/TARGET_GigaDevice/TARGET_GD32E10X/device/TOOLCHAIN_IAR/gd32e103vb.icf b/targets/TARGET_GigaDevice/TARGET_GD32E10X/device/TOOLCHAIN_IAR/gd32e103vb.icf index df6d14445a..b92876d0e1 100644 --- a/targets/TARGET_GigaDevice/TARGET_GD32E10X/device/TOOLCHAIN_IAR/gd32e103vb.icf +++ b/targets/TARGET_GigaDevice/TARGET_GD32E10X/device/TOOLCHAIN_IAR/gd32e103vb.icf @@ -4,6 +4,7 @@ if (!isdefinedsymbol(MBED_APP_START)) { define symbol MBED_APP_START = 0x08000000; } if (!isdefinedsymbol(MBED_APP_SIZE)) { define symbol MBED_APP_SIZE = 0x20000; } +if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) { define symbol MBED_BOOT_STACK_SIZE = 0x400; } /*-Specials-*/ define symbol __ICFEDIT_intvec_start__ = MBED_APP_START; /*-Memory Regions-*/ @@ -15,7 +16,7 @@ define symbol __ICFEDIT_region_RAM_start__ = 0x20000150; define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF; /*-Sizes-*/ /*Heap 1/4 of ram and stack 1/8*/ -define symbol __ICFEDIT_size_cstack__ = 0x1000; +define symbol __ICFEDIT_size_cstack__ = MBED_BOOT_STACK_SIZE; define symbol __ICFEDIT_size_heap__ = 0x2000; /**** End of ICF editor section. ###ICF###*/