From 382f7334fb87c7430a0810ce65ac79747913ad82 Mon Sep 17 00:00:00 2001 From: Jonathan Austin Date: Thu, 16 Jul 2015 15:59:54 +0300 Subject: [PATCH] Nordic: added the s110 scatter files This commit adds the ability for a compile flag to be set from targets.py which changes the soft device to s110. The compile flag is: MCU_NRF51_16K_S110. In order to avoid duplication of the startup file, for the 16K parts we introduce an S110 or S130 scatter file. This means all 16K platforms must define MCU_NRF51_16K and ONE of MCU_NRF51_16K_S110 or MCU_NRF51_16K_S130 Based on an earlier commit by Mihail but modified to avoid copy/paste of the startup code for S110/S130 Signed-off-by: Jonathan Austin --- .../TARGET_MCU_NRF51_16K_S110/nRF51822.sct | 24 +++ .../nRF51822.sct | 0 .../TARGET_MCU_NRF51_16K_S110/NRF51822.ld | 151 ++++++++++++++++++ .../NRF51822.ld | 0 workspace_tools/targets.py | 69 ++++++-- 5 files changed, 233 insertions(+), 11 deletions(-) create mode 100644 libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_ARM_STD/TARGET_MCU_NRF51_16K_S110/nRF51822.sct rename libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_ARM_STD/{TARGET_MCU_NORDIC_16K => TARGET_MCU_NRF51_16K_S130}/nRF51822.sct (100%) create mode 100644 libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S110/NRF51822.ld rename libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/{TARGET_MCU_NORDIC_16K => TARGET_MCU_NRF51_16K_S130}/NRF51822.ld (100%) diff --git a/libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_ARM_STD/TARGET_MCU_NRF51_16K_S110/nRF51822.sct b/libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_ARM_STD/TARGET_MCU_NRF51_16K_S110/nRF51822.sct new file mode 100644 index 0000000000..62638400f2 --- /dev/null +++ b/libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_ARM_STD/TARGET_MCU_NRF51_16K_S110/nRF51822.sct @@ -0,0 +1,24 @@ +;WITHOUT SOFTDEVICE: +;LR_IROM1 0x00000000 0x00040000 { +; ER_IROM1 0x00000000 0x00040000 { +; *.o (RESET, +First) +; *(InRoot$$Sections) +; .ANY (+RO) +; } +; RW_IRAM1 0x20000000 0x00004000 { +; .ANY (+RW +ZI) +; } +;} +; +;WITH SOFTDEVICE: + +LR_IROM1 0x18000 0x0028000 { + ER_IROM1 0x18000 0x0028000 { + *.o (RESET, +First) + *(InRoot$$Sections) + .ANY (+RO) + } + RW_IRAM1 0x20002000 0x00002000 { + .ANY (+RW +ZI) + } +} diff --git a/libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_ARM_STD/TARGET_MCU_NORDIC_16K/nRF51822.sct b/libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_ARM_STD/TARGET_MCU_NRF51_16K_S130/nRF51822.sct similarity index 100% rename from libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_ARM_STD/TARGET_MCU_NORDIC_16K/nRF51822.sct rename to libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_ARM_STD/TARGET_MCU_NRF51_16K_S130/nRF51822.sct diff --git a/libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S110/NRF51822.ld b/libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S110/NRF51822.ld new file mode 100644 index 0000000000..43e0ac80da --- /dev/null +++ b/libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S110/NRF51822.ld @@ -0,0 +1,151 @@ +/* Linker script to configure memory regions. */ + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00016000, LENGTH = 0x2A000 + RAM (rwx) : ORIGIN = 0x20002000, LENGTH = 0x2000 +} + +OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + KEEP(*(.Vectors)) + *(.text*) + + KEEP(*(.init)) + KEEP(*(.fini)) + + /* .ctors */ + *crtbegin.o(.ctors) + *crtbegin?.o(.ctors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) + *(SORT(.ctors.*)) + *(.ctors) + + /* .dtors */ + *crtbegin.o(.dtors) + *crtbegin?.o(.dtors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) + *(SORT(.dtors.*)) + *(.dtors) + + *(.rodata*) + + KEEP(*(.eh_frame*)) + } > FLASH + + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = ALIGN(4); + /* preinit data */ + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP(*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + + . = ALIGN(4); + /* init data */ + PROVIDE_HIDDEN (__init_array_start = .); + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + + + . = ALIGN(4); + /* finit data */ + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP(*(SORT(.fini_array.*))) + KEEP(*(.fini_array)) + PROVIDE_HIDDEN (__fini_array_end = .); + + *(.jcr) + . = ALIGN(4); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + end = __end__; + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .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 (COPY): + { + *(.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(__stack = __StackTop); + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/TARGET_MCU_NORDIC_16K/NRF51822.ld b/libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S130/NRF51822.ld similarity index 100% rename from libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/TARGET_MCU_NORDIC_16K/NRF51822.ld rename to libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S130/NRF51822.ld diff --git a/workspace_tools/targets.py b/workspace_tools/targets.py index 78d4b1670f..08266b75be 100755 --- a/workspace_tools/targets.py +++ b/workspace_tools/targets.py @@ -1017,30 +1017,77 @@ class MCU_NRF51(Target): binh.tofile(f, format='hex') +# 16KB Nordic targets are tight on SRAM using S130 (default) so we +# introduce two possible options: +# 1) Use S130 (default) - for this derive from MCU_NRF51_16K +# 2) Use S110 - for this derive from MCU_NRF51_16K_S110 +# Note that the 'default' option will track the default choice +# for other Nordic targets, and so can take advantage of other +# future SoftDevice improvements + +# The *_BASE targets should *not* be inherited from, as they do not +# specify enough for building a target + # 16KB MCU version, e.g. Nordic nRF51822, Seeed Arch BLE, etc. -class MCU_NRF51_16K(MCU_NRF51): +class MCU_NRF51_16K_BASE(MCU_NRF51): def __init__(self): MCU_NRF51.__init__(self) self.extra_labels += ['MCU_NORDIC_16K', 'MCU_NRF51_16K'] self.macros += ['TARGET_MCU_NORDIC_16K', 'TARGET_MCU_NRF51_16K'] # derivative class used to create softdevice+bootloader enabled images -class MCU_NRF51_16K_BOOT(MCU_NRF51_16K): +class MCU_NRF51_16K_BOOT_BASE(MCU_NRF51_16K_BASE): def __init__(self): - MCU_NRF51_16K.__init__(self) + MCU_NRF51_16K_BASE.__init__(self) self.extra_labels += ['MCU_NRF51_16K_BOOT'] self.macros += ['TARGET_MCU_NRF51_16K_BOOT', 'TARGET_OTA_ENABLED'] self.MERGE_SOFT_DEVICE = True self.MERGE_BOOTLOADER = True # derivative class used to create program only images for use with FOTA -class MCU_NRF51_16K_OTA(MCU_NRF51_16K): +class MCU_NRF51_16K_OTA_BASE(MCU_NRF51_16K_BASE): def __init__(self): - MCU_NRF51_16K.__init__(self) + MCU_NRF51_16K_BASE.__init__(self) self.extra_labels += ['MCU_NRF51_16K_OTA'] self.macros += ['TARGET_MCU_NRF51_16K_OTA', 'TARGET_OTA_ENABLED'] self.MERGE_SOFT_DEVICE = False +class MCU_NRF51_16K(MCU_NRF51_16K_BASE): + def __init__(self): + MCU_NRF51_16K_BASE.__init__(self) + self.extra_labels += ['MCU_NRF51_16K_S130'] + self.macros += ['TARGET_MCU_NRF51_16K_S130'] + +class MCU_NRF51_16K_S110(MCU_NRF51_16K_BASE): + def __init__(self): + MCU_NRF51_16K_BASE.__init__(self) + self.extra_labels += ['MCU_NRF51_16K_S110'] + self.macros += ['TARGET_MCU_NRF51_16K_S110'] + +class MCU_NRF51_16K_BOOT(MCU_NRF51_16K_BOOT_BASE): + def __init__(self): + MCU_NRF51_16K_BOOT_BASE.__init__(self) + self.extra_labels += ['MCU_NRF51_16K_S130'] + self.macros += ['TARGET_MCU_NRF51_16K_S130'] + +class MCU_NRF51_16K_BOOT_S110(MCU_NRF51_16K_BOOT_BASE): + def __init__(self): + MCU_NRF51_16K_BOOT_BASE.__init__(self) + self.extra_labels += ['MCU_NRF51_16K_S110'] + self.macros += ['TARGET_MCU_NRF51_16K_S110'] + +class MCU_NRF51_16K_OTA(MCU_NRF51_16K_OTA_BASE): + def __init__(self): + MCU_NRF51_16K_OTA_BASE.__init__(self) + self.extra_labels += ['MCU_NRF51_16K_S130'] + self.macros += ['TARGET_MCU_NRF51_16K_S130'] + +class MCU_NRF51_16K_OTA_S110(MCU_NRF51_16K_OTA_BASE): + def __init__(self): + MCU_NRF51_16K_OTA_BASE.__init__(self) + self.extra_labels += ['MCU_NRF51_16K_S110'] + self.macros += ['TARGET_MCU_NRF51_16K_S110'] + # 32KB MCU version, e.g. Nordic nRF51-DK, nRF51-Dongle, etc. class MCU_NRF51_32K(MCU_NRF51): @@ -1247,9 +1294,9 @@ class NRF51_DONGLE_OTA(MCU_NRF51_32K_OTA): self.extra_labels = ['NRF51_DONGLE'] self.macros += ['TARGET_NRF51_DONGLE'] -class NRF51_MICROBIT(MCU_NRF51_16K): +class NRF51_MICROBIT(MCU_NRF51_16K_S110): def __init__(self): - MCU_NRF51_16K.__init__(self) + MCU_NRF51_16K_S110.__init__(self) self.EXPECTED_SOFTDEVICES_WITH_OFFSETS = [ { 'name' : 's110_nrf51822_8.0.0_softdevice.hex', @@ -1264,15 +1311,15 @@ class NRF51_MICROBIT(MCU_NRF51_16K): ] self.macros += ['TARGET_NRF_LFCLK_RC'] -class NRF51_MICROBIT_BOOT(MCU_NRF51_16K_BOOT): +class NRF51_MICROBIT_BOOT(MCU_NRF51_16K_BOOT_S110): def __init__(self): - MCU_NRF51_16K_BOOT.__init__(self) + MCU_NRF51_16K_BOOT_S110.__init__(self) self.extra_labels += ['NRF51_MICROBIT'] self.macros += ['TARGET_NRF51_MICROBIT', 'TARGET_NRF_LFCLK_RC'] -class NRF51_MICROBIT_OTA(MCU_NRF51_16K_OTA): +class NRF51_MICROBIT_OTA(MCU_NRF51_16K_OTA_S110): def __init__(self): - MCU_NRF51_16K_OTA.__init__(self) + MCU_NRF51_16K_OTA_S110.__init__(self) self.extra_labels += ['NRF51_MICROBIT'] self.macros += ['TARGET_NRF51_MICROBIT', 'TARGET_NRF_LFCLK_RC']