diff --git a/CMakeLists.txt b/CMakeLists.txt index 44ff276f1dc..7412aca00fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -132,7 +132,7 @@ if("MBED_CONF_TARGET_APPLICATION_PROFILE=full" IN_LIST MBED_CONFIG_DEFINITIONS O elseif("MBED_CONF_TARGET_APPLICATION_PROFILE=bare-metal" IN_LIST MBED_CONFIG_DEFINITIONS) set(APPLICATION_PROFILE_CONFIG_BAREMETAL TRUE) else() - message(FATAL_ERROR "target.application-profile must be set to either 'full' or 'bare-metal'!") + message(FATAL_ERROR "target.application-profile must be set to either 'full' or 'bare-metal'! If you are getting this after upgrading mbed-os then you likely need to clear your CMake cache.") endif() # mbed-core-flags/mbed-core-sources link mbed-rtos-flags/mbed-rtos-sources or not depending on diff --git a/targets/TARGET_STM/TARGET_STM32L4/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32L4/CMakeLists.txt index 2c1d74be056..3c1302f3bbd 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32L4/CMakeLists.txt @@ -16,6 +16,7 @@ add_subdirectory(TARGET_STM32L4R5xI EXCLUDE_FROM_ALL) add_subdirectory(TARGET_STM32L4R9xI EXCLUDE_FROM_ALL) add_subdirectory(TARGET_STM32L4S5xI EXCLUDE_FROM_ALL) add_subdirectory(STM32Cube_FW EXCLUDE_FROM_ALL) +add_subdirectory(linker_scripts) add_library(mbed-stm32l4 INTERFACE) diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L432xC/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L432xC/CMakeLists.txt index b9914a884b8..6b16c5a1659 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L432xC/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L432xC/CMakeLists.txt @@ -5,10 +5,8 @@ add_subdirectory(TARGET_NUCLEO_L432KC EXCLUDE_FROM_ALL) if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") set(STARTUP_FILE TOOLCHAIN_GCC_ARM/startup_stm32l432xx.S) - set(LINKER_FILE TOOLCHAIN_GCC_ARM/stm32l432xc.ld) elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") set(STARTUP_FILE TOOLCHAIN_ARM/startup_stm32l432xx.S) - set(LINKER_FILE TOOLCHAIN_ARM/stm32l432xc.sct) endif() add_library(mbed-stm32l432xc INTERFACE) @@ -23,5 +21,5 @@ target_include_directories(mbed-stm32l432xc INTERFACE . ) -mbed_set_linker_script(mbed-stm32l432xc ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) + target_link_libraries(mbed-stm32l432xc INTERFACE mbed-stm32l4) diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L432xC/TOOLCHAIN_GCC_ARM/stm32l432xc.ld b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L432xC/TOOLCHAIN_GCC_ARM/stm32l432xc.ld deleted file mode 100644 index 3a07ff3bdd7..00000000000 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L432xC/TOOLCHAIN_GCC_ARM/stm32l432xc.ld +++ /dev/null @@ -1,203 +0,0 @@ -/* Linker script to configure memory regions. */ -/* - * SPDX-License-Identifier: BSD-3-Clause - ****************************************************************************** - * @attention - * - * Copyright (c) 2016-2020 STMicroelectronics. - * All rights reserved. - * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** -*/ - -#include "../cmsis_nvic.h" - - -#if !defined(MBED_APP_START) - #define MBED_APP_START MBED_ROM_START -#endif - -#if !defined(MBED_APP_SIZE) - #define MBED_APP_SIZE MBED_ROM_SIZE -#endif - -#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE) - /* This value is normally defined by the tools - to 0x1000 for bare metal and 0x400 for RTOS */ - #define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400 -#endif - -/* Round up VECTORS_SIZE to 8 bytes */ -#define VECTORS_SIZE (((NVIC_NUM_VECTORS * 4) + 7) & 0xFFFFFFF8) - -MEMORY -{ - FLASH (rx) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE - RAM (rwx) : ORIGIN = MBED_RAM_START + VECTORS_SIZE, LENGTH = MBED_RAM_SIZE + MBED_RAM1_SIZE - VECTORS_SIZE -} - -/* 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 - * _estack - */ -ENTRY(Reset_Handler) - -SECTIONS -{ - .text : - { - KEEP(*(.isr_vector)) - *(.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 = .; - _sidata = .; - - .data : AT (__etext) - { - __data_start__ = .; - _sdata = .; - *(vtable) - *(.data*) - - . = ALIGN(8); - /* preinit data */ - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP(*(.preinit_array)) - PROVIDE_HIDDEN (__preinit_array_end = .); - - . = ALIGN(8); - /* init data */ - PROVIDE_HIDDEN (__init_array_start = .); - KEEP(*(SORT(.init_array.*))) - KEEP(*(.init_array)) - PROVIDE_HIDDEN (__init_array_end = .); - - . = ALIGN(8); - /* finit data */ - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP(*(SORT(.fini_array.*))) - KEEP(*(.fini_array)) - PROVIDE_HIDDEN (__fini_array_end = .); - - KEEP(*(.jcr*)) - . = ALIGN(8); - /* All data end */ - __data_end__ = .; - _edata = .; - - } > RAM - - /* Uninitialized data section - * This region is not initialized by the C/C++ library and can be used to - * store state across soft reboots. */ - .uninitialized (NOLOAD): - { - . = ALIGN(32); - __uninitialized_start = .; - *(.uninitialized) - KEEP(*(.keep.uninitialized)) - . = ALIGN(32); - __uninitialized_end = .; - } > RAM - - .bss : - { - . = ALIGN(8); - __bss_start__ = .; - _sbss = .; - *(.bss*) - *(COMMON) - . = ALIGN(8); - __bss_end__ = .; - _ebss = .; - } > RAM - - .heap (COPY): - { - __end__ = .; - PROVIDE(end = .); - *(.heap*) - . = ORIGIN(RAM) + LENGTH(RAM) - MBED_CONF_TARGET_BOOT_STACK_SIZE; - __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); - _estack = __StackTop; - __StackLimit = __StackTop - MBED_CONF_TARGET_BOOT_STACK_SIZE; - PROVIDE(__stack = __StackTop); - - /* Check if data + heap + stack exceeds RAM limit */ - ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") -} diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L432xC/cmsis_nvic.h b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L432xC/cmsis_nvic.h index b2290b8738f..ec1835224a6 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L432xC/cmsis_nvic.h +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L432xC/cmsis_nvic.h @@ -17,31 +17,7 @@ #ifndef MBED_CMSIS_NVIC_H #define MBED_CMSIS_NVIC_H -#if !defined(MBED_ROM_START) -#define MBED_ROM_START 0x8000000 -#endif - -#if !defined(MBED_ROM_SIZE) -#define MBED_ROM_SIZE 0x40000 // 256 KB -#endif - -#if !defined(MBED_RAM_START) -#define MBED_RAM_START 0x20000000 -#endif - -#if !defined(MBED_RAM_SIZE) -#define MBED_RAM_SIZE 0xc000 // 48 KB -#endif - -#if !defined(MBED_RAM1_START) -#define MBED_RAM1_START 0x10000000 -#endif - -#if !defined(MBED_RAM1_SIZE) -#define MBED_RAM1_SIZE 0x4000 // 16 KB -#endif - #define NVIC_NUM_VECTORS 99 -#define NVIC_RAM_VECTOR_ADDRESS MBED_RAM_START +#define NVIC_RAM_VECTOR_ADDRESS MBED_RAM_BANK_IRAM2_START #endif diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L433xC/TOOLCHAIN_GCC_ARM/stm32l433xc.ld b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L433xC/TOOLCHAIN_GCC_ARM/stm32l433xc.ld deleted file mode 100644 index 3a07ff3bdd7..00000000000 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L433xC/TOOLCHAIN_GCC_ARM/stm32l433xc.ld +++ /dev/null @@ -1,203 +0,0 @@ -/* Linker script to configure memory regions. */ -/* - * SPDX-License-Identifier: BSD-3-Clause - ****************************************************************************** - * @attention - * - * Copyright (c) 2016-2020 STMicroelectronics. - * All rights reserved. - * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** -*/ - -#include "../cmsis_nvic.h" - - -#if !defined(MBED_APP_START) - #define MBED_APP_START MBED_ROM_START -#endif - -#if !defined(MBED_APP_SIZE) - #define MBED_APP_SIZE MBED_ROM_SIZE -#endif - -#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE) - /* This value is normally defined by the tools - to 0x1000 for bare metal and 0x400 for RTOS */ - #define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400 -#endif - -/* Round up VECTORS_SIZE to 8 bytes */ -#define VECTORS_SIZE (((NVIC_NUM_VECTORS * 4) + 7) & 0xFFFFFFF8) - -MEMORY -{ - FLASH (rx) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE - RAM (rwx) : ORIGIN = MBED_RAM_START + VECTORS_SIZE, LENGTH = MBED_RAM_SIZE + MBED_RAM1_SIZE - VECTORS_SIZE -} - -/* 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 - * _estack - */ -ENTRY(Reset_Handler) - -SECTIONS -{ - .text : - { - KEEP(*(.isr_vector)) - *(.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 = .; - _sidata = .; - - .data : AT (__etext) - { - __data_start__ = .; - _sdata = .; - *(vtable) - *(.data*) - - . = ALIGN(8); - /* preinit data */ - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP(*(.preinit_array)) - PROVIDE_HIDDEN (__preinit_array_end = .); - - . = ALIGN(8); - /* init data */ - PROVIDE_HIDDEN (__init_array_start = .); - KEEP(*(SORT(.init_array.*))) - KEEP(*(.init_array)) - PROVIDE_HIDDEN (__init_array_end = .); - - . = ALIGN(8); - /* finit data */ - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP(*(SORT(.fini_array.*))) - KEEP(*(.fini_array)) - PROVIDE_HIDDEN (__fini_array_end = .); - - KEEP(*(.jcr*)) - . = ALIGN(8); - /* All data end */ - __data_end__ = .; - _edata = .; - - } > RAM - - /* Uninitialized data section - * This region is not initialized by the C/C++ library and can be used to - * store state across soft reboots. */ - .uninitialized (NOLOAD): - { - . = ALIGN(32); - __uninitialized_start = .; - *(.uninitialized) - KEEP(*(.keep.uninitialized)) - . = ALIGN(32); - __uninitialized_end = .; - } > RAM - - .bss : - { - . = ALIGN(8); - __bss_start__ = .; - _sbss = .; - *(.bss*) - *(COMMON) - . = ALIGN(8); - __bss_end__ = .; - _ebss = .; - } > RAM - - .heap (COPY): - { - __end__ = .; - PROVIDE(end = .); - *(.heap*) - . = ORIGIN(RAM) + LENGTH(RAM) - MBED_CONF_TARGET_BOOT_STACK_SIZE; - __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); - _estack = __StackTop; - __StackLimit = __StackTop - MBED_CONF_TARGET_BOOT_STACK_SIZE; - PROVIDE(__stack = __StackTop); - - /* Check if data + heap + stack exceeds RAM limit */ - ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") -} diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L433xC/cmsis_nvic.h b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L433xC/cmsis_nvic.h index b2290b8738f..ec1835224a6 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L433xC/cmsis_nvic.h +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L433xC/cmsis_nvic.h @@ -17,31 +17,7 @@ #ifndef MBED_CMSIS_NVIC_H #define MBED_CMSIS_NVIC_H -#if !defined(MBED_ROM_START) -#define MBED_ROM_START 0x8000000 -#endif - -#if !defined(MBED_ROM_SIZE) -#define MBED_ROM_SIZE 0x40000 // 256 KB -#endif - -#if !defined(MBED_RAM_START) -#define MBED_RAM_START 0x20000000 -#endif - -#if !defined(MBED_RAM_SIZE) -#define MBED_RAM_SIZE 0xc000 // 48 KB -#endif - -#if !defined(MBED_RAM1_START) -#define MBED_RAM1_START 0x10000000 -#endif - -#if !defined(MBED_RAM1_SIZE) -#define MBED_RAM1_SIZE 0x4000 // 16 KB -#endif - #define NVIC_NUM_VECTORS 99 -#define NVIC_RAM_VECTOR_ADDRESS MBED_RAM_START +#define NVIC_RAM_VECTOR_ADDRESS MBED_RAM_BANK_IRAM2_START #endif diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L443xC/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L443xC/CMakeLists.txt index 431c8fb54ca..901f3e4c1e8 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L443xC/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L443xC/CMakeLists.txt @@ -5,10 +5,8 @@ add_subdirectory(TARGET_ADV_WISE_1510 EXCLUDE_FROM_ALL) if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") set(STARTUP_FILE TOOLCHAIN_GCC_ARM/startup_stm32l443xx.S) - set(LINKER_FILE TOOLCHAIN_GCC_ARM/stm32l443xc.ld) elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") set(STARTUP_FILE TOOLCHAIN_ARM/startup_stm32l443xx.S) - set(LINKER_FILE TOOLCHAIN_ARM/stm32l443xc.sct) endif() @@ -25,6 +23,4 @@ target_include_directories(mbed-stm32l443xc . ) -mbed_set_linker_script(mbed-stm32l443xc ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) - target_link_libraries(mbed-stm32l443xc INTERFACE mbed-stm32l4) diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L443xC/TOOLCHAIN_GCC_ARM/stm32l443xc.ld b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L443xC/TOOLCHAIN_GCC_ARM/stm32l443xc.ld deleted file mode 100644 index d4fe72574bf..00000000000 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L443xC/TOOLCHAIN_GCC_ARM/stm32l443xc.ld +++ /dev/null @@ -1,193 +0,0 @@ -#if !defined(MBED_APP_START) - #define MBED_APP_START 0x08000000 -#endif - -#if !defined(MBED_APP_SIZE) - #define MBED_APP_SIZE 256k -#endif - -#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE) - #define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400 -#endif - -STACK_SIZE = MBED_CONF_TARGET_BOOT_STACK_SIZE; - -/* Linker script to configure memory regions. */ -/* 0x18C resevered for vectors; 8-byte aligned = 0x190 (0x18C + 0x4)*/ -MEMORY -{ - FLASH (rx) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE - SRAM2 (rwx) : ORIGIN = 0x10000190, LENGTH = 16k - (0x18C+0x4) - SRAM1 (rwx) : ORIGIN = 0x20000000, LENGTH = 48k -} - -/* 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 - * _estack - */ -ENTRY(Reset_Handler) - -SECTIONS -{ - .text : - { - KEEP(*(.isr_vector)) - *(.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 = .; - _sidata = .; - - /* .stack section doesn't contains any symbols. It is only - * used for linker to reserve space for the isr stack section - * WARNING: .stack should come immediately after the last secure memory - * section. This provides stack overflow detection. */ - .stack (NOLOAD): - { - __StackLimit = .; - *(.stack*); - . += STACK_SIZE - (. - __StackLimit); - } > SRAM2 - - /* Set stack top to end of RAM, and stack limit move down by - * size of stack_dummy section */ - __StackTop = ADDR(.stack) + SIZEOF(.stack); - _estack = __StackTop; - __StackLimit = ADDR(.stack); - PROVIDE(__stack = __StackTop); - - /* Place holder for additional heap */ - .heap_0 (COPY): - { - __mbed_sbrk_start_0 = .; - . += (ORIGIN(SRAM2) + LENGTH(SRAM2) - .); - __mbed_krbs_start_0 = .; - } > SRAM2 - - /* Check if heap exceeds SRAM2 */ - ASSERT(__mbed_krbs_start_0 <= (ORIGIN(SRAM2)+LENGTH(SRAM2)), "Heap is too big for SRAM2") - - .data : AT (__etext) - { - __data_start__ = .; - _sdata = .; - *(vtable) - *(.data*) - - . = ALIGN(8); - /* preinit data */ - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP(*(.preinit_array)) - PROVIDE_HIDDEN (__preinit_array_end = .); - - . = ALIGN(8); - /* init data */ - PROVIDE_HIDDEN (__init_array_start = .); - KEEP(*(SORT(.init_array.*))) - KEEP(*(.init_array)) - PROVIDE_HIDDEN (__init_array_end = .); - - - . = ALIGN(8); - /* finit data */ - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP(*(SORT(.fini_array.*))) - KEEP(*(.fini_array)) - PROVIDE_HIDDEN (__fini_array_end = .); - - KEEP(*(.jcr*)) - . = ALIGN(8); - /* All data end */ - __data_end__ = .; - _edata = .; - - } > SRAM1 - - /* Check if bss exceeds SRAM1 */ - ASSERT(__data_end__ <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), ".data is too big for SRAM1") - - .bss : - { - . = ALIGN(8); - __bss_start__ = .; - _sbss = .; - *(.bss*) - *(COMMON) - . = ALIGN(8); - __bss_end__ = .; - _ebss = .; - } > SRAM1 - - /* Check if bss exceeds SRAM1 */ - ASSERT(__bss_end__ <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), "BSS is too big for SRAM1") - - /* Placeholder for default single heap */ - .heap (COPY): - { - __end__ = .; - end = __end__; - __mbed_sbrk_start = .; - *(.heap*) - . += (ORIGIN(SRAM1) + LENGTH(SRAM1) - .); - __mbed_krbs_start = .; - __HeapLimit = .; - } > SRAM1 - - /* Check if heap exceeds SRAM1 */ - ASSERT(__HeapLimit <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), "Heap is too big for SRAM1") -} diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L443xC/cmsis_nvic.h b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L443xC/cmsis_nvic.h index b2290b8738f..ec1835224a6 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L443xC/cmsis_nvic.h +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L443xC/cmsis_nvic.h @@ -17,31 +17,7 @@ #ifndef MBED_CMSIS_NVIC_H #define MBED_CMSIS_NVIC_H -#if !defined(MBED_ROM_START) -#define MBED_ROM_START 0x8000000 -#endif - -#if !defined(MBED_ROM_SIZE) -#define MBED_ROM_SIZE 0x40000 // 256 KB -#endif - -#if !defined(MBED_RAM_START) -#define MBED_RAM_START 0x20000000 -#endif - -#if !defined(MBED_RAM_SIZE) -#define MBED_RAM_SIZE 0xc000 // 48 KB -#endif - -#if !defined(MBED_RAM1_START) -#define MBED_RAM1_START 0x10000000 -#endif - -#if !defined(MBED_RAM1_SIZE) -#define MBED_RAM1_SIZE 0x4000 // 16 KB -#endif - #define NVIC_NUM_VECTORS 99 -#define NVIC_RAM_VECTOR_ADDRESS MBED_RAM_START +#define NVIC_RAM_VECTOR_ADDRESS MBED_RAM_BANK_IRAM2_START #endif diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L452xE/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L452xE/CMakeLists.txt index 611b630292d..5a3cf8f2e7a 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L452xE/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L452xE/CMakeLists.txt @@ -5,10 +5,8 @@ add_subdirectory(TARGET_NUCLEO_L452RE_P EXCLUDE_FROM_ALL) if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") set(STARTUP_FILE TOOLCHAIN_GCC_ARM/startup_stm32l452xx.S) - set(LINKER_FILE TOOLCHAIN_GCC_ARM/stm32l452xe.ld) elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") set(STARTUP_FILE TOOLCHAIN_ARM/startup_stm32l452xx.S) - set(LINKER_FILE TOOLCHAIN_ARM/stm32l452xe.sct) endif() add_library(mbed-stm32l452xe INTERFACE) @@ -24,7 +22,4 @@ target_include_directories(mbed-stm32l452xe . ) - -mbed_set_linker_script(mbed-stm32l452xe ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) - target_link_libraries(mbed-stm32l452xe INTERFACE mbed-stm32l4) diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L452xE/cmsis_nvic.h b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L452xE/cmsis_nvic.h index b5288e8a690..4eac8ee21ee 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L452xE/cmsis_nvic.h +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L452xE/cmsis_nvic.h @@ -17,31 +17,7 @@ #ifndef MBED_CMSIS_NVIC_H #define MBED_CMSIS_NVIC_H -#if !defined(MBED_ROM_START) -#define MBED_ROM_START 0x8000000 -#endif - -#if !defined(MBED_ROM_SIZE) -#define MBED_ROM_SIZE 0x80000 // 512 KB -#endif - -#if !defined(MBED_RAM_START) -#define MBED_RAM_START 0x20000000 -#endif - -#if !defined(MBED_RAM_SIZE) -#define MBED_RAM_SIZE 0x20000 // 128 KB -#endif - -#if !defined(MBED_RAM1_START) -#define MBED_RAM1_START 0x10000000 -#endif - -#if !defined(MBED_RAM1_SIZE) -#define MBED_RAM1_SIZE 0x8000 // 32 KB -#endif - #define NVIC_NUM_VECTORS 101 -#define NVIC_RAM_VECTOR_ADDRESS MBED_RAM1_START +#define NVIC_RAM_VECTOR_ADDRESS MBED_RAM_BANK_IRAM2_START #endif diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L471xG/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L471xG/CMakeLists.txt index afd6a71f5a4..02c12d09afa 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L471xG/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L471xG/CMakeLists.txt @@ -5,10 +5,8 @@ add_subdirectory(TARGET_MTS_DRAGONFLY_L471QG EXCLUDE_FROM_ALL) if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") set(STARTUP_FILE TOOLCHAIN_GCC_ARM/startup_stm32l471xx.S) - set(LINKER_FILE TOOLCHAIN_GCC_ARM/stm32l471xg.ld) elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") set(STARTUP_FILE TOOLCHAIN_ARM/startup_stm32l471xx.S) - set(LINKER_FILE TOOLCHAIN_ARM/stm32l471xg.sct) endif() @@ -25,7 +23,4 @@ target_include_directories(mbed-stm32l471xg . ) - -mbed_set_linker_script(mbed-stm32l471xg ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) - target_link_libraries(mbed-stm32l471xg INTERFACE mbed-stm32l4) diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L471xG/TOOLCHAIN_GCC_ARM/stm32l471xg.ld b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L471xG/TOOLCHAIN_GCC_ARM/stm32l471xg.ld deleted file mode 100644 index 67f5a0273c5..00000000000 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L471xG/TOOLCHAIN_GCC_ARM/stm32l471xg.ld +++ /dev/null @@ -1,228 +0,0 @@ -/* Linker script to configure memory regions. */ -/* - * SPDX-License-Identifier: BSD-3-Clause - ****************************************************************************** - * @attention - * - * Copyright (c) 2016-2020 STMicroelectronics. - * All rights reserved. - * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** -*/ - -#include "../cmsis_nvic.h" - - -#if !defined(MBED_APP_START) - #define MBED_APP_START MBED_ROM_START -#endif - -#if !defined(MBED_APP_SIZE) - #define MBED_APP_SIZE MBED_ROM_SIZE -#endif - -M_CRASH_DATA_RAM_SIZE = 0x100; - -#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE) - /* This value is normally defined by the tools - to 0x1000 for bare metal and 0x400 for RTOS */ - #define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400 -#endif - -/* Round up VECTORS_SIZE to 8 bytes */ -#define VECTORS_SIZE (((NVIC_NUM_VECTORS * 4) + 7) & 0xFFFFFFF8) - -MEMORY -{ - FLASH (rx) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE - SRAM2 (rwx) : ORIGIN = MBED_RAM1_START + VECTORS_SIZE, LENGTH = MBED_RAM1_SIZE - VECTORS_SIZE - SRAM1 (rwx) : ORIGIN = MBED_RAM_START, LENGTH = MBED_RAM_SIZE -} - -/* 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 - * _estack - */ -ENTRY(Reset_Handler) - -SECTIONS -{ - .text : - { - KEEP(*(.isr_vector)) - *(.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 = .; - _sidata = .; - - .crash_data_ram : - { - . = ALIGN(8); - __CRASH_DATA_RAM__ = .; - __CRASH_DATA_RAM_START__ = .; /* Create a global symbol at data start */ - KEEP(*(.keep.crash_data_ram)) - *(.m_crash_data_ram) /* This is a user defined section */ - . += M_CRASH_DATA_RAM_SIZE; - . = ALIGN(8); - __CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */ - } > SRAM2 - - /* .stack section doesn't contains any symbols. It is only - * used for linker to reserve space for the isr stack section - * WARNING: .stack should come immediately after the last secure memory - * section. This provides stack overflow detection. */ - .stack (NOLOAD): - { - __StackLimit = .; - *(.stack*); - . += MBED_CONF_TARGET_BOOT_STACK_SIZE - (. - __StackLimit); - } > SRAM2 - - /* Set stack top to end of RAM, and stack limit move down by - * size of stack_dummy section */ - __StackTop = ADDR(.stack) + SIZEOF(.stack); - _estack = __StackTop; - __StackLimit = ADDR(.stack); - PROVIDE(__stack = __StackTop); - - /* Place holder for additional heap */ - .heap_0 (COPY): - { - __mbed_sbrk_start_0 = .; - . += (ORIGIN(SRAM2) + LENGTH(SRAM2) - .); - __mbed_krbs_start_0 = .; - } > SRAM2 - - /* Check if heap exceeds SRAM2 */ - ASSERT(__mbed_krbs_start_0 <= (ORIGIN(SRAM2)+LENGTH(SRAM2)), "Heap is too big for SRAM2") - - .data : AT (__etext) - { - __data_start__ = .; - _sdata = .; - *(vtable) - *(.data*) - - . = ALIGN(8); - /* preinit data */ - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP(*(.preinit_array)) - PROVIDE_HIDDEN (__preinit_array_end = .); - - . = ALIGN(8); - /* init data */ - PROVIDE_HIDDEN (__init_array_start = .); - KEEP(*(SORT(.init_array.*))) - KEEP(*(.init_array)) - PROVIDE_HIDDEN (__init_array_end = .); - - . = ALIGN(8); - /* finit data */ - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP(*(SORT(.fini_array.*))) - KEEP(*(.fini_array)) - PROVIDE_HIDDEN (__fini_array_end = .); - - KEEP(*(.jcr*)) - . = ALIGN(8); - /* All data end */ - __data_end__ = .; - _edata = .; - - } > SRAM1 - - /* Check if bss exceeds SRAM1 */ - ASSERT(__data_end__ <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), ".data is too big for SRAM1") - - .bss : - { - . = ALIGN(8); - __bss_start__ = .; - _sbss = .; - *(.bss*) - *(COMMON) - . = ALIGN(8); - __bss_end__ = .; - _ebss = .; - } > SRAM1 - - /* Check if bss exceeds SRAM1 */ - ASSERT(__bss_end__ <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), "BSS is too big for SRAM1") - - /* Placeholder for default single heap */ - .heap (COPY): - { - __end__ = .; - end = __end__; - __mbed_sbrk_start = .; - *(.heap*) - . += (ORIGIN(SRAM1) + LENGTH(SRAM1) - .); - __mbed_krbs_start = .; - __HeapLimit = .; - } > SRAM1 - - /* Check if heap exceeds SRAM1 */ - ASSERT(__HeapLimit <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), "Heap is too big for SRAM1") -} diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L471xG/cmsis_nvic.h b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L471xG/cmsis_nvic.h index 32c9cfee9a1..e1d07a51128 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L471xG/cmsis_nvic.h +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L471xG/cmsis_nvic.h @@ -17,31 +17,7 @@ #ifndef MBED_CMSIS_NVIC_H #define MBED_CMSIS_NVIC_H -#if !defined(MBED_ROM_START) -#define MBED_ROM_START 0x8000000 -#endif - -#if !defined(MBED_ROM_SIZE) -#define MBED_ROM_SIZE 0x100000 // 1.0 MB -#endif - -#if !defined(MBED_RAM_START) -#define MBED_RAM_START 0x20000000 -#endif - -#if !defined(MBED_RAM_SIZE) -#define MBED_RAM_SIZE 0x18000 // 96 KB -#endif - -#if !defined(MBED_RAM1_START) -#define MBED_RAM1_START 0x10000000 -#endif - -#if !defined(MBED_RAM1_SIZE) -#define MBED_RAM1_SIZE 0x8000 // 32 KB -#endif - #define NVIC_NUM_VECTORS 98 -#define NVIC_RAM_VECTOR_ADDRESS MBED_RAM1_START +#define NVIC_RAM_VECTOR_ADDRESS MBED_RAM_BANK_IRAM2_START #endif diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/CMakeLists.txt index e9f865dd78c..8a40bb27cd9 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/CMakeLists.txt @@ -5,10 +5,8 @@ add_subdirectory(TARGET_DISCO_L475VG_IOT01A EXCLUDE_FROM_ALL) if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") set(STARTUP_FILE TOOLCHAIN_GCC_ARM/startup_stm32l475xx.S) - set(LINKER_FILE TOOLCHAIN_GCC_ARM/stm32l475xg.ld) elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") set(STARTUP_FILE TOOLCHAIN_ARM/startup_stm32l475xx.S) - set(LINKER_FILE TOOLCHAIN_ARM/stm32l475xg.sct) endif() add_library(mbed-stm32l475xg INTERFACE) @@ -24,7 +22,4 @@ target_sources(mbed-stm32l475xg system_clock.c ) - -mbed_set_linker_script(mbed-stm32l475xg ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) - target_link_libraries(mbed-stm32l475xg INTERFACE mbed-stm32l4) diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/TOOLCHAIN_GCC_ARM/stm32l475xg.ld b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/TOOLCHAIN_GCC_ARM/stm32l475xg.ld deleted file mode 100644 index 67f5a0273c5..00000000000 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/TOOLCHAIN_GCC_ARM/stm32l475xg.ld +++ /dev/null @@ -1,228 +0,0 @@ -/* Linker script to configure memory regions. */ -/* - * SPDX-License-Identifier: BSD-3-Clause - ****************************************************************************** - * @attention - * - * Copyright (c) 2016-2020 STMicroelectronics. - * All rights reserved. - * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** -*/ - -#include "../cmsis_nvic.h" - - -#if !defined(MBED_APP_START) - #define MBED_APP_START MBED_ROM_START -#endif - -#if !defined(MBED_APP_SIZE) - #define MBED_APP_SIZE MBED_ROM_SIZE -#endif - -M_CRASH_DATA_RAM_SIZE = 0x100; - -#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE) - /* This value is normally defined by the tools - to 0x1000 for bare metal and 0x400 for RTOS */ - #define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400 -#endif - -/* Round up VECTORS_SIZE to 8 bytes */ -#define VECTORS_SIZE (((NVIC_NUM_VECTORS * 4) + 7) & 0xFFFFFFF8) - -MEMORY -{ - FLASH (rx) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE - SRAM2 (rwx) : ORIGIN = MBED_RAM1_START + VECTORS_SIZE, LENGTH = MBED_RAM1_SIZE - VECTORS_SIZE - SRAM1 (rwx) : ORIGIN = MBED_RAM_START, LENGTH = MBED_RAM_SIZE -} - -/* 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 - * _estack - */ -ENTRY(Reset_Handler) - -SECTIONS -{ - .text : - { - KEEP(*(.isr_vector)) - *(.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 = .; - _sidata = .; - - .crash_data_ram : - { - . = ALIGN(8); - __CRASH_DATA_RAM__ = .; - __CRASH_DATA_RAM_START__ = .; /* Create a global symbol at data start */ - KEEP(*(.keep.crash_data_ram)) - *(.m_crash_data_ram) /* This is a user defined section */ - . += M_CRASH_DATA_RAM_SIZE; - . = ALIGN(8); - __CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */ - } > SRAM2 - - /* .stack section doesn't contains any symbols. It is only - * used for linker to reserve space for the isr stack section - * WARNING: .stack should come immediately after the last secure memory - * section. This provides stack overflow detection. */ - .stack (NOLOAD): - { - __StackLimit = .; - *(.stack*); - . += MBED_CONF_TARGET_BOOT_STACK_SIZE - (. - __StackLimit); - } > SRAM2 - - /* Set stack top to end of RAM, and stack limit move down by - * size of stack_dummy section */ - __StackTop = ADDR(.stack) + SIZEOF(.stack); - _estack = __StackTop; - __StackLimit = ADDR(.stack); - PROVIDE(__stack = __StackTop); - - /* Place holder for additional heap */ - .heap_0 (COPY): - { - __mbed_sbrk_start_0 = .; - . += (ORIGIN(SRAM2) + LENGTH(SRAM2) - .); - __mbed_krbs_start_0 = .; - } > SRAM2 - - /* Check if heap exceeds SRAM2 */ - ASSERT(__mbed_krbs_start_0 <= (ORIGIN(SRAM2)+LENGTH(SRAM2)), "Heap is too big for SRAM2") - - .data : AT (__etext) - { - __data_start__ = .; - _sdata = .; - *(vtable) - *(.data*) - - . = ALIGN(8); - /* preinit data */ - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP(*(.preinit_array)) - PROVIDE_HIDDEN (__preinit_array_end = .); - - . = ALIGN(8); - /* init data */ - PROVIDE_HIDDEN (__init_array_start = .); - KEEP(*(SORT(.init_array.*))) - KEEP(*(.init_array)) - PROVIDE_HIDDEN (__init_array_end = .); - - . = ALIGN(8); - /* finit data */ - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP(*(SORT(.fini_array.*))) - KEEP(*(.fini_array)) - PROVIDE_HIDDEN (__fini_array_end = .); - - KEEP(*(.jcr*)) - . = ALIGN(8); - /* All data end */ - __data_end__ = .; - _edata = .; - - } > SRAM1 - - /* Check if bss exceeds SRAM1 */ - ASSERT(__data_end__ <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), ".data is too big for SRAM1") - - .bss : - { - . = ALIGN(8); - __bss_start__ = .; - _sbss = .; - *(.bss*) - *(COMMON) - . = ALIGN(8); - __bss_end__ = .; - _ebss = .; - } > SRAM1 - - /* Check if bss exceeds SRAM1 */ - ASSERT(__bss_end__ <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), "BSS is too big for SRAM1") - - /* Placeholder for default single heap */ - .heap (COPY): - { - __end__ = .; - end = __end__; - __mbed_sbrk_start = .; - *(.heap*) - . += (ORIGIN(SRAM1) + LENGTH(SRAM1) - .); - __mbed_krbs_start = .; - __HeapLimit = .; - } > SRAM1 - - /* Check if heap exceeds SRAM1 */ - ASSERT(__HeapLimit <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), "Heap is too big for SRAM1") -} diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/cmsis_nvic.h b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/cmsis_nvic.h index c78ee0f7353..fbd3650ac55 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/cmsis_nvic.h +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/cmsis_nvic.h @@ -17,31 +17,7 @@ #ifndef MBED_CMSIS_NVIC_H #define MBED_CMSIS_NVIC_H -#if !defined(MBED_ROM_START) -#define MBED_ROM_START 0x8000000 -#endif - -#if !defined(MBED_ROM_SIZE) -#define MBED_ROM_SIZE 0x100000 // 1.0 MB -#endif - -#if !defined(MBED_RAM_START) -#define MBED_RAM_START 0x20000000 -#endif - -#if !defined(MBED_RAM_SIZE) -#define MBED_RAM_SIZE 0x18000 // 96 KB -#endif - -#if !defined(MBED_RAM1_START) -#define MBED_RAM1_START 0x10000000 -#endif - -#if !defined(MBED_RAM1_SIZE) -#define MBED_RAM1_SIZE 0x8000 // 32 KB -#endif - #define NVIC_NUM_VECTORS 98 -#define NVIC_RAM_VECTOR_ADDRESS MBED_RAM1_START // Vectors positioned at start of SRAM2 +#define NVIC_RAM_VECTOR_ADDRESS MBED_RAM_BANK_IRAM2_START // Vectors positioned at start of SRAM2 #endif diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476xG/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476xG/CMakeLists.txt index 3a7cc2d5ab3..5a911d8d1e7 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476xG/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476xG/CMakeLists.txt @@ -6,10 +6,8 @@ add_subdirectory(TARGET_NUCLEO_L476RG EXCLUDE_FROM_ALL) if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") set(STARTUP_FILE TOOLCHAIN_GCC_ARM/startup_stm32l476xx.S) - set(LINKER_FILE TOOLCHAIN_GCC_ARM/stm32l476xg.ld) elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") set(STARTUP_FILE TOOLCHAIN_ARM/startup_stm32l476xx.S) - set(LINKER_FILE TOOLCHAIN_ARM/stm32l476xg.sct) endif() @@ -26,6 +24,4 @@ target_include_directories(mbed-stm32l476xg . ) -mbed_set_linker_script(mbed-stm32l476xg ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) - target_link_libraries(mbed-stm32l476xg INTERFACE mbed-stm32l4) diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476xG/TOOLCHAIN_GCC_ARM/stm32l476xg.ld b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476xG/TOOLCHAIN_GCC_ARM/stm32l476xg.ld deleted file mode 100644 index 67f5a0273c5..00000000000 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476xG/TOOLCHAIN_GCC_ARM/stm32l476xg.ld +++ /dev/null @@ -1,228 +0,0 @@ -/* Linker script to configure memory regions. */ -/* - * SPDX-License-Identifier: BSD-3-Clause - ****************************************************************************** - * @attention - * - * Copyright (c) 2016-2020 STMicroelectronics. - * All rights reserved. - * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** -*/ - -#include "../cmsis_nvic.h" - - -#if !defined(MBED_APP_START) - #define MBED_APP_START MBED_ROM_START -#endif - -#if !defined(MBED_APP_SIZE) - #define MBED_APP_SIZE MBED_ROM_SIZE -#endif - -M_CRASH_DATA_RAM_SIZE = 0x100; - -#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE) - /* This value is normally defined by the tools - to 0x1000 for bare metal and 0x400 for RTOS */ - #define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400 -#endif - -/* Round up VECTORS_SIZE to 8 bytes */ -#define VECTORS_SIZE (((NVIC_NUM_VECTORS * 4) + 7) & 0xFFFFFFF8) - -MEMORY -{ - FLASH (rx) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE - SRAM2 (rwx) : ORIGIN = MBED_RAM1_START + VECTORS_SIZE, LENGTH = MBED_RAM1_SIZE - VECTORS_SIZE - SRAM1 (rwx) : ORIGIN = MBED_RAM_START, LENGTH = MBED_RAM_SIZE -} - -/* 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 - * _estack - */ -ENTRY(Reset_Handler) - -SECTIONS -{ - .text : - { - KEEP(*(.isr_vector)) - *(.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 = .; - _sidata = .; - - .crash_data_ram : - { - . = ALIGN(8); - __CRASH_DATA_RAM__ = .; - __CRASH_DATA_RAM_START__ = .; /* Create a global symbol at data start */ - KEEP(*(.keep.crash_data_ram)) - *(.m_crash_data_ram) /* This is a user defined section */ - . += M_CRASH_DATA_RAM_SIZE; - . = ALIGN(8); - __CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */ - } > SRAM2 - - /* .stack section doesn't contains any symbols. It is only - * used for linker to reserve space for the isr stack section - * WARNING: .stack should come immediately after the last secure memory - * section. This provides stack overflow detection. */ - .stack (NOLOAD): - { - __StackLimit = .; - *(.stack*); - . += MBED_CONF_TARGET_BOOT_STACK_SIZE - (. - __StackLimit); - } > SRAM2 - - /* Set stack top to end of RAM, and stack limit move down by - * size of stack_dummy section */ - __StackTop = ADDR(.stack) + SIZEOF(.stack); - _estack = __StackTop; - __StackLimit = ADDR(.stack); - PROVIDE(__stack = __StackTop); - - /* Place holder for additional heap */ - .heap_0 (COPY): - { - __mbed_sbrk_start_0 = .; - . += (ORIGIN(SRAM2) + LENGTH(SRAM2) - .); - __mbed_krbs_start_0 = .; - } > SRAM2 - - /* Check if heap exceeds SRAM2 */ - ASSERT(__mbed_krbs_start_0 <= (ORIGIN(SRAM2)+LENGTH(SRAM2)), "Heap is too big for SRAM2") - - .data : AT (__etext) - { - __data_start__ = .; - _sdata = .; - *(vtable) - *(.data*) - - . = ALIGN(8); - /* preinit data */ - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP(*(.preinit_array)) - PROVIDE_HIDDEN (__preinit_array_end = .); - - . = ALIGN(8); - /* init data */ - PROVIDE_HIDDEN (__init_array_start = .); - KEEP(*(SORT(.init_array.*))) - KEEP(*(.init_array)) - PROVIDE_HIDDEN (__init_array_end = .); - - . = ALIGN(8); - /* finit data */ - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP(*(SORT(.fini_array.*))) - KEEP(*(.fini_array)) - PROVIDE_HIDDEN (__fini_array_end = .); - - KEEP(*(.jcr*)) - . = ALIGN(8); - /* All data end */ - __data_end__ = .; - _edata = .; - - } > SRAM1 - - /* Check if bss exceeds SRAM1 */ - ASSERT(__data_end__ <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), ".data is too big for SRAM1") - - .bss : - { - . = ALIGN(8); - __bss_start__ = .; - _sbss = .; - *(.bss*) - *(COMMON) - . = ALIGN(8); - __bss_end__ = .; - _ebss = .; - } > SRAM1 - - /* Check if bss exceeds SRAM1 */ - ASSERT(__bss_end__ <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), "BSS is too big for SRAM1") - - /* Placeholder for default single heap */ - .heap (COPY): - { - __end__ = .; - end = __end__; - __mbed_sbrk_start = .; - *(.heap*) - . += (ORIGIN(SRAM1) + LENGTH(SRAM1) - .); - __mbed_krbs_start = .; - __HeapLimit = .; - } > SRAM1 - - /* Check if heap exceeds SRAM1 */ - ASSERT(__HeapLimit <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), "Heap is too big for SRAM1") -} diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476xG/cmsis_nvic.h b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476xG/cmsis_nvic.h index c78ee0f7353..fbd3650ac55 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476xG/cmsis_nvic.h +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476xG/cmsis_nvic.h @@ -17,31 +17,7 @@ #ifndef MBED_CMSIS_NVIC_H #define MBED_CMSIS_NVIC_H -#if !defined(MBED_ROM_START) -#define MBED_ROM_START 0x8000000 -#endif - -#if !defined(MBED_ROM_SIZE) -#define MBED_ROM_SIZE 0x100000 // 1.0 MB -#endif - -#if !defined(MBED_RAM_START) -#define MBED_RAM_START 0x20000000 -#endif - -#if !defined(MBED_RAM_SIZE) -#define MBED_RAM_SIZE 0x18000 // 96 KB -#endif - -#if !defined(MBED_RAM1_START) -#define MBED_RAM1_START 0x10000000 -#endif - -#if !defined(MBED_RAM1_SIZE) -#define MBED_RAM1_SIZE 0x8000 // 32 KB -#endif - #define NVIC_NUM_VECTORS 98 -#define NVIC_RAM_VECTOR_ADDRESS MBED_RAM1_START // Vectors positioned at start of SRAM2 +#define NVIC_RAM_VECTOR_ADDRESS MBED_RAM_BANK_IRAM2_START // Vectors positioned at start of SRAM2 #endif diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L486xG/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L486xG/CMakeLists.txt index 23a5223706c..2c280d8cc2e 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L486xG/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L486xG/CMakeLists.txt @@ -5,10 +5,8 @@ add_subdirectory(TARGET_NUCLEO_L486RG EXCLUDE_FROM_ALL) if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") set(STARTUP_FILE TOOLCHAIN_GCC_ARM/startup_stm32l486xx.S) - set(LINKER_FILE TOOLCHAIN_GCC_ARM/stm32l486xg.ld) elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") set(STARTUP_FILE TOOLCHAIN_ARM/startup_stm32l486xx.S) - set(LINKER_FILE TOOLCHAIN_ARM/stm32l486xg.sct) endif() add_library(mbed-stm32l486xg INTERFACE) @@ -23,6 +21,4 @@ target_include_directories(mbed-stm32l486xg . ) -mbed_set_linker_script(mbed-stm32l486xg ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) - target_link_libraries(mbed-stm32l486xg INTERFACE mbed-stm32l4) diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L486xG/TOOLCHAIN_GCC_ARM/stm32l486xg.ld b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L486xG/TOOLCHAIN_GCC_ARM/stm32l486xg.ld deleted file mode 100644 index 67f5a0273c5..00000000000 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L486xG/TOOLCHAIN_GCC_ARM/stm32l486xg.ld +++ /dev/null @@ -1,228 +0,0 @@ -/* Linker script to configure memory regions. */ -/* - * SPDX-License-Identifier: BSD-3-Clause - ****************************************************************************** - * @attention - * - * Copyright (c) 2016-2020 STMicroelectronics. - * All rights reserved. - * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** -*/ - -#include "../cmsis_nvic.h" - - -#if !defined(MBED_APP_START) - #define MBED_APP_START MBED_ROM_START -#endif - -#if !defined(MBED_APP_SIZE) - #define MBED_APP_SIZE MBED_ROM_SIZE -#endif - -M_CRASH_DATA_RAM_SIZE = 0x100; - -#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE) - /* This value is normally defined by the tools - to 0x1000 for bare metal and 0x400 for RTOS */ - #define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400 -#endif - -/* Round up VECTORS_SIZE to 8 bytes */ -#define VECTORS_SIZE (((NVIC_NUM_VECTORS * 4) + 7) & 0xFFFFFFF8) - -MEMORY -{ - FLASH (rx) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE - SRAM2 (rwx) : ORIGIN = MBED_RAM1_START + VECTORS_SIZE, LENGTH = MBED_RAM1_SIZE - VECTORS_SIZE - SRAM1 (rwx) : ORIGIN = MBED_RAM_START, LENGTH = MBED_RAM_SIZE -} - -/* 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 - * _estack - */ -ENTRY(Reset_Handler) - -SECTIONS -{ - .text : - { - KEEP(*(.isr_vector)) - *(.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 = .; - _sidata = .; - - .crash_data_ram : - { - . = ALIGN(8); - __CRASH_DATA_RAM__ = .; - __CRASH_DATA_RAM_START__ = .; /* Create a global symbol at data start */ - KEEP(*(.keep.crash_data_ram)) - *(.m_crash_data_ram) /* This is a user defined section */ - . += M_CRASH_DATA_RAM_SIZE; - . = ALIGN(8); - __CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */ - } > SRAM2 - - /* .stack section doesn't contains any symbols. It is only - * used for linker to reserve space for the isr stack section - * WARNING: .stack should come immediately after the last secure memory - * section. This provides stack overflow detection. */ - .stack (NOLOAD): - { - __StackLimit = .; - *(.stack*); - . += MBED_CONF_TARGET_BOOT_STACK_SIZE - (. - __StackLimit); - } > SRAM2 - - /* Set stack top to end of RAM, and stack limit move down by - * size of stack_dummy section */ - __StackTop = ADDR(.stack) + SIZEOF(.stack); - _estack = __StackTop; - __StackLimit = ADDR(.stack); - PROVIDE(__stack = __StackTop); - - /* Place holder for additional heap */ - .heap_0 (COPY): - { - __mbed_sbrk_start_0 = .; - . += (ORIGIN(SRAM2) + LENGTH(SRAM2) - .); - __mbed_krbs_start_0 = .; - } > SRAM2 - - /* Check if heap exceeds SRAM2 */ - ASSERT(__mbed_krbs_start_0 <= (ORIGIN(SRAM2)+LENGTH(SRAM2)), "Heap is too big for SRAM2") - - .data : AT (__etext) - { - __data_start__ = .; - _sdata = .; - *(vtable) - *(.data*) - - . = ALIGN(8); - /* preinit data */ - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP(*(.preinit_array)) - PROVIDE_HIDDEN (__preinit_array_end = .); - - . = ALIGN(8); - /* init data */ - PROVIDE_HIDDEN (__init_array_start = .); - KEEP(*(SORT(.init_array.*))) - KEEP(*(.init_array)) - PROVIDE_HIDDEN (__init_array_end = .); - - . = ALIGN(8); - /* finit data */ - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP(*(SORT(.fini_array.*))) - KEEP(*(.fini_array)) - PROVIDE_HIDDEN (__fini_array_end = .); - - KEEP(*(.jcr*)) - . = ALIGN(8); - /* All data end */ - __data_end__ = .; - _edata = .; - - } > SRAM1 - - /* Check if bss exceeds SRAM1 */ - ASSERT(__data_end__ <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), ".data is too big for SRAM1") - - .bss : - { - . = ALIGN(8); - __bss_start__ = .; - _sbss = .; - *(.bss*) - *(COMMON) - . = ALIGN(8); - __bss_end__ = .; - _ebss = .; - } > SRAM1 - - /* Check if bss exceeds SRAM1 */ - ASSERT(__bss_end__ <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), "BSS is too big for SRAM1") - - /* Placeholder for default single heap */ - .heap (COPY): - { - __end__ = .; - end = __end__; - __mbed_sbrk_start = .; - *(.heap*) - . += (ORIGIN(SRAM1) + LENGTH(SRAM1) - .); - __mbed_krbs_start = .; - __HeapLimit = .; - } > SRAM1 - - /* Check if heap exceeds SRAM1 */ - ASSERT(__HeapLimit <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), "Heap is too big for SRAM1") -} diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L486xG/cmsis_nvic.h b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L486xG/cmsis_nvic.h index c78ee0f7353..fbd3650ac55 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L486xG/cmsis_nvic.h +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L486xG/cmsis_nvic.h @@ -17,31 +17,7 @@ #ifndef MBED_CMSIS_NVIC_H #define MBED_CMSIS_NVIC_H -#if !defined(MBED_ROM_START) -#define MBED_ROM_START 0x8000000 -#endif - -#if !defined(MBED_ROM_SIZE) -#define MBED_ROM_SIZE 0x100000 // 1.0 MB -#endif - -#if !defined(MBED_RAM_START) -#define MBED_RAM_START 0x20000000 -#endif - -#if !defined(MBED_RAM_SIZE) -#define MBED_RAM_SIZE 0x18000 // 96 KB -#endif - -#if !defined(MBED_RAM1_START) -#define MBED_RAM1_START 0x10000000 -#endif - -#if !defined(MBED_RAM1_SIZE) -#define MBED_RAM1_SIZE 0x8000 // 32 KB -#endif - #define NVIC_NUM_VECTORS 98 -#define NVIC_RAM_VECTOR_ADDRESS MBED_RAM1_START // Vectors positioned at start of SRAM2 +#define NVIC_RAM_VECTOR_ADDRESS MBED_RAM_BANK_IRAM2_START // Vectors positioned at start of SRAM2 #endif diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L496xG/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L496xG/CMakeLists.txt index 2e1e4b7dc21..ec96c97b91d 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L496xG/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L496xG/CMakeLists.txt @@ -6,10 +6,8 @@ add_subdirectory(TARGET_NUCLEO_L496ZG EXCLUDE_FROM_ALL) if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") set(STARTUP_FILE TOOLCHAIN_GCC_ARM/startup_stm32l496xx.S) - set(LINKER_FILE TOOLCHAIN_GCC_ARM/stm32l496xg.ld) elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") set(STARTUP_FILE TOOLCHAIN_ARM/startup_stm32l496xx.S) - set(LINKER_FILE TOOLCHAIN_ARM/stm32l496xg.sct) endif() add_library(mbed-stm32l496xg INTERFACE) @@ -25,6 +23,4 @@ target_include_directories(mbed-stm32l496xg . ) -mbed_set_linker_script(mbed-stm32l496xg ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) - target_link_libraries(mbed-stm32l496xg INTERFACE mbed-stm32l4) diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L496xG/TOOLCHAIN_GCC_ARM/stm32l496xg.ld b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L496xG/TOOLCHAIN_GCC_ARM/stm32l496xg.ld deleted file mode 100644 index 3a07ff3bdd7..00000000000 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L496xG/TOOLCHAIN_GCC_ARM/stm32l496xg.ld +++ /dev/null @@ -1,203 +0,0 @@ -/* Linker script to configure memory regions. */ -/* - * SPDX-License-Identifier: BSD-3-Clause - ****************************************************************************** - * @attention - * - * Copyright (c) 2016-2020 STMicroelectronics. - * All rights reserved. - * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** -*/ - -#include "../cmsis_nvic.h" - - -#if !defined(MBED_APP_START) - #define MBED_APP_START MBED_ROM_START -#endif - -#if !defined(MBED_APP_SIZE) - #define MBED_APP_SIZE MBED_ROM_SIZE -#endif - -#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE) - /* This value is normally defined by the tools - to 0x1000 for bare metal and 0x400 for RTOS */ - #define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400 -#endif - -/* Round up VECTORS_SIZE to 8 bytes */ -#define VECTORS_SIZE (((NVIC_NUM_VECTORS * 4) + 7) & 0xFFFFFFF8) - -MEMORY -{ - FLASH (rx) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE - RAM (rwx) : ORIGIN = MBED_RAM_START + VECTORS_SIZE, LENGTH = MBED_RAM_SIZE + MBED_RAM1_SIZE - VECTORS_SIZE -} - -/* 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 - * _estack - */ -ENTRY(Reset_Handler) - -SECTIONS -{ - .text : - { - KEEP(*(.isr_vector)) - *(.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 = .; - _sidata = .; - - .data : AT (__etext) - { - __data_start__ = .; - _sdata = .; - *(vtable) - *(.data*) - - . = ALIGN(8); - /* preinit data */ - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP(*(.preinit_array)) - PROVIDE_HIDDEN (__preinit_array_end = .); - - . = ALIGN(8); - /* init data */ - PROVIDE_HIDDEN (__init_array_start = .); - KEEP(*(SORT(.init_array.*))) - KEEP(*(.init_array)) - PROVIDE_HIDDEN (__init_array_end = .); - - . = ALIGN(8); - /* finit data */ - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP(*(SORT(.fini_array.*))) - KEEP(*(.fini_array)) - PROVIDE_HIDDEN (__fini_array_end = .); - - KEEP(*(.jcr*)) - . = ALIGN(8); - /* All data end */ - __data_end__ = .; - _edata = .; - - } > RAM - - /* Uninitialized data section - * This region is not initialized by the C/C++ library and can be used to - * store state across soft reboots. */ - .uninitialized (NOLOAD): - { - . = ALIGN(32); - __uninitialized_start = .; - *(.uninitialized) - KEEP(*(.keep.uninitialized)) - . = ALIGN(32); - __uninitialized_end = .; - } > RAM - - .bss : - { - . = ALIGN(8); - __bss_start__ = .; - _sbss = .; - *(.bss*) - *(COMMON) - . = ALIGN(8); - __bss_end__ = .; - _ebss = .; - } > RAM - - .heap (COPY): - { - __end__ = .; - PROVIDE(end = .); - *(.heap*) - . = ORIGIN(RAM) + LENGTH(RAM) - MBED_CONF_TARGET_BOOT_STACK_SIZE; - __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); - _estack = __StackTop; - __StackLimit = __StackTop - MBED_CONF_TARGET_BOOT_STACK_SIZE; - PROVIDE(__stack = __StackTop); - - /* Check if data + heap + stack exceeds RAM limit */ - ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") -} diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L496xG/cmsis_nvic.h b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L496xG/cmsis_nvic.h index cc9dc22a061..2ab72208e04 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L496xG/cmsis_nvic.h +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L496xG/cmsis_nvic.h @@ -17,31 +17,7 @@ #ifndef MBED_CMSIS_NVIC_H #define MBED_CMSIS_NVIC_H -#if !defined(MBED_ROM_START) -#define MBED_ROM_START 0x8000000 -#endif - -#if !defined(MBED_ROM_SIZE) -#define MBED_ROM_SIZE 0x100000 // 1.0 MB -#endif - -#if !defined(MBED_RAM_START) -#define MBED_RAM_START 0x20000000 -#endif - -#if !defined(MBED_RAM_SIZE) -#define MBED_RAM_SIZE 0x40000 // 256 KB -#endif - -#if !defined(MBED_RAM1_START) -#define MBED_RAM1_START 0x10000000 -#endif - -#if !defined(MBED_RAM1_SIZE) -#define MBED_RAM1_SIZE 0x10000 // 64 KB -#endif - #define NVIC_NUM_VECTORS 107 -#define NVIC_RAM_VECTOR_ADDRESS MBED_RAM_START +#define NVIC_RAM_VECTOR_ADDRESS MBED_RAM_BANK_IRAM2_START #endif diff --git a/targets/TARGET_STM/TARGET_STM32L4/linker_scripts/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32L4/linker_scripts/CMakeLists.txt new file mode 100644 index 00000000000..552ce84c107 --- /dev/null +++ b/targets/TARGET_STM/TARGET_STM32L4/linker_scripts/CMakeLists.txt @@ -0,0 +1,9 @@ +mbed_set_linker_script(mbed-stm32l432xc ${CMAKE_CURRENT_SOURCE_DIR}/stm32l4_dual_flash_bank.ld) +mbed_set_linker_script(mbed-stm32l433xc ${CMAKE_CURRENT_SOURCE_DIR}/stm32l4_dual_flash_bank.ld) +mbed_set_linker_script(mbed-stm32l443xc ${CMAKE_CURRENT_SOURCE_DIR}/stm32l4_dual_flash_bank.ld) +mbed_set_linker_script(mbed-stm32l452xe ${CMAKE_CURRENT_SOURCE_DIR}/stm32l4_dual_flash_bank.ld) +mbed_set_linker_script(mbed-stm32l471xg ${CMAKE_CURRENT_SOURCE_DIR}/stm32l4_dual_flash_bank.ld) +mbed_set_linker_script(mbed-stm32l475xg ${CMAKE_CURRENT_SOURCE_DIR}/stm32l4_dual_flash_bank.ld) +mbed_set_linker_script(mbed-stm32l476xg ${CMAKE_CURRENT_SOURCE_DIR}/stm32l4_dual_flash_bank.ld) +mbed_set_linker_script(mbed-stm32l486xg ${CMAKE_CURRENT_SOURCE_DIR}/stm32l4_dual_flash_bank.ld) +mbed_set_linker_script(mbed-stm32l496xg ${CMAKE_CURRENT_SOURCE_DIR}/stm32l4_dual_flash_bank.ld) \ No newline at end of file diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L452xE/TOOLCHAIN_GCC_ARM/stm32l452xe.ld b/targets/TARGET_STM/TARGET_STM32L4/linker_scripts/stm32l4_dual_flash_bank.ld similarity index 75% rename from targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L452xE/TOOLCHAIN_GCC_ARM/stm32l452xe.ld rename to targets/TARGET_STM/TARGET_STM32L4/linker_scripts/stm32l4_dual_flash_bank.ld index 17fbe4a799d..8ef2e194da0 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L452xE/TOOLCHAIN_GCC_ARM/stm32l452xe.ld +++ b/targets/TARGET_STM/TARGET_STM32L4/linker_scripts/stm32l4_dual_flash_bank.ld @@ -1,4 +1,6 @@ -/* Linker script to configure memory regions. */ +/* Linker script for all STM32L4xx targets that have one flash bank + * and two RAM banks. */ + /* * SPDX-License-Identifier: BSD-3-Clause ****************************************************************************** @@ -15,16 +17,8 @@ ****************************************************************************** */ -#include "../cmsis_nvic.h" - +#include "cmsis_nvic.h" -#if !defined(MBED_APP_START) - #define MBED_APP_START MBED_ROM_START -#endif - -#if !defined(MBED_APP_SIZE) - #define MBED_APP_SIZE MBED_ROM_SIZE -#endif M_CRASH_DATA_RAM_SIZE = 0x100; @@ -39,9 +33,9 @@ M_CRASH_DATA_RAM_SIZE = 0x100; MEMORY { - FLASH (rx) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE - SRAM2 (rwx) : ORIGIN = MBED_RAM1_START + VECTORS_SIZE, LENGTH = MBED_RAM1_SIZE - VECTORS_SIZE - SRAM1 (rwx) : ORIGIN = MBED_RAM_START, LENGTH = 0x20000 + FLASH (rx) : ORIGIN = MBED_CONFIGURED_ROM_START, LENGTH = MBED_CONFIGURED_ROM_SIZE + SRAM2 (rwx) : ORIGIN = MBED_RAM_BANK_IRAM2_START + VECTORS_SIZE, LENGTH = MBED_RAM_BANK_IRAM2_SIZE - VECTORS_SIZE + SRAM1 (rwx) : ORIGIN = MBED_RAM_BANK_IRAM1_START, LENGTH = MBED_RAM_BANK_IRAM1_SIZE } /* Linker script to place sections and symbol values. Should be used together @@ -129,25 +123,7 @@ SECTIONS __CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */ } > SRAM2 - /* .stack section doesn't contains any symbols. It is only - * used for linker to reserve space for the isr stack section - * WARNING: .stack should come immediately after the last secure memory - * section. This provides stack overflow detection. */ - .stack (NOLOAD): - { - __StackLimit = .; - *(.stack*); - . += MBED_CONF_TARGET_BOOT_STACK_SIZE - (. - __StackLimit); - } > SRAM2 - - /* Set stack top to end of RAM, and stack limit move down by - * size of stack_dummy section */ - __StackTop = ADDR(.stack) + SIZEOF(.stack); - _estack = __StackTop; - __StackLimit = ADDR(.stack); - PROVIDE(__stack = __StackTop); - - /* Place holder for additional heap */ + /* Use all remaining SRAM2 as heap 0 */ .heap_0 (COPY): { __mbed_sbrk_start_0 = .; @@ -155,9 +131,6 @@ SECTIONS __mbed_krbs_start_0 = .; } > SRAM2 - /* Check if heap exceeds SRAM2 */ - ASSERT(__mbed_krbs_start_0 <= (ORIGIN(SRAM2)+LENGTH(SRAM2)), "Heap is too big for SRAM2") - .data : AT (__etext) { __data_start__ = .; @@ -207,11 +180,8 @@ SECTIONS __bss_end__ = .; _ebss = .; } > SRAM1 - - /* Check if bss exceeds SRAM1 */ - ASSERT(__bss_end__ <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), "BSS is too big for SRAM1") - /* Placeholder for default single heap */ + /* Placeholder for heap 0 space */ .heap (COPY): { __end__ = .; @@ -223,6 +193,12 @@ SECTIONS __HeapLimit = .; } > SRAM1 - /* Check if heap exceeds SRAM1 */ - ASSERT(__HeapLimit <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), "Heap is too big for SRAM1") + /* Set stack top to end of SRAM1, and stack limit to be less than that by the boot stack size */ + __StackTop = ORIGIN(SRAM1) + LENGTH(SRAM1); + _estack = __StackTop; + PROVIDE(__stack = __StackTop); + __StackLimit = __StackTop - MBED_CONF_TARGET_BOOT_STACK_SIZE; + + /* Check if bss exceeds SRAM1 */ + ASSERT(__bss_end__ < __StackLimit, "Size of static variables does not leave enough room for minimum stack size") } diff --git a/targets/targets.json5 b/targets/targets.json5 index fbcf8737c06..51d1ae7fb11 100644 --- a/targets/targets.json5 +++ b/targets/targets.json5 @@ -4175,7 +4175,8 @@ mode is recommended for target MCUs with small amounts of flash and RAM.", "STM32L432xC" ], "macros_add": [ - "STM32L432xx" + "STM32L432xx", + "MBED_SPLIT_HEAP" ] }, "NUCLEO_L432KC": { @@ -4197,7 +4198,8 @@ mode is recommended for target MCUs with small amounts of flash and RAM.", "STM32L433xC" ], "macros_add": [ - "STM32L433xx" + "STM32L433xx", + "MBED_SPLIT_HEAP" ] }, "NUCLEO_L433RC_P": { @@ -4440,7 +4442,8 @@ mode is recommended for target MCUs with small amounts of flash and RAM.", "lpuart_clock_source": "USE_LPUART_CLK_HSI|USE_LPUART_CLK_SYSCLK" }, "macros_add": [ - "STM32L496xx" + "STM32L496xx", + "MBED_SPLIT_HEAP" ] }, "DISCO_L496AG": {