diff --git a/targets/TARGET_NUVOTON/TARGET_M2354/CMakeLists.txt b/targets/TARGET_NUVOTON/TARGET_M2354/CMakeLists.txt index 0a6d86f22e9..88d00bae6b8 100644 --- a/targets/TARGET_NUVOTON/TARGET_M2354/CMakeLists.txt +++ b/targets/TARGET_NUVOTON/TARGET_M2354/CMakeLists.txt @@ -14,6 +14,7 @@ target_sources(mbed-m2354 analogin_api.c analogout_api.c + device/partition_M2354_mem.c device/startup_M2354.c device/system_M2354.c device/StdDriver/src/m2354_acmp.c diff --git a/targets/TARGET_NUVOTON/TARGET_M2354/TARGET_TFM/TARGET_NU_M2354/COMPONENT_TFM_S_FW/README.md b/targets/TARGET_NUVOTON/TARGET_M2354/TARGET_TFM/TARGET_NU_M2354/COMPONENT_TFM_S_FW/README.md index b7896920e8a..63f23b5f506 100644 --- a/targets/TARGET_NUVOTON/TARGET_M2354/TARGET_TFM/TARGET_NU_M2354/COMPONENT_TFM_S_FW/README.md +++ b/targets/TARGET_NUVOTON/TARGET_M2354/TARGET_TFM/TARGET_NU_M2354/COMPONENT_TFM_S_FW/README.md @@ -152,6 +152,23 @@ Below summarize the copy paths from TF-M into Mbed: **NOTE**: `trusted-firmware-m/cmake_build/install/image_signing/keys/root-RSA-3072.pem` can be missing due to TF-M build tool issue. Try to get it from `trusted-firmware-m/bl2/ext/mcuboot/root-RSA-3072.pem` instead if it is just the original source. +Open `targets.json5` (for built-in target) or `custom_targets.json5` (for custom target), +, locate the `memory_banks` section for this mbed target, +and update the below symbols per above TF-M exported `region_defs.h`. + +```json5 +"memory_banks": { + "NS_CODE": { + "size": /**/, + "start": /**/, + }, + "NS_DATA": { + "size": /**/, + "start": /**/, + }, +}, +``` + ## PSA Firmware Update ### Requirement diff --git a/targets/TARGET_NUVOTON/TARGET_M2354/device/TOOLCHAIN_ARMC6/M2354.sct b/targets/TARGET_NUVOTON/TARGET_M2354/device/TOOLCHAIN_ARMC6/M2354.sct deleted file mode 100644 index 3c0138002fd..00000000000 --- a/targets/TARGET_NUVOTON/TARGET_M2354/device/TOOLCHAIN_ARMC6/M2354.sct +++ /dev/null @@ -1,64 +0,0 @@ -#! armclang --target=arm-arm-none-eabi -march=armv8-m.base -E -xc - -/* - * Copyright (c) 2020, Nuvoton Technology Corporation - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "../partition_M2354_mem.h" - -#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE) -# if defined(MBED_BOOT_STACK_SIZE) -# define MBED_CONF_TARGET_BOOT_STACK_SIZE MBED_BOOT_STACK_SIZE -# else -# define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400 -# endif -#endif - -LR_IROM1 MBED_APP_START -{ - /* load address = execution address */ - ER_IROM1 +0 - { - *(RESET, +First) - *(InRoot$$Sections) - .ANY (+RO) - } - - ARM_LIB_STACK MBED_RAM_APP_START EMPTY MBED_CONF_TARGET_BOOT_STACK_SIZE - { - } - - /* Reserve for vectors - * - * Vector table base address is required to be 128-byte aligned at a minimum. - * A PE might impose further restrictions on it. */ - ER_IRAMVEC AlignExpr(+0, 128) EMPTY (4*(16 + 116)) - { - } - - RW_IRAM1 AlignExpr(+0, 16) - { - .ANY (+RW +ZI) - } - - ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_APP_START + MBED_RAM_APP_SIZE - AlignExpr(ImageLimit(RW_IRAM1), 16)) - { - } -} - -ScatterAssert(LoadLimit(LR_IROM1) <= (MBED_APP_START + MBED_APP_SIZE)) -ScatterAssert(ImageLimit(ARM_LIB_HEAP) <= MBED_RAM_APP_START + MBED_RAM_APP_SIZE) diff --git a/targets/TARGET_NUVOTON/TARGET_M2354/device/TOOLCHAIN_GCC_ARM/M2354.ld b/targets/TARGET_NUVOTON/TARGET_M2354/device/TOOLCHAIN_GCC_ARM/M2354.ld index 0ae735279d3..1018168e26d 100644 --- a/targets/TARGET_NUVOTON/TARGET_M2354/device/TOOLCHAIN_GCC_ARM/M2354.ld +++ b/targets/TARGET_NUVOTON/TARGET_M2354/device/TOOLCHAIN_GCC_ARM/M2354.ld @@ -34,9 +34,9 @@ StackSize = MBED_CONF_TARGET_BOOT_STACK_SIZE; MEMORY { - VECTORS (rx) : ORIGIN = MBED_APP_START, LENGTH = 0x00000400 - FLASH (rx) : ORIGIN = MBED_APP_START + 0x400, LENGTH = MBED_APP_SIZE - 0x400 - RAM_INTERN (rwx) : ORIGIN = MBED_RAM_APP_START, LENGTH = MBED_RAM_APP_SIZE + VECTORS (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_NS_CODE_START, LENGTH = 0x00000400 + FLASH (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_NS_CODE_START + 0x400, LENGTH = MBED_CONFIGURED_ROM_BANK_NS_CODE_SIZE - 0x400 + RAM_INTERN (rwx) : ORIGIN = MBED_CONFIGURED_RAM_BANK_NS_DATA_START, LENGTH = MBED_CONFIGURED_RAM_BANK_NS_DATA_SIZE } /** diff --git a/targets/TARGET_NUVOTON/TARGET_M2354/device/partition_M2354_mem.c b/targets/TARGET_NUVOTON/TARGET_M2354/device/partition_M2354_mem.c new file mode 100644 index 00000000000..8ee93692bf3 --- /dev/null +++ b/targets/TARGET_NUVOTON/TARGET_M2354/device/partition_M2354_mem.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2020, Nuvoton Technology Corporation + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "partition_M2354_mem.h" + +/* Check MBED_ROM_BANK_NS_CODE_START and friends + * + * These symbols must be resolved by TF-M exported region_defs.h. + */ +static_assert(MBED_ROM_BANK_NS_CODE_START == NS_CODE_START, + "MBED_ROM_BANK_NS_CODE_START not equal TF-M imported NS_CODE_START"); +static_assert(MBED_ROM_BANK_NS_CODE_SIZE == NS_CODE_SIZE, + "MBED_ROM_BANK_NS_CODE_SIZE not equal TF-M imported NS_CODE_SIZE"); +static_assert(MBED_RAM_BANK_NS_DATA_START == NS_DATA_START, + "MBED_RAM_BANK_NS_DATA_START not equal TF-M imported NS_DATA_START"); +static_assert(MBED_RAM_BANK_NS_DATA_SIZE == NS_DATA_SIZE, + "MBED_RAM_BANK_NS_DATA_SIZE not equal TF-M imported NS_DATA_SIZE"); diff --git a/targets/TARGET_NUVOTON/TARGET_M2354/device/partition_M2354_mem.h b/targets/TARGET_NUVOTON/TARGET_M2354/device/partition_M2354_mem.h index f7a97d36a2f..4e81cc6f6fc 100644 --- a/targets/TARGET_NUVOTON/TARGET_M2354/device/partition_M2354_mem.h +++ b/targets/TARGET_NUVOTON/TARGET_M2354/device/partition_M2354_mem.h @@ -19,113 +19,45 @@ #ifndef __PARTITION_M2354_MEM_H__ #define __PARTITION_M2354_MEM_H__ -/* About partition_M2354_mem.h/partition_M2354_mem.icf.h - * - * 1. partition_M2354_mem.h is created for centralizing memory partition configuration. It will be - * included by C/C++ files and linker files (except IAR linker file). - * 2. IAR linker doesn't support preprocessor, so partition_M2354_mem.icf.h, duplicate of partition_M2354_mem.h - * is created for IAR linker file. - * 3. To continue above, we name partition_M2354_mem.icf.h instead of partition_M2354_mem.icf because: - * (1) Mbed OS build tool may mis-regard partition_M2354_mem.icf as the main linker configuration file. - * (2) *.icf files may not be present in search directories for "include" directive. Per observation, - * the search directories are inconsistent among normal example build and test code build. To address - * it, we name partition_M2354_mem.icf.h instead because *.h files are always present in these builds - * (already there or via copy). - */ - #include "nu_tfm_import_define.h" #include NU_TFM_S_REGION_DEFS_H_PATH #include "nu_tfm_import_undefine.h" -/* Resolve MBED_ROM_START and friends +/* Resolve MBED_ROM_BANK_NS_CODE_START and friends * - * TF-M exported region_defs.h essentially resolves MBED_ROM_START and friends. - * target.mbed_rom_start and friends get unnecessary. + * TF-M exported region_defs.h essentially resolves MBED_ROM_BANK_NS_CODE_START and friends. */ -/* Resolve non-secure ROM start */ -#undef MBED_ROM_START -#define MBED_ROM_START NS_CODE_START - -/* Resolve non-secure ROM size */ -#undef MBED_ROM_SIZE -#define MBED_ROM_SIZE NS_CODE_SIZE - -/* Resolve non-secure RAM start */ -#undef MBED_RAM_START -#define MBED_RAM_START NS_DATA_START - -/* Resolve non-secure RAM size */ -#undef MBED_RAM_SIZE -#define MBED_RAM_SIZE NS_DATA_SIZE - -/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just - * MBED_APP_xxx macros to linker files even though they mean the same thing. - * Because this file is to include by both C/C++ files and linker files, we add - * these macros according to the others for consistency when they are missing - * in compile or link stage. */ -#ifndef APPLICATION_ADDR -#ifdef MBED_APP_START -#define APPLICATION_ADDR MBED_APP_START -#else -#define APPLICATION_ADDR MBED_ROM_START -#endif -#endif - -#ifndef APPLICATION_SIZE -#ifdef MBED_APP_SIZE -#define APPLICATION_SIZE MBED_APP_SIZE -#else -#define APPLICATION_SIZE MBED_ROM_SIZE -#endif +/* Physical NS_CODE start/size */ +#if !defined(MBED_ROM_BANK_NS_CODE_START) +#define MBED_ROM_BANK_NS_CODE_START NS_CODE_START #endif +#if !defined(MBED_ROM_BANK_NS_CODE_SIZE) +#define MBED_ROM_BANK_NS_CODE_SIZE NS_CODE_SIZE +#endif -#ifndef APPLICATION_RAM_ADDR -#ifdef MBED_RAM_APP_START -#define APPLICATION_RAM_ADDR MBED_RAM_APP_START -#else -#define APPLICATION_RAM_ADDR MBED_RAM_START +/* Physical NS_DATA start/size */ +#if !defined(MBED_RAM_BANK_NS_DATA_START) +#define MBED_RAM_BANK_NS_DATA_START NS_DATA_START #endif +#if !defined(MBED_RAM_BANK_NS_DATA_SIZE) +#define MBED_RAM_BANK_NS_DATA_SIZE NS_DATA_SIZE #endif -#ifndef APPLICATION_RAM_SIZE -#ifdef MBED_RAM_APP_SIZE -#define APPLICATION_RAM_SIZE MBED_RAM_APP_SIZE -#else -#define APPLICATION_RAM_SIZE MBED_RAM_SIZE -#endif +/* Configured NS_CODE start/size */ +#if !defined(MBED_CONFIGURED_ROM_BANK_NS_CODE_START) +#define MBED_CONFIGURED_ROM_BANK_NS_CODE_START MBED_ROM_BANK_NS_CODE_START #endif +#if !defined(MBED_CONFIGURED_ROM_BANK_NS_CODE_SIZE) +#define MBED_CONFIGURED_ROM_BANK_NS_CODE_SIZE MBED_ROM_BANK_NS_CODE_SIZE +#endif -#ifndef MBED_APP_START -#define MBED_APP_START APPLICATION_ADDR +/* Configured NS_DATA start/size */ +#if !defined(MBED_CONFIGURED_RAM_BANK_NS_DATA_START) +#define MBED_CONFIGURED_RAM_BANK_NS_DATA_START MBED_RAM_BANK_NS_DATA_START #endif - -#ifndef MBED_APP_SIZE -#define MBED_APP_SIZE APPLICATION_SIZE -#endif - -#ifndef MBED_RAM_APP_START -#define MBED_RAM_APP_START APPLICATION_RAM_ADDR -#endif - -#ifndef MBED_RAM_APP_SIZE -#define MBED_RAM_APP_SIZE APPLICATION_RAM_SIZE -#endif - -#if (APPLICATION_ADDR != MBED_APP_START) -#error("APPLICATION_ADDR and MBED_APP_START are not the same!!!") -#endif - -#if (APPLICATION_SIZE != MBED_APP_SIZE) -#error("APPLICATION_SIZE and MBED_APP_SIZE are not the same!!!") -#endif - -#if (APPLICATION_RAM_ADDR != MBED_RAM_APP_START) -#error("APPLICATION_RAM_ADDR and MBED_RAM_APP_START are not the same!!!") -#endif - -#if (APPLICATION_RAM_SIZE != MBED_RAM_APP_SIZE) -#error("APPLICATION_RAM_SIZE and MBED_RAM_APP_SIZE are not the same!!!") +#if !defined(MBED_CONFIGURED_RAM_BANK_NS_DATA_SIZE) +#define MBED_CONFIGURED_RAM_BANK_NS_DATA_SIZE MBED_RAM_BANK_NS_DATA_SIZE #endif #endif /* __PARTITION_M2354_MEM_H__ */ diff --git a/targets/TARGET_NUVOTON/TARGET_M2354/device/partition_M2354_mem.icf.h b/targets/TARGET_NUVOTON/TARGET_M2354/device/partition_M2354_mem.icf.h deleted file mode 100644 index c9602f65cfc..00000000000 --- a/targets/TARGET_NUVOTON/TARGET_M2354/device/partition_M2354_mem.icf.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2020, Nuvoton Technology Corporation - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* See partition_M2354_mem.h for documentation */ - -/* Update MBED_ROM_START and friends on redoing TF-M import (for IAR) - * - * IAR doesn't support CPP, so we cannot resolve MBED_ROM_START and friends by - * TF-M exported region_defs.h. - * - * Without target.mbed_rom_start and friends (replaced with TF-M exported region_defs.h), - * MBED_ROM_START and friends passed along are incorrect. Because IAR doesn't allow symbol - * redefinition, we change to MBED_ROM_START_ORIDE and friends instead for a temporary - * solution. - */ - -/* Resolve non-secure ROM start */ -define symbol MBED_ROM_START_ORIDE = 0x10070400; - -/* Resolve non-secure ROM size */ -define symbol MBED_ROM_SIZE_ORIDE = 0x8F400; - -/* Resolve non-secure RAM start */ -define symbol MBED_RAM_START_ORIDE = 0x30018000; - -/* Resolve non-secure RAM size */ -define symbol MBED_RAM_SIZE_ORIDE = 0x28000; - -/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just - * MBED_APP_xxx macros to linker files even though they mean the same thing. - * Because this file is to include by both C/C++ files and linker files, we add - * these macros according to the others for consistency when they are missing - * in compile or link stage. */ - -if (!isdefinedsymbol(APPLICATION_ADDR)) { - if (isdefinedsymbol(MBED_APP_START)) { - define symbol APPLICATION_ADDR = MBED_APP_START; - } else { - define symbol APPLICATION_ADDR = MBED_ROM_START_ORIDE; - } -} - -if (!isdefinedsymbol(APPLICATION_SIZE)) { - if (isdefinedsymbol(MBED_APP_SIZE)) { - define symbol APPLICATION_SIZE = MBED_APP_SIZE; - } else { - define symbol APPLICATION_SIZE = MBED_ROM_SIZE_ORIDE; - } -} - -if (!isdefinedsymbol(APPLICATION_RAM_ADDR)) { - if (isdefinedsymbol(MBED_RAM_APP_START)) { - define symbol APPLICATION_RAM_ADDR = MBED_RAM_APP_START; - } else { - define symbol APPLICATION_RAM_ADDR = MBED_RAM_START_ORIDE; - } -} - -if (!isdefinedsymbol(APPLICATION_RAM_SIZE)) { - if (isdefinedsymbol(MBED_RAM_APP_SIZE)) { - define symbol APPLICATION_RAM_SIZE = MBED_RAM_APP_SIZE; - } else { - define symbol APPLICATION_RAM_SIZE = MBED_RAM_SIZE_ORIDE; - } -} - -if (!isdefinedsymbol(MBED_APP_START)) { - define symbol MBED_APP_START = APPLICATION_ADDR; -} - -if (!isdefinedsymbol(MBED_APP_SIZE)) { - define symbol MBED_APP_SIZE = APPLICATION_SIZE; -} - -if (!isdefinedsymbol(MBED_RAM_APP_START)) { - define symbol MBED_RAM_APP_START = APPLICATION_RAM_ADDR; -} - -if (!isdefinedsymbol(MBED_RAM_APP_SIZE)) { - define symbol MBED_RAM_APP_SIZE = APPLICATION_RAM_SIZE; -} - -if (APPLICATION_ADDR != MBED_APP_START) { - error "APPLICATION_ADDR and MBED_APP_START are not the same!!!"; -} - -if (APPLICATION_SIZE != MBED_APP_SIZE) { - error "APPLICATION_SIZE and MBED_APP_SIZE are not the same!!!"; -} - -if (APPLICATION_RAM_ADDR != MBED_RAM_APP_START) { - error "APPLICATION_RAM_ADDR and MBED_RAM_APP_START are not the same!!!"; -} - -if (APPLICATION_RAM_SIZE != MBED_RAM_APP_SIZE) { - error "APPLICATION_RAM_SIZE and MBED_RAM_APP_SIZE are not the same!!!"; -} diff --git a/targets/TARGET_NUVOTON/TARGET_M251/device/M251_mem.h b/targets/TARGET_NUVOTON/TARGET_M251/device/M251_mem.h index 4d7817c2352..03a6745e961 100644 --- a/targets/TARGET_NUVOTON/TARGET_M251/device/M251_mem.h +++ b/targets/TARGET_NUVOTON/TARGET_M251/device/M251_mem.h @@ -19,115 +19,42 @@ #ifndef __M251_MEM_H__ #define __M251_MEM_H__ -/* About M251_mem.h/M251_mem.icf.h - * - * 1. M251_mem.h is created for centralizing memory configuration. It will be included by C/C++ files - * and linker files (except IAR linker file). - * 2. IAR linker doesn't support preprocessor, so M251_mem.icf.h, duplicate of M251_mem.h - * is created for IAR linker file. - * 3. To continue above, we name M251_mem.icf.h instead of M251_mem.icf because: - * (1) Mbed OS build tool may mis-regard M251_mem.icf as the main linker configuration file. - * (2) *.icf files may not be present in search directories for "include" directive. Per observation, - * the search directories are inconsistent among normal example build and test code build. To address - * it, we name M251_mem.icf.h instead because *.h files are always present in these builds - * (already there or via copy). - */ - /* Default memory specification * * Flash size: 256KiB * SRAM size: 32KiB */ -/* Resolve ROM start */ -#ifndef MBED_ROM_START -#define MBED_ROM_START (0x0) -#endif - -/* Resolve ROM size */ -#ifndef MBED_ROM_SIZE -#define MBED_ROM_SIZE (0x40000) -#endif - -/* Resolve RAM start */ -#ifndef MBED_RAM_START -#define MBED_RAM_START (0x20000000) -#endif - -/* Resolve RAM size */ -#ifndef MBED_RAM_SIZE -#define MBED_RAM_SIZE (0x8000) -#endif - - -/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just - * MBED_APP_xxx macros to linker files even though they mean the same thing. - * Because this file is to include by both C/C++ files and linker files, we add - * these macros according to the others for consistency when they are missing - * in compile or link stage. */ - -#ifndef APPLICATION_ADDR -#ifdef MBED_APP_START -#define APPLICATION_ADDR MBED_APP_START -#else -#define APPLICATION_ADDR MBED_ROM_START -#endif +/* Physical IROM1 start/size */ +#if !defined(MBED_ROM_BANK_IROM1_START) +#define MBED_ROM_BANK_IROM1_START 0x0 #endif +#if !defined(MBED_ROM_BANK_IROM1_SIZE) +#define MBED_ROM_BANK_IROM1_SIZE 0x40000 +#endif -#ifndef APPLICATION_SIZE -#ifdef MBED_APP_SIZE -#define APPLICATION_SIZE MBED_APP_SIZE -#else -#define APPLICATION_SIZE MBED_ROM_SIZE +/* Physical IRAM1 start/size */ +#if !defined(MBED_RAM_BANK_IRAM1_START) +#define MBED_RAM_BANK_IRAM1_START 0x20000000 #endif +#if !defined(MBED_RAM_BANK_IRAM1_SIZE) +#define MBED_RAM_BANK_IRAM1_SIZE 0x8000 #endif -#ifndef APPLICATION_RAM_ADDR -#ifdef MBED_RAM_APP_START -#define APPLICATION_RAM_ADDR MBED_RAM_APP_START -#else -#define APPLICATION_RAM_ADDR MBED_RAM_START -#endif +/* Configured IROM1 start/size */ +#if !defined(MBED_CONFIGURED_ROM_BANK_IROM1_START) +#define MBED_CONFIGURED_ROM_BANK_IROM1_START MBED_ROM_BANK_IROM1_START #endif +#if !defined(MBED_CONFIGURED_ROM_BANK_IROM1_SIZE) +#define MBED_CONFIGURED_ROM_BANK_IROM1_SIZE MBED_ROM_BANK_IROM1_SIZE +#endif -#ifndef APPLICATION_RAM_SIZE -#ifdef MBED_RAM_APP_SIZE -#define APPLICATION_RAM_SIZE MBED_RAM_APP_SIZE -#else -#define APPLICATION_RAM_SIZE MBED_RAM_SIZE -#endif +/* Configured IRAM1 start/size */ +#if !defined(MBED_CONFIGURED_RAM_BANK_IRAM1_START) +#define MBED_CONFIGURED_RAM_BANK_IRAM1_START MBED_RAM_BANK_IRAM1_START #endif - -#ifndef MBED_APP_START -#define MBED_APP_START APPLICATION_ADDR -#endif - -#ifndef MBED_APP_SIZE -#define MBED_APP_SIZE APPLICATION_SIZE -#endif - -#ifndef MBED_RAM_APP_START -#define MBED_RAM_APP_START APPLICATION_RAM_ADDR -#endif - -#ifndef MBED_RAM_APP_SIZE -#define MBED_RAM_APP_SIZE APPLICATION_RAM_SIZE -#endif - -#if (APPLICATION_ADDR != MBED_APP_START) -#error("APPLICATION_ADDR and MBED_APP_START are not the same!!!") -#endif - -#if (APPLICATION_SIZE != MBED_APP_SIZE) -#error("APPLICATION_SIZE and MBED_APP_SIZE are not the same!!!") -#endif - -#if (APPLICATION_RAM_ADDR != MBED_RAM_APP_START) -#error("APPLICATION_RAM_ADDR and MBED_RAM_APP_START are not the same!!!") -#endif - -#if (APPLICATION_RAM_SIZE != MBED_RAM_APP_SIZE) -#error("APPLICATION_RAM_SIZE and MBED_RAM_APP_SIZE are not the same!!!") +#if !defined(MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE) +#define MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE MBED_RAM_BANK_IRAM1_SIZE #endif #endif /* __M251_MEM_H__ */ diff --git a/targets/TARGET_NUVOTON/TARGET_M251/device/M251_mem.icf.h b/targets/TARGET_NUVOTON/TARGET_M251/device/M251_mem.icf.h deleted file mode 100644 index afa5dcef90a..00000000000 --- a/targets/TARGET_NUVOTON/TARGET_M251/device/M251_mem.icf.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2020, Nuvoton Technology Corporation - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* See M251_mem.h for documentation */ - -/* Default memory specification - * - * Flash size: 256KiB - * SRAM size: 32KiB - */ - -/* Resolve ROM start */ -if (!isdefinedsymbol(MBED_ROM_START)) { - define symbol MBED_ROM_START = 0x0; -} - -/* Resolve ROM size */ -if (!isdefinedsymbol(MBED_ROM_SIZE)) { - define symbol MBED_ROM_SIZE = 0x40000; -} - -/* Resolve RAM start */ -if (!isdefinedsymbol(MBED_RAM_START)) { - define symbol MBED_RAM_START = 0x20000000; -} - -/* Resolve RAM size */ -if (!isdefinedsymbol(MBED_RAM_SIZE)) { - define symbol MBED_RAM_SIZE = 0x8000; -} - -/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just - * MBED_APP_xxx macros to linker files even though they mean the same thing. - * Because this file is to include by both C/C++ files and linker files, we add - * these macros according to the others for consistency when they are missing - * in compile or link stage. */ - -if (!isdefinedsymbol(APPLICATION_ADDR)) { - if (isdefinedsymbol(MBED_APP_START)) { - define symbol APPLICATION_ADDR = MBED_APP_START; - } else { - define symbol APPLICATION_ADDR = MBED_ROM_START; - } -} - -if (!isdefinedsymbol(APPLICATION_SIZE)) { - if (isdefinedsymbol(MBED_APP_SIZE)) { - define symbol APPLICATION_SIZE = MBED_APP_SIZE; - } else { - define symbol APPLICATION_SIZE = MBED_ROM_SIZE; - } -} - -if (!isdefinedsymbol(APPLICATION_RAM_ADDR)) { - if (isdefinedsymbol(MBED_RAM_APP_START)) { - define symbol APPLICATION_RAM_ADDR = MBED_RAM_APP_START; - } else { - define symbol APPLICATION_RAM_ADDR = MBED_RAM_START; - } -} - -if (!isdefinedsymbol(APPLICATION_RAM_SIZE)) { - if (isdefinedsymbol(MBED_RAM_APP_SIZE)) { - define symbol APPLICATION_RAM_SIZE = MBED_RAM_APP_SIZE; - } else { - define symbol APPLICATION_RAM_SIZE = MBED_RAM_SIZE; - } -} - -if (!isdefinedsymbol(MBED_APP_START)) { - define symbol MBED_APP_START = APPLICATION_ADDR; -} - -if (!isdefinedsymbol(MBED_APP_SIZE)) { - define symbol MBED_APP_SIZE = APPLICATION_SIZE; -} - -if (!isdefinedsymbol(MBED_RAM_APP_START)) { - define symbol MBED_RAM_APP_START = APPLICATION_RAM_ADDR; -} - -if (!isdefinedsymbol(MBED_RAM_APP_SIZE)) { - define symbol MBED_RAM_APP_SIZE = APPLICATION_RAM_SIZE; -} - -if (APPLICATION_ADDR != MBED_APP_START) { - error "APPLICATION_ADDR and MBED_APP_START are not the same!!!"; -} - -if (APPLICATION_SIZE != MBED_APP_SIZE) { - error "APPLICATION_SIZE and MBED_APP_SIZE are not the same!!!"; -} - -if (APPLICATION_RAM_ADDR != MBED_RAM_APP_START) { - error "APPLICATION_RAM_ADDR and MBED_RAM_APP_START are not the same!!!"; -} - -if (APPLICATION_RAM_SIZE != MBED_RAM_APP_SIZE) { - error "APPLICATION_RAM_SIZE and MBED_RAM_APP_SIZE are not the same!!!"; -} diff --git a/targets/TARGET_NUVOTON/TARGET_M251/device/TOOLCHAIN_ARMC6/M251.sct b/targets/TARGET_NUVOTON/TARGET_M251/device/TOOLCHAIN_ARMC6/M251.sct deleted file mode 100644 index 46871453b80..00000000000 --- a/targets/TARGET_NUVOTON/TARGET_M251/device/TOOLCHAIN_ARMC6/M251.sct +++ /dev/null @@ -1,67 +0,0 @@ -#! armclang -E --target=arm-arm-none-eabi -x c -mcpu=cortex-m23 - -/* - * Copyright (c) 2019, Nuvoton Technology Corporation - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "../M251_mem.h" - -#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE) -# if defined(MBED_BOOT_STACK_SIZE) -# define MBED_CONF_TARGET_BOOT_STACK_SIZE MBED_BOOT_STACK_SIZE -# else -# define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400 -# endif -#endif - -#define VECTOR_SIZE (4*(16 + 64)) - -LR_IROM1 MBED_APP_START MBED_APP_SIZE -{ - /* load address = execution address */ - ER_IROM1 +0 - { - *(RESET, +First) - *(InRoot$$Sections) - .ANY (+RO) - } - - ARM_LIB_STACK MBED_RAM_APP_START EMPTY MBED_CONF_TARGET_BOOT_STACK_SIZE - { - } - - /* Reserve for vectors - * - * Vector table base address is required to be 128-byte aligned at a minimum. - * A PE might impose further restrictions on it. */ - ER_IRAMVEC AlignExpr(+0, 128) EMPTY VECTOR_SIZE - { - } - - /* 16 byte-aligned */ - RW_IRAM1 AlignExpr(+0, 16) - { - .ANY (+RW +ZI) - } - - ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_APP_START + MBED_RAM_APP_SIZE - AlignExpr(ImageLimit(RW_IRAM1), 16)) - { - } -} - -ScatterAssert(LoadLimit(LR_IROM1) <= (MBED_APP_START + MBED_APP_SIZE)) -ScatterAssert(ImageLimit(ARM_LIB_HEAP) <= (MBED_RAM_APP_START + MBED_RAM_APP_SIZE)) diff --git a/targets/TARGET_NUVOTON/TARGET_M251/device/TOOLCHAIN_GCC_ARM/M251.ld b/targets/TARGET_NUVOTON/TARGET_M251/device/TOOLCHAIN_GCC_ARM/M251.ld index 8fa5fc7e35c..2c529af83c0 100644 --- a/targets/TARGET_NUVOTON/TARGET_M251/device/TOOLCHAIN_GCC_ARM/M251.ld +++ b/targets/TARGET_NUVOTON/TARGET_M251/device/TOOLCHAIN_GCC_ARM/M251.ld @@ -32,9 +32,9 @@ StackSize = MBED_CONF_TARGET_BOOT_STACK_SIZE; MEMORY { - VECTORS (rx) : ORIGIN = MBED_APP_START, LENGTH = 0x00000400 - FLASH (rx) : ORIGIN = MBED_APP_START + 0x400, LENGTH = MBED_APP_SIZE - 0x400 - RAM_INTERN (rwx) : ORIGIN = MBED_RAM_APP_START, LENGTH = MBED_RAM_APP_SIZE + VECTORS (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START, LENGTH = 0x00000400 + FLASH (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START + 0x400, LENGTH = MBED_CONFIGURED_ROM_BANK_IROM1_SIZE - 0x400 + RAM_INTERN (rwx) : ORIGIN = MBED_CONFIGURED_RAM_BANK_IRAM1_START, LENGTH = MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE } /* Must match cmsis_nvic.h */ diff --git a/targets/TARGET_NUVOTON/TARGET_M251/flash_api.c b/targets/TARGET_NUVOTON/TARGET_M251/flash_api.c index 5115794e8f8..fb3c5a81400 100644 --- a/targets/TARGET_NUVOTON/TARGET_M251/flash_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M251/flash_api.c @@ -94,7 +94,7 @@ static const flash_algo_t flash_algo_config = { /* Secure flash */ static const sector_info_t sectors_info[] = { - {MBED_ROM_START, 0x200}, // (start, sector size) + {MBED_ROM_BANK_IROM1_START, 0x200}, // (start, sector size) }; /* Secure flash */ @@ -102,8 +102,8 @@ static const flash_target_config_t flash_target_config = { .page_size = 4, // 4 bytes // Here page_size is program unit, which is different // than FMC definition. - .flash_start = MBED_ROM_START, - .flash_size = MBED_ROM_SIZE, + .flash_start = MBED_ROM_BANK_IROM1_START, + .flash_size = MBED_ROM_BANK_IROM1_SIZE, .sectors = sectors_info, .sector_info_count = sizeof(sectors_info) / sizeof(sector_info_t) }; diff --git a/targets/TARGET_NUVOTON/TARGET_M261/device/M261_mem.h b/targets/TARGET_NUVOTON/TARGET_M261/device/M261_mem.h index 793b913735b..4b900f004a1 100644 --- a/targets/TARGET_NUVOTON/TARGET_M261/device/M261_mem.h +++ b/targets/TARGET_NUVOTON/TARGET_M261/device/M261_mem.h @@ -19,115 +19,42 @@ #ifndef __M261_MEM_H__ #define __M261_MEM_H__ -/* About M261_mem.h/M261_mem.icf.h - * - * 1. M261_mem.h is created for centralizing memory configuration. It will be included by C/C++ files - * and linker files (except IAR linker file). - * 2. IAR linker doesn't support preprocessor, so M261_mem.icf.h, duplicate of M261_mem.h - * is created for IAR linker file. - * 3. To continue above, we name M261_mem.icf.h instead of M261_mem.icf because: - * (1) Mbed OS build tool may mis-regard M261_mem.icf as the main linker configuration file. - * (2) *.icf files may not be present in search directories for "include" directive. Per observation, - * the search directories are inconsistent among normal example build and test code build. To address - * it, we name M261_mem.icf.h instead because *.h files are always present in these builds - * (already there or via copy). - */ - /* Default memory specification * * Flash size: 512KiB * SRAM size: 96KiB */ -/* Resolve ROM start */ -#ifndef MBED_ROM_START -#define MBED_ROM_START (0x0) -#endif - -/* Resolve ROM size */ -#ifndef MBED_ROM_SIZE -#define MBED_ROM_SIZE (0x80000) -#endif - -/* Resolve RAM start */ -#ifndef MBED_RAM_START -#define MBED_RAM_START (0x20000000) -#endif - -/* Resolve RAM size */ -#ifndef MBED_RAM_SIZE -#define MBED_RAM_SIZE (0x18000) -#endif - - -/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just - * MBED_APP_xxx macros to linker files even though they mean the same thing. - * Because this file is to include by both C/C++ files and linker files, we add - * these macros according to the others for consistency when they are missing - * in compile or link stage. */ - -#ifndef APPLICATION_ADDR -#ifdef MBED_APP_START -#define APPLICATION_ADDR MBED_APP_START -#else -#define APPLICATION_ADDR MBED_ROM_START -#endif +/* Physical IROM1 start/size */ +#if !defined(MBED_ROM_BANK_IROM1_START) +#define MBED_ROM_BANK_IROM1_START 0x0 #endif +#if !defined(MBED_ROM_BANK_IROM1_SIZE) +#define MBED_ROM_BANK_IROM1_SIZE 0x80000 +#endif -#ifndef APPLICATION_SIZE -#ifdef MBED_APP_SIZE -#define APPLICATION_SIZE MBED_APP_SIZE -#else -#define APPLICATION_SIZE MBED_ROM_SIZE +/* Physical IRAM1 start/size */ +#if !defined(MBED_RAM_BANK_IRAM1_START) +#define MBED_RAM_BANK_IRAM1_START 0x20000000 #endif +#if !defined(MBED_RAM_BANK_IRAM1_SIZE) +#define MBED_RAM_BANK_IRAM1_SIZE 0x18000 #endif -#ifndef APPLICATION_RAM_ADDR -#ifdef MBED_RAM_APP_START -#define APPLICATION_RAM_ADDR MBED_RAM_APP_START -#else -#define APPLICATION_RAM_ADDR MBED_RAM_START -#endif +/* Configured IROM1 start/size */ +#if !defined(MBED_CONFIGURED_ROM_BANK_IROM1_START) +#define MBED_CONFIGURED_ROM_BANK_IROM1_START MBED_ROM_BANK_IROM1_START #endif +#if !defined(MBED_CONFIGURED_ROM_BANK_IROM1_SIZE) +#define MBED_CONFIGURED_ROM_BANK_IROM1_SIZE MBED_ROM_BANK_IROM1_SIZE +#endif -#ifndef APPLICATION_RAM_SIZE -#ifdef MBED_RAM_APP_SIZE -#define APPLICATION_RAM_SIZE MBED_RAM_APP_SIZE -#else -#define APPLICATION_RAM_SIZE MBED_RAM_SIZE -#endif +/* Configured IRAM1 start/size */ +#if !defined(MBED_CONFIGURED_RAM_BANK_IRAM1_START) +#define MBED_CONFIGURED_RAM_BANK_IRAM1_START MBED_RAM_BANK_IRAM1_START #endif - -#ifndef MBED_APP_START -#define MBED_APP_START APPLICATION_ADDR -#endif - -#ifndef MBED_APP_SIZE -#define MBED_APP_SIZE APPLICATION_SIZE -#endif - -#ifndef MBED_RAM_APP_START -#define MBED_RAM_APP_START APPLICATION_RAM_ADDR -#endif - -#ifndef MBED_RAM_APP_SIZE -#define MBED_RAM_APP_SIZE APPLICATION_RAM_SIZE -#endif - -#if (APPLICATION_ADDR != MBED_APP_START) -#error("APPLICATION_ADDR and MBED_APP_START are not the same!!!") -#endif - -#if (APPLICATION_SIZE != MBED_APP_SIZE) -#error("APPLICATION_SIZE and MBED_APP_SIZE are not the same!!!") -#endif - -#if (APPLICATION_RAM_ADDR != MBED_RAM_APP_START) -#error("APPLICATION_RAM_ADDR and MBED_RAM_APP_START are not the same!!!") -#endif - -#if (APPLICATION_RAM_SIZE != MBED_RAM_APP_SIZE) -#error("APPLICATION_RAM_SIZE and MBED_RAM_APP_SIZE are not the same!!!") +#if !defined(MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE) +#define MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE MBED_RAM_BANK_IRAM1_SIZE #endif #endif /* __M261_MEM_H__ */ diff --git a/targets/TARGET_NUVOTON/TARGET_M261/device/M261_mem.icf.h b/targets/TARGET_NUVOTON/TARGET_M261/device/M261_mem.icf.h deleted file mode 100644 index 92d68dbac46..00000000000 --- a/targets/TARGET_NUVOTON/TARGET_M261/device/M261_mem.icf.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2020, Nuvoton Technology Corporation - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* See M261_mem.h for documentation */ - -/* Default memory specification - * - * Flash size: 512KiB - * SRAM size: 96KiB - */ - -/* Resolve ROM start */ -if (!isdefinedsymbol(MBED_ROM_START)) { - define symbol MBED_ROM_START = 0x0; -} - -/* Resolve ROM size */ -if (!isdefinedsymbol(MBED_ROM_SIZE)) { - define symbol MBED_ROM_SIZE = 0x80000; -} - -/* Resolve RAM start */ -if (!isdefinedsymbol(MBED_RAM_START)) { - define symbol MBED_RAM_START = 0x20000000; -} - -/* Resolve RAM size */ -if (!isdefinedsymbol(MBED_RAM_SIZE)) { - define symbol MBED_RAM_SIZE = 0x18000; -} - -/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just - * MBED_APP_xxx macros to linker files even though they mean the same thing. - * Because this file is to include by both C/C++ files and linker files, we add - * these macros according to the others for consistency when they are missing - * in compile or link stage. */ - -if (!isdefinedsymbol(APPLICATION_ADDR)) { - if (isdefinedsymbol(MBED_APP_START)) { - define symbol APPLICATION_ADDR = MBED_APP_START; - } else { - define symbol APPLICATION_ADDR = MBED_ROM_START; - } -} - -if (!isdefinedsymbol(APPLICATION_SIZE)) { - if (isdefinedsymbol(MBED_APP_SIZE)) { - define symbol APPLICATION_SIZE = MBED_APP_SIZE; - } else { - define symbol APPLICATION_SIZE = MBED_ROM_SIZE; - } -} - -if (!isdefinedsymbol(APPLICATION_RAM_ADDR)) { - if (isdefinedsymbol(MBED_RAM_APP_START)) { - define symbol APPLICATION_RAM_ADDR = MBED_RAM_APP_START; - } else { - define symbol APPLICATION_RAM_ADDR = MBED_RAM_START; - } -} - -if (!isdefinedsymbol(APPLICATION_RAM_SIZE)) { - if (isdefinedsymbol(MBED_RAM_APP_SIZE)) { - define symbol APPLICATION_RAM_SIZE = MBED_RAM_APP_SIZE; - } else { - define symbol APPLICATION_RAM_SIZE = MBED_RAM_SIZE; - } -} - -if (!isdefinedsymbol(MBED_APP_START)) { - define symbol MBED_APP_START = APPLICATION_ADDR; -} - -if (!isdefinedsymbol(MBED_APP_SIZE)) { - define symbol MBED_APP_SIZE = APPLICATION_SIZE; -} - -if (!isdefinedsymbol(MBED_RAM_APP_START)) { - define symbol MBED_RAM_APP_START = APPLICATION_RAM_ADDR; -} - -if (!isdefinedsymbol(MBED_RAM_APP_SIZE)) { - define symbol MBED_RAM_APP_SIZE = APPLICATION_RAM_SIZE; -} - -if (APPLICATION_ADDR != MBED_APP_START) { - error "APPLICATION_ADDR and MBED_APP_START are not the same!!!"; -} - -if (APPLICATION_SIZE != MBED_APP_SIZE) { - error "APPLICATION_SIZE and MBED_APP_SIZE are not the same!!!"; -} - -if (APPLICATION_RAM_ADDR != MBED_RAM_APP_START) { - error "APPLICATION_RAM_ADDR and MBED_RAM_APP_START are not the same!!!"; -} - -if (APPLICATION_RAM_SIZE != MBED_RAM_APP_SIZE) { - error "APPLICATION_RAM_SIZE and MBED_RAM_APP_SIZE are not the same!!!"; -} diff --git a/targets/TARGET_NUVOTON/TARGET_M261/device/TOOLCHAIN_ARMC6/M261.sct b/targets/TARGET_NUVOTON/TARGET_M261/device/TOOLCHAIN_ARMC6/M261.sct deleted file mode 100644 index 0e2e8e3031e..00000000000 --- a/targets/TARGET_NUVOTON/TARGET_M261/device/TOOLCHAIN_ARMC6/M261.sct +++ /dev/null @@ -1,61 +0,0 @@ -#! armclang -E --target=arm-arm-none-eabi -x c -mcpu=cortex-m23 - -/* - * Copyright (c) 2019-2020, Nuvoton Technology Corporation - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "../M261_mem.h" - -#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE) -# if defined(MBED_BOOT_STACK_SIZE) -# define MBED_CONF_TARGET_BOOT_STACK_SIZE MBED_BOOT_STACK_SIZE -# else -# define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400 -# endif -#endif - -#define VECTOR_SIZE (4*(16 + 102)) - -LR_IROM1 MBED_APP_START { - ER_IROM1 +0 { ; load address = execution address - *(RESET, +First) - *(InRoot$$Sections) - .ANY (+RO) - } - - ARM_LIB_STACK MBED_RAM_APP_START EMPTY MBED_CONF_TARGET_BOOT_STACK_SIZE { - } - - /* Reserve for vectors - * - * Vector table base address is required to be 128-byte aligned at a minimum. - * A PE might impose further restrictions on it. */ - ER_IRAMVEC AlignExpr(+0, 128) EMPTY VECTOR_SIZE { ; Reserve for vectors - } - - RW_m_crash_data AlignExpr(+0, 0x100) EMPTY 0x100 { ; Reserve for crash data storage - } - - RW_IRAM1 AlignExpr(+0, 16) { ; 16 byte-aligned - .ANY (+RW +ZI) - } - - ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_APP_START + MBED_RAM_APP_SIZE - AlignExpr(ImageLimit(RW_IRAM1), 16)) { - } -} -ScatterAssert(LoadLimit(LR_IROM1) <= (MBED_APP_START + MBED_APP_SIZE)) -ScatterAssert(ImageLimit(ARM_LIB_HEAP) <= (MBED_RAM_APP_START + MBED_RAM_APP_SIZE)) diff --git a/targets/TARGET_NUVOTON/TARGET_M261/device/TOOLCHAIN_GCC_ARM/M261.ld b/targets/TARGET_NUVOTON/TARGET_M261/device/TOOLCHAIN_GCC_ARM/M261.ld index 2d6d7bb29bc..31d34e4baa5 100644 --- a/targets/TARGET_NUVOTON/TARGET_M261/device/TOOLCHAIN_GCC_ARM/M261.ld +++ b/targets/TARGET_NUVOTON/TARGET_M261/device/TOOLCHAIN_GCC_ARM/M261.ld @@ -35,9 +35,9 @@ StackSize = MBED_CONF_TARGET_BOOT_STACK_SIZE; MEMORY { - VECTORS (rx) : ORIGIN = MBED_APP_START, LENGTH = 0x00000400 - FLASH (rx) : ORIGIN = MBED_APP_START + 0x400, LENGTH = MBED_APP_SIZE - 0x00000400 - RAM_INTERN (rwx) : ORIGIN = MBED_RAM_APP_START, LENGTH = MBED_RAM_APP_SIZE + VECTORS (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START, LENGTH = 0x00000400 + FLASH (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START + 0x400, LENGTH = MBED_CONFIGURED_ROM_BANK_IROM1_SIZE - 0x00000400 + RAM_INTERN (rwx) : ORIGIN = MBED_CONFIGURED_RAM_BANK_IRAM1_START, LENGTH = MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE } /** diff --git a/targets/TARGET_NUVOTON/TARGET_M261/flash_api.c b/targets/TARGET_NUVOTON/TARGET_M261/flash_api.c index 8963309cb7b..ad25d2c2885 100644 --- a/targets/TARGET_NUVOTON/TARGET_M261/flash_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M261/flash_api.c @@ -83,7 +83,7 @@ static const flash_algo_t flash_algo_config = { }; static const sector_info_t sectors_info[] = { - {MBED_ROM_START, 0x800}, // (start, sector size) + {MBED_ROM_BANK_IROM1_START, 0x800}, // (start, sector size) }; /* Secure flash */ @@ -91,8 +91,8 @@ static const flash_target_config_t flash_target_config = { .page_size = 4, // 4 bytes // Here page_size is program unit, which is different // than FMC definition. - .flash_start = MBED_ROM_START, - .flash_size = MBED_ROM_SIZE, + .flash_start = MBED_ROM_BANK_IROM1_START, + .flash_size = MBED_ROM_BANK_IROM1_SIZE, .sectors = sectors_info, .sector_info_count = sizeof(sectors_info) / sizeof(sector_info_t) }; diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/M451_mem.h b/targets/TARGET_NUVOTON/TARGET_M451/device/M451_mem.h index 28872b71ba0..cf25e114c74 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/M451_mem.h +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/M451_mem.h @@ -19,115 +19,42 @@ #ifndef __M451_MEM_H__ #define __M451_MEM_H__ -/* About M451_mem.h/M451_mem.icf.h - * - * 1. M451_mem.h is created for centralizing memory configuration. It will be included by C/C++ files - * and linker files (except IAR linker file). - * 2. IAR linker doesn't support preprocessor, so M451_mem.icf.h, duplicate of M451_mem.h - * is created for IAR linker file. - * 3. To continue above, we name M451_mem.icf.h instead of M451_mem.icf because: - * (1) Mbed OS build tool may mis-regard M451_mem.icf as the main linker configuration file. - * (2) *.icf files may not be present in search directories for "include" directive. Per observation, - * the search directories are inconsistent among normal example build and test code build. To address - * it, we name M451_mem.icf.h instead because *.h files are always present in these builds - * (already there or via copy). - */ - /* Default memory specification * * Flash size: 256KiB * SRAM size: 32KiB */ -/* Resolve ROM start */ -#ifndef MBED_ROM_START -#define MBED_ROM_START (0x0) -#endif - -/* Resolve ROM size */ -#ifndef MBED_ROM_SIZE -#define MBED_ROM_SIZE (0x40000) -#endif - -/* Resolve RAM start */ -#ifndef MBED_RAM_START -#define MBED_RAM_START (0x20000000) -#endif - -/* Resolve RAM size */ -#ifndef MBED_RAM_SIZE -#define MBED_RAM_SIZE (0x8000) -#endif - - -/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just - * MBED_APP_xxx macros to linker files even though they mean the same thing. - * Because this file is to include by both C/C++ files and linker files, we add - * these macros according to the others for consistency when they are missing - * in compile or link stage. */ - -#ifndef APPLICATION_ADDR -#ifdef MBED_APP_START -#define APPLICATION_ADDR MBED_APP_START -#else -#define APPLICATION_ADDR MBED_ROM_START -#endif +/* Physical IROM1 start/size */ +#if !defined(MBED_ROM_BANK_IROM1_START) +#define MBED_ROM_BANK_IROM1_START 0x0 #endif +#if !defined(MBED_ROM_BANK_IROM1_SIZE) +#define MBED_ROM_BANK_IROM1_SIZE 0x40000 +#endif -#ifndef APPLICATION_SIZE -#ifdef MBED_APP_SIZE -#define APPLICATION_SIZE MBED_APP_SIZE -#else -#define APPLICATION_SIZE MBED_ROM_SIZE +/* Physical IRAM1 start/size */ +#if !defined(MBED_RAM_BANK_IRAM1_START) +#define MBED_RAM_BANK_IRAM1_START 0x20000000 #endif +#if !defined(MBED_RAM_BANK_IRAM1_SIZE) +#define MBED_RAM_BANK_IRAM1_SIZE 0x8000 #endif -#ifndef APPLICATION_RAM_ADDR -#ifdef MBED_RAM_APP_START -#define APPLICATION_RAM_ADDR MBED_RAM_APP_START -#else -#define APPLICATION_RAM_ADDR MBED_RAM_START -#endif +/* Configured IROM1 start/size */ +#if !defined(MBED_CONFIGURED_ROM_BANK_IROM1_START) +#define MBED_CONFIGURED_ROM_BANK_IROM1_START MBED_ROM_BANK_IROM1_START #endif +#if !defined(MBED_CONFIGURED_ROM_BANK_IROM1_SIZE) +#define MBED_CONFIGURED_ROM_BANK_IROM1_SIZE MBED_ROM_BANK_IROM1_SIZE +#endif -#ifndef APPLICATION_RAM_SIZE -#ifdef MBED_RAM_APP_SIZE -#define APPLICATION_RAM_SIZE MBED_RAM_APP_SIZE -#else -#define APPLICATION_RAM_SIZE MBED_RAM_SIZE -#endif +/* Configured IRAM1 start/size */ +#if !defined(MBED_CONFIGURED_RAM_BANK_IRAM1_START) +#define MBED_CONFIGURED_RAM_BANK_IRAM1_START MBED_RAM_BANK_IRAM1_START #endif - -#ifndef MBED_APP_START -#define MBED_APP_START APPLICATION_ADDR -#endif - -#ifndef MBED_APP_SIZE -#define MBED_APP_SIZE APPLICATION_SIZE -#endif - -#ifndef MBED_RAM_APP_START -#define MBED_RAM_APP_START APPLICATION_RAM_ADDR -#endif - -#ifndef MBED_RAM_APP_SIZE -#define MBED_RAM_APP_SIZE APPLICATION_RAM_SIZE -#endif - -#if (APPLICATION_ADDR != MBED_APP_START) -#error("APPLICATION_ADDR and MBED_APP_START are not the same!!!") -#endif - -#if (APPLICATION_SIZE != MBED_APP_SIZE) -#error("APPLICATION_SIZE and MBED_APP_SIZE are not the same!!!") -#endif - -#if (APPLICATION_RAM_ADDR != MBED_RAM_APP_START) -#error("APPLICATION_RAM_ADDR and MBED_RAM_APP_START are not the same!!!") -#endif - -#if (APPLICATION_RAM_SIZE != MBED_RAM_APP_SIZE) -#error("APPLICATION_RAM_SIZE and MBED_RAM_APP_SIZE are not the same!!!") +#if !defined(MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE) +#define MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE MBED_RAM_BANK_IRAM1_SIZE #endif #endif /* __M451_MEM_H__ */ diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/M451_mem.icf.h b/targets/TARGET_NUVOTON/TARGET_M451/device/M451_mem.icf.h deleted file mode 100644 index 61e5cce8771..00000000000 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/M451_mem.icf.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2020, Nuvoton Technology Corporation - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* See M451_mem.h for documentation */ - -/* Default memory specification - * - * Flash size: 256KiB - * SRAM size: 32KiB - */ - -/* Resolve ROM start */ -if (!isdefinedsymbol(MBED_ROM_START)) { - define symbol MBED_ROM_START = 0x0; -} - -/* Resolve ROM size */ -if (!isdefinedsymbol(MBED_ROM_SIZE)) { - define symbol MBED_ROM_SIZE = 0x40000; -} - -/* Resolve RAM start */ -if (!isdefinedsymbol(MBED_RAM_START)) { - define symbol MBED_RAM_START = 0x20000000; -} - -/* Resolve RAM size */ -if (!isdefinedsymbol(MBED_RAM_SIZE)) { - define symbol MBED_RAM_SIZE = 0x8000; -} - -/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just - * MBED_APP_xxx macros to linker files even though they mean the same thing. - * Because this file is to include by both C/C++ files and linker files, we add - * these macros according to the others for consistency when they are missing - * in compile or link stage. */ - -if (!isdefinedsymbol(APPLICATION_ADDR)) { - if (isdefinedsymbol(MBED_APP_START)) { - define symbol APPLICATION_ADDR = MBED_APP_START; - } else { - define symbol APPLICATION_ADDR = MBED_ROM_START; - } -} - -if (!isdefinedsymbol(APPLICATION_SIZE)) { - if (isdefinedsymbol(MBED_APP_SIZE)) { - define symbol APPLICATION_SIZE = MBED_APP_SIZE; - } else { - define symbol APPLICATION_SIZE = MBED_ROM_SIZE; - } -} - -if (!isdefinedsymbol(APPLICATION_RAM_ADDR)) { - if (isdefinedsymbol(MBED_RAM_APP_START)) { - define symbol APPLICATION_RAM_ADDR = MBED_RAM_APP_START; - } else { - define symbol APPLICATION_RAM_ADDR = MBED_RAM_START; - } -} - -if (!isdefinedsymbol(APPLICATION_RAM_SIZE)) { - if (isdefinedsymbol(MBED_RAM_APP_SIZE)) { - define symbol APPLICATION_RAM_SIZE = MBED_RAM_APP_SIZE; - } else { - define symbol APPLICATION_RAM_SIZE = MBED_RAM_SIZE; - } -} - -if (!isdefinedsymbol(MBED_APP_START)) { - define symbol MBED_APP_START = APPLICATION_ADDR; -} - -if (!isdefinedsymbol(MBED_APP_SIZE)) { - define symbol MBED_APP_SIZE = APPLICATION_SIZE; -} - -if (!isdefinedsymbol(MBED_RAM_APP_START)) { - define symbol MBED_RAM_APP_START = APPLICATION_RAM_ADDR; -} - -if (!isdefinedsymbol(MBED_RAM_APP_SIZE)) { - define symbol MBED_RAM_APP_SIZE = APPLICATION_RAM_SIZE; -} - -if (APPLICATION_ADDR != MBED_APP_START) { - error "APPLICATION_ADDR and MBED_APP_START are not the same!!!"; -} - -if (APPLICATION_SIZE != MBED_APP_SIZE) { - error "APPLICATION_SIZE and MBED_APP_SIZE are not the same!!!"; -} - -if (APPLICATION_RAM_ADDR != MBED_RAM_APP_START) { - error "APPLICATION_RAM_ADDR and MBED_RAM_APP_START are not the same!!!"; -} - -if (APPLICATION_RAM_SIZE != MBED_RAM_APP_SIZE) { - error "APPLICATION_RAM_SIZE and MBED_RAM_APP_SIZE are not the same!!!"; -} diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/TOOLCHAIN_GCC_ARM/M453.ld b/targets/TARGET_NUVOTON/TARGET_M451/device/TOOLCHAIN_GCC_ARM/M453.ld index 1171d176eaa..59477613fda 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/TOOLCHAIN_GCC_ARM/M453.ld +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/TOOLCHAIN_GCC_ARM/M453.ld @@ -34,9 +34,9 @@ StackSize = MBED_CONF_TARGET_BOOT_STACK_SIZE; MEMORY { - VECTORS (rx) : ORIGIN = MBED_APP_START, LENGTH = 0x400 - FLASH (rx) : ORIGIN = MBED_APP_START + 0x400, LENGTH = MBED_APP_SIZE - 0x400 - RAM_INTERN (rwx) : ORIGIN = MBED_RAM_APP_START, LENGTH = MBED_RAM_APP_SIZE + VECTORS (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START, LENGTH = 0x400 + FLASH (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START + 0x400, LENGTH = MBED_CONFIGURED_ROM_BANK_IROM1_SIZE - 0x400 + RAM_INTERN (rwx) : ORIGIN = MBED_CONFIGURED_RAM_BANK_IRAM1_START, LENGTH = MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE } /** diff --git a/targets/TARGET_NUVOTON/TARGET_M451/flash_api.c b/targets/TARGET_NUVOTON/TARGET_M451/flash_api.c index ac683a6a810..5126f527950 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/flash_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/flash_api.c @@ -63,14 +63,14 @@ static const flash_algo_t flash_algo_config = { }; static const sector_info_t sectors_info[] = { - {MBED_ROM_START, 0x800}, // (start, sector size) + {MBED_ROM_BANK_IROM1_START, 0x800}, // (start, sector size) }; static const flash_target_config_t flash_target_config = { .page_size = 4, // 4 bytes // Here page_size is program unit, which is different than FMC definition. - .flash_start = MBED_ROM_START, - .flash_size = MBED_ROM_SIZE, + .flash_start = MBED_ROM_BANK_IROM1_START, + .flash_size = MBED_ROM_BANK_IROM1_SIZE, .sectors = sectors_info, .sector_info_count = sizeof(sectors_info) / sizeof(sector_info_t) }; diff --git a/targets/TARGET_NUVOTON/TARGET_M460/device/M460_mem.h b/targets/TARGET_NUVOTON/TARGET_M460/device/M460_mem.h index e2c82845bd6..8a4d762fd54 100644 --- a/targets/TARGET_NUVOTON/TARGET_M460/device/M460_mem.h +++ b/targets/TARGET_NUVOTON/TARGET_M460/device/M460_mem.h @@ -19,115 +19,58 @@ #ifndef __M460_MEM_H__ #define __M460_MEM_H__ -/* About M460_mem.h/M460_mem.icf.h - * - * 1. M460_mem.h is created for centralizing memory configuration. It will be included by C/C++ files - * and linker files (except IAR linker file). - * 2. IAR linker doesn't support preprocessor, so M460_mem.icf.h, duplicate of M460_mem.h - * is created for IAR linker file. - * 3. To continue above, we name M460_mem.icf.h instead of M460_mem.icf because: - * (1) Mbed OS build tool may mis-regard M460_mem.icf as the main linker configuration file. - * (2) *.icf files may not be present in search directories for "include" directive. Per observation, - * the search directories are inconsistent among normal example build and test code build. To address - * it, we name M460_mem.icf.h instead because *.h files are always present in these builds - * (already there or via copy). - */ - /* Default memory specification * * Flash size: 1024KiB * SRAM size: 512KiB */ -/* Resolve ROM start */ -#ifndef MBED_ROM_START -#define MBED_ROM_START (0x0) +/* Physical IROM1 start/size */ +#if !defined(MBED_ROM_BANK_IROM1_START) +#define MBED_ROM_BANK_IROM1_START 0x0 #endif +#if !defined(MBED_ROM_BANK_IROM1_SIZE) +#define MBED_ROM_BANK_IROM1_SIZE 0x100000 +#endif -/* Resolve ROM size */ -#ifndef MBED_ROM_SIZE -#define MBED_ROM_SIZE (0x100000) +/* Physical IRAM1 start/size */ +#if !defined(MBED_RAM_BANK_IRAM1_START) +#define MBED_RAM_BANK_IRAM1_START 0x20000000 #endif - -/* Resolve RAM start */ -#ifndef MBED_RAM_START -#define MBED_RAM_START (0x20000000) +#if !defined(MBED_RAM_BANK_IRAM1_SIZE) +#define MBED_RAM_BANK_IRAM1_SIZE 0x80000 #endif -/* Resolve RAM size */ -#ifndef MBED_RAM_SIZE -#define MBED_RAM_SIZE (0x80000) +/* Configured IROM1 start/size */ +#if !defined(MBED_CONFIGURED_ROM_BANK_IROM1_START) +#define MBED_CONFIGURED_ROM_BANK_IROM1_START MBED_ROM_BANK_IROM1_START #endif +#if !defined(MBED_CONFIGURED_ROM_BANK_IROM1_SIZE) +#define MBED_CONFIGURED_ROM_BANK_IROM1_SIZE MBED_ROM_BANK_IROM1_SIZE +#endif - -/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just - * MBED_APP_xxx macros to linker files even though they mean the same thing. - * Because this file is to include by both C/C++ files and linker files, we add - * these macros according to the others for consistency when they are missing - * in compile or link stage. */ - -#ifndef APPLICATION_ADDR -#ifdef MBED_APP_START -#define APPLICATION_ADDR MBED_APP_START -#else -#define APPLICATION_ADDR MBED_ROM_START +/* Configured IRAM1 start/size */ +#if !defined(MBED_CONFIGURED_RAM_BANK_IRAM1_START) +#define MBED_CONFIGURED_RAM_BANK_IRAM1_START MBED_RAM_BANK_IRAM1_START #endif +#if !defined(MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE) +#define MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE MBED_RAM_BANK_IRAM1_SIZE #endif -#ifndef APPLICATION_SIZE -#ifdef MBED_APP_SIZE -#define APPLICATION_SIZE MBED_APP_SIZE -#else -#define APPLICATION_SIZE MBED_ROM_SIZE +/* Physical HYPERRAM1 start/size */ +#if !defined(MBED_RAM_BANK_HYPERRAM1_START) +#define MBED_RAM_BANK_HYPERRAM1_START 0x80000000 #endif +#if !defined(MBED_RAM_BANK_HYPERRAM1_SIZE) +#define MBED_RAM_BANK_HYPERRAM1_SIZE 0x800000 #endif -#ifndef APPLICATION_RAM_ADDR -#ifdef MBED_RAM_APP_START -#define APPLICATION_RAM_ADDR MBED_RAM_APP_START -#else -#define APPLICATION_RAM_ADDR MBED_RAM_START -#endif +/* Configured HYPERRAM1 start/size */ +#if !defined(MBED_CONFIGURED_RAM_BANK_HYPERRAM1_START) +#define MBED_CONFIGURED_RAM_BANK_HYPERRAM1_START MBED_RAM_BANK_HYPERRAM1_START #endif - -#ifndef APPLICATION_RAM_SIZE -#ifdef MBED_RAM_APP_SIZE -#define APPLICATION_RAM_SIZE MBED_RAM_APP_SIZE -#else -#define APPLICATION_RAM_SIZE MBED_RAM_SIZE -#endif -#endif - -#ifndef MBED_APP_START -#define MBED_APP_START APPLICATION_ADDR -#endif - -#ifndef MBED_APP_SIZE -#define MBED_APP_SIZE APPLICATION_SIZE -#endif - -#ifndef MBED_RAM_APP_START -#define MBED_RAM_APP_START APPLICATION_RAM_ADDR -#endif - -#ifndef MBED_RAM_APP_SIZE -#define MBED_RAM_APP_SIZE APPLICATION_RAM_SIZE -#endif - -#if (APPLICATION_ADDR != MBED_APP_START) -#error("APPLICATION_ADDR and MBED_APP_START are not the same!!!") -#endif - -#if (APPLICATION_SIZE != MBED_APP_SIZE) -#error("APPLICATION_SIZE and MBED_APP_SIZE are not the same!!!") -#endif - -#if (APPLICATION_RAM_ADDR != MBED_RAM_APP_START) -#error("APPLICATION_RAM_ADDR and MBED_RAM_APP_START are not the same!!!") -#endif - -#if (APPLICATION_RAM_SIZE != MBED_RAM_APP_SIZE) -#error("APPLICATION_RAM_SIZE and MBED_RAM_APP_SIZE are not the same!!!") +#if !defined(MBED_CONFIGURED_RAM_BANK_HYPERRAM1_SIZE) +#define MBED_CONFIGURED_RAM_BANK_HYPERRAM1_SIZE MBED_RAM_BANK_HYPERRAM1_SIZE #endif #endif /* __M460_MEM_H__ */ diff --git a/targets/TARGET_NUVOTON/TARGET_M460/device/M460_mem.icf.h b/targets/TARGET_NUVOTON/TARGET_M460/device/M460_mem.icf.h deleted file mode 100644 index 35617da4d3b..00000000000 --- a/targets/TARGET_NUVOTON/TARGET_M460/device/M460_mem.icf.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2022, Nuvoton Technology Corporation - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* See M460_mem.h for documentation */ - -/* Default memory specification - * - * Flash size: 1024KiB - * SRAM size: 512KiB - */ - -/* Resolve ROM start */ -if (!isdefinedsymbol(MBED_ROM_START)) { - define symbol MBED_ROM_START = 0x0; -} - -/* Resolve ROM size */ -if (!isdefinedsymbol(MBED_ROM_SIZE)) { - define symbol MBED_ROM_SIZE = 0x100000; -} - -/* Resolve RAM start */ -if (!isdefinedsymbol(MBED_RAM_START)) { - define symbol MBED_RAM_START = 0x20000000; -} - -/* Resolve RAM size */ -if (!isdefinedsymbol(MBED_RAM_SIZE)) { - define symbol MBED_RAM_SIZE = 0x80000; -} - -/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just - * MBED_APP_xxx macros to linker files even though they mean the same thing. - * Because this file is to include by both C/C++ files and linker files, we add - * these macros according to the others for consistency when they are missing - * in compile or link stage. */ - -if (!isdefinedsymbol(APPLICATION_ADDR)) { - if (isdefinedsymbol(MBED_APP_START)) { - define symbol APPLICATION_ADDR = MBED_APP_START; - } else { - define symbol APPLICATION_ADDR = MBED_ROM_START; - } -} - -if (!isdefinedsymbol(APPLICATION_SIZE)) { - if (isdefinedsymbol(MBED_APP_SIZE)) { - define symbol APPLICATION_SIZE = MBED_APP_SIZE; - } else { - define symbol APPLICATION_SIZE = MBED_ROM_SIZE; - } -} - -if (!isdefinedsymbol(APPLICATION_RAM_ADDR)) { - if (isdefinedsymbol(MBED_RAM_APP_START)) { - define symbol APPLICATION_RAM_ADDR = MBED_RAM_APP_START; - } else { - define symbol APPLICATION_RAM_ADDR = MBED_RAM_START; - } -} - -if (!isdefinedsymbol(APPLICATION_RAM_SIZE)) { - if (isdefinedsymbol(MBED_RAM_APP_SIZE)) { - define symbol APPLICATION_RAM_SIZE = MBED_RAM_APP_SIZE; - } else { - define symbol APPLICATION_RAM_SIZE = MBED_RAM_SIZE; - } -} - -if (!isdefinedsymbol(MBED_APP_START)) { - define symbol MBED_APP_START = APPLICATION_ADDR; -} - -if (!isdefinedsymbol(MBED_APP_SIZE)) { - define symbol MBED_APP_SIZE = APPLICATION_SIZE; -} - -if (!isdefinedsymbol(MBED_RAM_APP_START)) { - define symbol MBED_RAM_APP_START = APPLICATION_RAM_ADDR; -} - -if (!isdefinedsymbol(MBED_RAM_APP_SIZE)) { - define symbol MBED_RAM_APP_SIZE = APPLICATION_RAM_SIZE; -} - -if (APPLICATION_ADDR != MBED_APP_START) { - error "APPLICATION_ADDR and MBED_APP_START are not the same!!!"; -} - -if (APPLICATION_SIZE != MBED_APP_SIZE) { - error "APPLICATION_SIZE and MBED_APP_SIZE are not the same!!!"; -} - -if (APPLICATION_RAM_ADDR != MBED_RAM_APP_START) { - error "APPLICATION_RAM_ADDR and MBED_RAM_APP_START are not the same!!!"; -} - -if (APPLICATION_RAM_SIZE != MBED_RAM_APP_SIZE) { - error "APPLICATION_RAM_SIZE and MBED_RAM_APP_SIZE are not the same!!!"; -} diff --git a/targets/TARGET_NUVOTON/TARGET_M460/device/TOOLCHAIN_GCC_ARM/M467.ld b/targets/TARGET_NUVOTON/TARGET_M460/device/TOOLCHAIN_GCC_ARM/M467.ld index 95b33e0b2d3..9b34e3893da 100644 --- a/targets/TARGET_NUVOTON/TARGET_M460/device/TOOLCHAIN_GCC_ARM/M467.ld +++ b/targets/TARGET_NUVOTON/TARGET_M460/device/TOOLCHAIN_GCC_ARM/M467.ld @@ -30,23 +30,15 @@ # endif #endif -#if !defined(NU_HYPERRAM_START) -#define NU_HYPERRAM_START 0x80000000 -#endif - -#if !defined(NU_HYPERRAM_SIZE) -#define NU_HYPERRAM_SIZE 0x800000 -#endif - M_CRASH_DATA_RAM_SIZE = 0x100; StackSize = MBED_CONF_TARGET_BOOT_STACK_SIZE; MEMORY { - VECTORS (rx) : ORIGIN = MBED_APP_START, LENGTH = 0x00000400 - FLASH (rx) : ORIGIN = MBED_APP_START + 0x400, LENGTH = MBED_APP_SIZE - 0x00000400 - RAM_INTERN (rwx) : ORIGIN = MBED_RAM_APP_START, LENGTH = MBED_RAM_APP_SIZE - HYPERRAM (rwx) : ORIGIN = NU_HYPERRAM_START, LENGTH = NU_HYPERRAM_SIZE + VECTORS (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START, LENGTH = 0x00000400 + FLASH (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START + 0x400, LENGTH = MBED_CONFIGURED_ROM_BANK_IROM1_SIZE - 0x00000400 + RAM_INTERN (rwx) : ORIGIN = MBED_CONFIGURED_RAM_BANK_IRAM1_START, LENGTH = MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE + HYPERRAM (rwx) : ORIGIN = MBED_CONFIGURED_RAM_BANK_HYPERRAM1_START, LENGTH = MBED_CONFIGURED_RAM_BANK_HYPERRAM1_SIZE } /** diff --git a/targets/TARGET_NUVOTON/TARGET_M460/flash_api.c b/targets/TARGET_NUVOTON/TARGET_M460/flash_api.c index 7a63a74820c..6df95966962 100644 --- a/targets/TARGET_NUVOTON/TARGET_M460/flash_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M460/flash_api.c @@ -57,14 +57,14 @@ static const flash_algo_t flash_algo_config = { }; static const sector_info_t sectors_info[] = { - {MBED_ROM_START, 0x1000}, // (start, sector size) + {MBED_ROM_BANK_IROM1_START, 0x1000}, // (start, sector size) }; static const flash_target_config_t flash_target_config = { .page_size = 4, // 4 bytes // Here page_size is program unit, which is different than FMC definition. - .flash_start = MBED_ROM_START, - .flash_size = MBED_ROM_SIZE, + .flash_start = MBED_ROM_BANK_IROM1_START, + .flash_size = MBED_ROM_BANK_IROM1_SIZE, .sectors = sectors_info, .sector_info_count = sizeof(sectors_info) / sizeof(sector_info_t) }; diff --git a/targets/TARGET_NUVOTON/TARGET_M480/device/M480_mem.h b/targets/TARGET_NUVOTON/TARGET_M480/device/M480_mem.h index 60aef6d73ea..f3963dc59ad 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/device/M480_mem.h +++ b/targets/TARGET_NUVOTON/TARGET_M480/device/M480_mem.h @@ -19,115 +19,42 @@ #ifndef __M480_MEM_H__ #define __M480_MEM_H__ -/* About M480_mem.h/M480_mem.icf.h - * - * 1. M480_mem.h is created for centralizing memory configuration. It will be included by C/C++ files - * and linker files (except IAR linker file). - * 2. IAR linker doesn't support preprocessor, so M480_mem.icf.h, duplicate of M480_mem.h - * is created for IAR linker file. - * 3. To continue above, we name M480_mem.icf.h instead of M480_mem.icf because: - * (1) Mbed OS build tool may mis-regard M480_mem.icf as the main linker configuration file. - * (2) *.icf files may not be present in search directories for "include" directive. Per observation, - * the search directories are inconsistent among normal example build and test code build. To address - * it, we name M480_mem.icf.h instead because *.h files are always present in these builds - * (already there or via copy). - */ - /* Default memory specification * * Flash size: 512KiB * SRAM size: 160KiB = 128KiB + 32KiB (SPIM CCM) */ -/* Resolve ROM start */ -#ifndef MBED_ROM_START -#define MBED_ROM_START (0x0) -#endif - -/* Resolve ROM size */ -#ifndef MBED_ROM_SIZE -#define MBED_ROM_SIZE (0x80000) -#endif - -/* Resolve RAM start */ -#ifndef MBED_RAM_START -#define MBED_RAM_START (0x20000000) -#endif - -/* Resolve RAM size */ -#ifndef MBED_RAM_SIZE -#define MBED_RAM_SIZE (0x28000) -#endif - - -/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just - * MBED_APP_xxx macros to linker files even though they mean the same thing. - * Because this file is to include by both C/C++ files and linker files, we add - * these macros according to the others for consistency when they are missing - * in compile or link stage. */ - -#ifndef APPLICATION_ADDR -#ifdef MBED_APP_START -#define APPLICATION_ADDR MBED_APP_START -#else -#define APPLICATION_ADDR MBED_ROM_START -#endif +/* Physical IROM1 start/size */ +#if !defined(MBED_ROM_BANK_IROM1_START) +#define MBED_ROM_BANK_IROM1_START 0x0 #endif +#if !defined(MBED_ROM_BANK_IROM1_SIZE) +#define MBED_ROM_BANK_IROM1_SIZE 0x80000 +#endif -#ifndef APPLICATION_SIZE -#ifdef MBED_APP_SIZE -#define APPLICATION_SIZE MBED_APP_SIZE -#else -#define APPLICATION_SIZE MBED_ROM_SIZE +/* Physical IRAM1 start/size */ +#if !defined(MBED_RAM_BANK_IRAM1_START) +#define MBED_RAM_BANK_IRAM1_START 0x20000000 #endif +#if !defined(MBED_RAM_BANK_IRAM1_SIZE) +#define MBED_RAM_BANK_IRAM1_SIZE 0x28000 #endif -#ifndef APPLICATION_RAM_ADDR -#ifdef MBED_RAM_APP_START -#define APPLICATION_RAM_ADDR MBED_RAM_APP_START -#else -#define APPLICATION_RAM_ADDR MBED_RAM_START -#endif +/* Configured IROM1 start/size */ +#if !defined(MBED_CONFIGURED_ROM_BANK_IROM1_START) +#define MBED_CONFIGURED_ROM_BANK_IROM1_START MBED_ROM_BANK_IROM1_START #endif +#if !defined(MBED_CONFIGURED_ROM_BANK_IROM1_SIZE) +#define MBED_CONFIGURED_ROM_BANK_IROM1_SIZE MBED_ROM_BANK_IROM1_SIZE +#endif -#ifndef APPLICATION_RAM_SIZE -#ifdef MBED_RAM_APP_SIZE -#define APPLICATION_RAM_SIZE MBED_RAM_APP_SIZE -#else -#define APPLICATION_RAM_SIZE MBED_RAM_SIZE -#endif +/* Configured IRAM1 start/size */ +#if !defined(MBED_CONFIGURED_RAM_BANK_IRAM1_START) +#define MBED_CONFIGURED_RAM_BANK_IRAM1_START MBED_RAM_BANK_IRAM1_START #endif - -#ifndef MBED_APP_START -#define MBED_APP_START APPLICATION_ADDR -#endif - -#ifndef MBED_APP_SIZE -#define MBED_APP_SIZE APPLICATION_SIZE -#endif - -#ifndef MBED_RAM_APP_START -#define MBED_RAM_APP_START APPLICATION_RAM_ADDR -#endif - -#ifndef MBED_RAM_APP_SIZE -#define MBED_RAM_APP_SIZE APPLICATION_RAM_SIZE -#endif - -#if (APPLICATION_ADDR != MBED_APP_START) -#error("APPLICATION_ADDR and MBED_APP_START are not the same!!!") -#endif - -#if (APPLICATION_SIZE != MBED_APP_SIZE) -#error("APPLICATION_SIZE and MBED_APP_SIZE are not the same!!!") -#endif - -#if (APPLICATION_RAM_ADDR != MBED_RAM_APP_START) -#error("APPLICATION_RAM_ADDR and MBED_RAM_APP_START are not the same!!!") -#endif - -#if (APPLICATION_RAM_SIZE != MBED_RAM_APP_SIZE) -#error("APPLICATION_RAM_SIZE and MBED_RAM_APP_SIZE are not the same!!!") +#if !defined(MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE) +#define MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE MBED_RAM_BANK_IRAM1_SIZE #endif #endif /* __M480_MEM_H__ */ diff --git a/targets/TARGET_NUVOTON/TARGET_M480/device/M480_mem.icf.h b/targets/TARGET_NUVOTON/TARGET_M480/device/M480_mem.icf.h deleted file mode 100644 index a7fd49e4a71..00000000000 --- a/targets/TARGET_NUVOTON/TARGET_M480/device/M480_mem.icf.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2020, Nuvoton Technology Corporation - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* See M480_mem.h for documentation */ - -/* Default memory specification - * - * Flash size: 512KiB - * SRAM size: 160KiB = 128KiB + 32KiB (SPIM CCM) - */ - -/* Resolve ROM start */ -if (!isdefinedsymbol(MBED_ROM_START)) { - define symbol MBED_ROM_START = 0x0; -} - -/* Resolve ROM size */ -if (!isdefinedsymbol(MBED_ROM_SIZE)) { - define symbol MBED_ROM_SIZE = 0x80000; -} - -/* Resolve RAM start */ -if (!isdefinedsymbol(MBED_RAM_START)) { - define symbol MBED_RAM_START = 0x20000000; -} - -/* Resolve RAM size */ -if (!isdefinedsymbol(MBED_RAM_SIZE)) { - define symbol MBED_RAM_SIZE = 0x28000; -} - -/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just - * MBED_APP_xxx macros to linker files even though they mean the same thing. - * Because this file is to include by both C/C++ files and linker files, we add - * these macros according to the others for consistency when they are missing - * in compile or link stage. */ - -if (!isdefinedsymbol(APPLICATION_ADDR)) { - if (isdefinedsymbol(MBED_APP_START)) { - define symbol APPLICATION_ADDR = MBED_APP_START; - } else { - define symbol APPLICATION_ADDR = MBED_ROM_START; - } -} - -if (!isdefinedsymbol(APPLICATION_SIZE)) { - if (isdefinedsymbol(MBED_APP_SIZE)) { - define symbol APPLICATION_SIZE = MBED_APP_SIZE; - } else { - define symbol APPLICATION_SIZE = MBED_ROM_SIZE; - } -} - -if (!isdefinedsymbol(APPLICATION_RAM_ADDR)) { - if (isdefinedsymbol(MBED_RAM_APP_START)) { - define symbol APPLICATION_RAM_ADDR = MBED_RAM_APP_START; - } else { - define symbol APPLICATION_RAM_ADDR = MBED_RAM_START; - } -} - -if (!isdefinedsymbol(APPLICATION_RAM_SIZE)) { - if (isdefinedsymbol(MBED_RAM_APP_SIZE)) { - define symbol APPLICATION_RAM_SIZE = MBED_RAM_APP_SIZE; - } else { - define symbol APPLICATION_RAM_SIZE = MBED_RAM_SIZE; - } -} - -if (!isdefinedsymbol(MBED_APP_START)) { - define symbol MBED_APP_START = APPLICATION_ADDR; -} - -if (!isdefinedsymbol(MBED_APP_SIZE)) { - define symbol MBED_APP_SIZE = APPLICATION_SIZE; -} - -if (!isdefinedsymbol(MBED_RAM_APP_START)) { - define symbol MBED_RAM_APP_START = APPLICATION_RAM_ADDR; -} - -if (!isdefinedsymbol(MBED_RAM_APP_SIZE)) { - define symbol MBED_RAM_APP_SIZE = APPLICATION_RAM_SIZE; -} - -if (APPLICATION_ADDR != MBED_APP_START) { - error "APPLICATION_ADDR and MBED_APP_START are not the same!!!"; -} - -if (APPLICATION_SIZE != MBED_APP_SIZE) { - error "APPLICATION_SIZE and MBED_APP_SIZE are not the same!!!"; -} - -if (APPLICATION_RAM_ADDR != MBED_RAM_APP_START) { - error "APPLICATION_RAM_ADDR and MBED_RAM_APP_START are not the same!!!"; -} - -if (APPLICATION_RAM_SIZE != MBED_RAM_APP_SIZE) { - error "APPLICATION_RAM_SIZE and MBED_RAM_APP_SIZE are not the same!!!"; -} diff --git a/targets/TARGET_NUVOTON/TARGET_M480/device/TOOLCHAIN_GCC_ARM/M487.ld b/targets/TARGET_NUVOTON/TARGET_M480/device/TOOLCHAIN_GCC_ARM/M487.ld index 5e941482ba5..8134c8bb350 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/device/TOOLCHAIN_GCC_ARM/M487.ld +++ b/targets/TARGET_NUVOTON/TARGET_M480/device/TOOLCHAIN_GCC_ARM/M487.ld @@ -35,9 +35,9 @@ StackSize = MBED_CONF_TARGET_BOOT_STACK_SIZE; MEMORY { - VECTORS (rx) : ORIGIN = MBED_APP_START, LENGTH = 0x00000400 - FLASH (rx) : ORIGIN = MBED_APP_START + 0x400, LENGTH = MBED_APP_SIZE - 0x00000400 - RAM_INTERN (rwx) : ORIGIN = MBED_RAM_APP_START, LENGTH = MBED_RAM_APP_SIZE + VECTORS (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START, LENGTH = 0x00000400 + FLASH (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START + 0x400, LENGTH = MBED_CONFIGURED_ROM_BANK_IROM1_SIZE - 0x00000400 + RAM_INTERN (rwx) : ORIGIN = MBED_CONFIGURED_RAM_BANK_IRAM1_START, LENGTH = MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE } /** diff --git a/targets/TARGET_NUVOTON/TARGET_M480/flash_api.c b/targets/TARGET_NUVOTON/TARGET_M480/flash_api.c index fc6d20c3887..aabcb0cbe2c 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/flash_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M480/flash_api.c @@ -68,14 +68,14 @@ static const flash_algo_t flash_algo_config = { }; static const sector_info_t sectors_info[] = { - {MBED_ROM_START, 0x1000}, // (start, sector size) + {MBED_ROM_BANK_IROM1_START, 0x1000}, // (start, sector size) }; static const flash_target_config_t flash_target_config = { .page_size = 4, // 4 bytes // Here page_size is program unit, which is different than FMC definition. - .flash_start = MBED_ROM_START, - .flash_size = MBED_ROM_SIZE, + .flash_start = MBED_ROM_BANK_IROM1_START, + .flash_size = MBED_ROM_BANK_IROM1_SIZE, .sectors = sectors_info, .sector_info_count = sizeof(sectors_info) / sizeof(sector_info_t) }; diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/NANO100_mem.h b/targets/TARGET_NUVOTON/TARGET_NANO100/device/NANO100_mem.h index 7f658ade1ff..f4bb97eb11d 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/NANO100_mem.h +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device/NANO100_mem.h @@ -19,115 +19,42 @@ #ifndef __NANO100_MEM_H__ #define __NANO100_MEM_H__ -/* About NANO100_mem.h/NANO100_mem.icf.h - * - * 1. NANO100_mem.h is created for centralizing memory configuration. It will be included by C/C++ files - * and linker files (except IAR linker file). - * 2. IAR linker doesn't support preprocessor, so NANO100_mem.icf.h, duplicate of NANO100_mem.h - * is created for IAR linker file. - * 3. To continue above, we name NANO100_mem.icf.h instead of NANO100_mem.icf because: - * (1) Mbed OS build tool may mis-regard NANO100_mem.icf as the main linker configuration file. - * (2) *.icf files may not be present in search directories for "include" directive. Per observation, - * the search directories are inconsistent among normal example build and test code build. To address - * it, we name NANO100_mem.icf.h instead because *.h files are always present in these builds - * (already there or via copy). - */ - /* Default memory specification * * Flash size: 128KiB * SRAM size: 16KiB */ -/* Resolve ROM start */ -#ifndef MBED_ROM_START -#define MBED_ROM_START (0x0) -#endif - -/* Resolve ROM size */ -#ifndef MBED_ROM_SIZE -#define MBED_ROM_SIZE (0x20000) -#endif - -/* Resolve RAM start */ -#ifndef MBED_RAM_START -#define MBED_RAM_START (0x20000000) -#endif - -/* Resolve RAM size */ -#ifndef MBED_RAM_SIZE -#define MBED_RAM_SIZE (0x4000) -#endif - - -/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just - * MBED_APP_xxx macros to linker files even though they mean the same thing. - * Because this file is to include by both C/C++ files and linker files, we add - * these macros according to the others for consistency when they are missing - * in compile or link stage. */ - -#ifndef APPLICATION_ADDR -#ifdef MBED_APP_START -#define APPLICATION_ADDR MBED_APP_START -#else -#define APPLICATION_ADDR MBED_ROM_START -#endif +/* Physical IROM1 start/size */ +#if !defined(MBED_ROM_BANK_IROM1_START) +#define MBED_ROM_BANK_IROM1_START 0x0 #endif +#if !defined(MBED_ROM_BANK_IROM1_SIZE) +#define MBED_ROM_BANK_IROM1_SIZE 0x20000 +#endif -#ifndef APPLICATION_SIZE -#ifdef MBED_APP_SIZE -#define APPLICATION_SIZE MBED_APP_SIZE -#else -#define APPLICATION_SIZE MBED_ROM_SIZE +/* Physical IRAM1 start/size */ +#if !defined(MBED_RAM_BANK_IRAM1_START) +#define MBED_RAM_BANK_IRAM1_START 0x20000000 #endif +#if !defined(MBED_RAM_BANK_IRAM1_SIZE) +#define MBED_RAM_BANK_IRAM1_SIZE 0x4000 #endif -#ifndef APPLICATION_RAM_ADDR -#ifdef MBED_RAM_APP_START -#define APPLICATION_RAM_ADDR MBED_RAM_APP_START -#else -#define APPLICATION_RAM_ADDR MBED_RAM_START -#endif +/* Configured IROM1 start/size */ +#if !defined(MBED_CONFIGURED_ROM_BANK_IROM1_START) +#define MBED_CONFIGURED_ROM_BANK_IROM1_START MBED_ROM_BANK_IROM1_START #endif +#if !defined(MBED_CONFIGURED_ROM_BANK_IROM1_SIZE) +#define MBED_CONFIGURED_ROM_BANK_IROM1_SIZE MBED_ROM_BANK_IROM1_SIZE +#endif -#ifndef APPLICATION_RAM_SIZE -#ifdef MBED_RAM_APP_SIZE -#define APPLICATION_RAM_SIZE MBED_RAM_APP_SIZE -#else -#define APPLICATION_RAM_SIZE MBED_RAM_SIZE -#endif +/* Configured IRAM1 start/size */ +#if !defined(MBED_CONFIGURED_RAM_BANK_IRAM1_START) +#define MBED_CONFIGURED_RAM_BANK_IRAM1_START MBED_RAM_BANK_IRAM1_START #endif - -#ifndef MBED_APP_START -#define MBED_APP_START APPLICATION_ADDR -#endif - -#ifndef MBED_APP_SIZE -#define MBED_APP_SIZE APPLICATION_SIZE -#endif - -#ifndef MBED_RAM_APP_START -#define MBED_RAM_APP_START APPLICATION_RAM_ADDR -#endif - -#ifndef MBED_RAM_APP_SIZE -#define MBED_RAM_APP_SIZE APPLICATION_RAM_SIZE -#endif - -#if (APPLICATION_ADDR != MBED_APP_START) -#error("APPLICATION_ADDR and MBED_APP_START are not the same!!!") -#endif - -#if (APPLICATION_SIZE != MBED_APP_SIZE) -#error("APPLICATION_SIZE and MBED_APP_SIZE are not the same!!!") -#endif - -#if (APPLICATION_RAM_ADDR != MBED_RAM_APP_START) -#error("APPLICATION_RAM_ADDR and MBED_RAM_APP_START are not the same!!!") -#endif - -#if (APPLICATION_RAM_SIZE != MBED_RAM_APP_SIZE) -#error("APPLICATION_RAM_SIZE and MBED_RAM_APP_SIZE are not the same!!!") +#if !defined(MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE) +#define MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE MBED_RAM_BANK_IRAM1_SIZE #endif #endif /* __NANO100_MEM_H__ */ diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/NANO100_mem.icf.h b/targets/TARGET_NUVOTON/TARGET_NANO100/device/NANO100_mem.icf.h deleted file mode 100644 index 6b14f62cfc5..00000000000 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/NANO100_mem.icf.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2020, Nuvoton Technology Corporation - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* See NANO100_mem.h for documentation */ - -/* Default memory specification - * - * Flash size: 128KiB - * SRAM size: 16KiB - */ - -/* Resolve ROM start */ -if (!isdefinedsymbol(MBED_ROM_START)) { - define symbol MBED_ROM_START = 0x0; -} - -/* Resolve ROM size */ -if (!isdefinedsymbol(MBED_ROM_SIZE)) { - define symbol MBED_ROM_SIZE = 0x20000; -} - -/* Resolve RAM start */ -if (!isdefinedsymbol(MBED_RAM_START)) { - define symbol MBED_RAM_START = 0x20000000; -} - -/* Resolve RAM size */ -if (!isdefinedsymbol(MBED_RAM_SIZE)) { - define symbol MBED_RAM_SIZE = 0x4000; -} - -/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just - * MBED_APP_xxx macros to linker files even though they mean the same thing. - * Because this file is to include by both C/C++ files and linker files, we add - * these macros according to the others for consistency when they are missing - * in compile or link stage. */ - -if (!isdefinedsymbol(APPLICATION_ADDR)) { - if (isdefinedsymbol(MBED_APP_START)) { - define symbol APPLICATION_ADDR = MBED_APP_START; - } else { - define symbol APPLICATION_ADDR = MBED_ROM_START; - } -} - -if (!isdefinedsymbol(APPLICATION_SIZE)) { - if (isdefinedsymbol(MBED_APP_SIZE)) { - define symbol APPLICATION_SIZE = MBED_APP_SIZE; - } else { - define symbol APPLICATION_SIZE = MBED_ROM_SIZE; - } -} - -if (!isdefinedsymbol(APPLICATION_RAM_ADDR)) { - if (isdefinedsymbol(MBED_RAM_APP_START)) { - define symbol APPLICATION_RAM_ADDR = MBED_RAM_APP_START; - } else { - define symbol APPLICATION_RAM_ADDR = MBED_RAM_START; - } -} - -if (!isdefinedsymbol(APPLICATION_RAM_SIZE)) { - if (isdefinedsymbol(MBED_RAM_APP_SIZE)) { - define symbol APPLICATION_RAM_SIZE = MBED_RAM_APP_SIZE; - } else { - define symbol APPLICATION_RAM_SIZE = MBED_RAM_SIZE; - } -} - -if (!isdefinedsymbol(MBED_APP_START)) { - define symbol MBED_APP_START = APPLICATION_ADDR; -} - -if (!isdefinedsymbol(MBED_APP_SIZE)) { - define symbol MBED_APP_SIZE = APPLICATION_SIZE; -} - -if (!isdefinedsymbol(MBED_RAM_APP_START)) { - define symbol MBED_RAM_APP_START = APPLICATION_RAM_ADDR; -} - -if (!isdefinedsymbol(MBED_RAM_APP_SIZE)) { - define symbol MBED_RAM_APP_SIZE = APPLICATION_RAM_SIZE; -} - -if (APPLICATION_ADDR != MBED_APP_START) { - error "APPLICATION_ADDR and MBED_APP_START are not the same!!!"; -} - -if (APPLICATION_SIZE != MBED_APP_SIZE) { - error "APPLICATION_SIZE and MBED_APP_SIZE are not the same!!!"; -} - -if (APPLICATION_RAM_ADDR != MBED_RAM_APP_START) { - error "APPLICATION_RAM_ADDR and MBED_RAM_APP_START are not the same!!!"; -} - -if (APPLICATION_RAM_SIZE != MBED_RAM_APP_SIZE) { - error "APPLICATION_RAM_SIZE and MBED_RAM_APP_SIZE are not the same!!!"; -} diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/TOOLCHAIN_GCC_ARM/NANO130.ld b/targets/TARGET_NUVOTON/TARGET_NANO100/device/TOOLCHAIN_GCC_ARM/NANO130.ld index ef96198d307..554fe58e7b6 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/TOOLCHAIN_GCC_ARM/NANO130.ld +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device/TOOLCHAIN_GCC_ARM/NANO130.ld @@ -34,9 +34,9 @@ StackSize = MBED_CONF_TARGET_BOOT_STACK_SIZE; MEMORY { - VECTORS (rx) : ORIGIN = MBED_APP_START, LENGTH = 0x400 - FLASH (rx) : ORIGIN = MBED_APP_START + 0x400, LENGTH = MBED_APP_SIZE - 0x400 - RAM_INTERN (rwx) : ORIGIN = MBED_RAM_APP_START, LENGTH = MBED_RAM_APP_SIZE + VECTORS (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START, LENGTH = 0x400 + FLASH (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START + 0x400, LENGTH = MBED_CONFIGURED_ROM_BANK_IROM1_SIZE - 0x400 + RAM_INTERN (rwx) : ORIGIN = MBED_CONFIGURED_RAM_BANK_IRAM1_START, LENGTH = MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE } /** diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/NUC472_mem.h b/targets/TARGET_NUVOTON/TARGET_NUC472/device/NUC472_mem.h new file mode 100644 index 00000000000..5129b27babe --- /dev/null +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/NUC472_mem.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2022, Nuvoton Technology Corporation + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __NUC472_MEM_H__ +#define __NUC472_MEM_H__ + +/* Default memory specification + * + * Flash size: 512KiB + * SRAM size: 64KiB + */ + +/* Physical IROM1 start/size */ +#if !defined(MBED_ROM_BANK_IROM1_START) +#define MBED_ROM_BANK_IROM1_START 0x0 +#endif +#if !defined(MBED_ROM_BANK_IROM1_SIZE) +#define MBED_ROM_BANK_IROM1_SIZE 0x80000 +#endif + +/* Physical IRAM1 start/size */ +#if !defined(MBED_RAM_BANK_IRAM1_START) +#define MBED_RAM_BANK_IRAM1_START 0x20000000 +#endif +#if !defined(MBED_RAM_BANK_IRAM1_SIZE) +#define MBED_RAM_BANK_IRAM1_SIZE 0x10000 +#endif + +/* Configured IROM1 start/size */ +#if !defined(MBED_CONFIGURED_ROM_BANK_IROM1_START) +#define MBED_CONFIGURED_ROM_BANK_IROM1_START MBED_ROM_BANK_IROM1_START +#endif +#if !defined(MBED_CONFIGURED_ROM_BANK_IROM1_SIZE) +#define MBED_CONFIGURED_ROM_BANK_IROM1_SIZE MBED_ROM_BANK_IROM1_SIZE +#endif + +/* Configured IRAM1 start/size */ +#if !defined(MBED_CONFIGURED_RAM_BANK_IRAM1_START) +#define MBED_CONFIGURED_RAM_BANK_IRAM1_START MBED_RAM_BANK_IRAM1_START +#endif +#if !defined(MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE) +#define MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE MBED_RAM_BANK_IRAM1_SIZE +#endif + +/* Physical XRAM1 start/size */ +#if !defined(MBED_RAM_BANK_XRAM1_START) +#define MBED_RAM_BANK_XRAM1_START 0x60000000 +#endif +#if !defined(MBED_RAM_BANK_XRAM1_SIZE) +#define MBED_RAM_BANK_XRAM1_SIZE 0x100000 +#endif + +/* Configured XRAM1 start/size */ +#if !defined(MBED_CONFIGURED_RAM_BANK_XRAM1_START) +#define MBED_CONFIGURED_RAM_BANK_XRAM1_START MBED_RAM_BANK_XRAM1_START +#endif +#if !defined(MBED_CONFIGURED_RAM_BANK_XRAM1_SIZE) +#define MBED_CONFIGURED_RAM_BANK_XRAM1_SIZE MBED_RAM_BANK_XRAM1_SIZE +#endif + +#endif /* __NUC472_MEM_H__ */ diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/TOOLCHAIN_GCC_ARM/TARGET_NU_XRAM_SUPPORTED/NUC472.ld b/targets/TARGET_NUVOTON/TARGET_NUC472/device/TOOLCHAIN_GCC_ARM/TARGET_NU_XRAM_SUPPORTED/NUC472.ld index 043c8113952..e020ad70879 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/TOOLCHAIN_GCC_ARM/TARGET_NU_XRAM_SUPPORTED/NUC472.ld +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/TOOLCHAIN_GCC_ARM/TARGET_NU_XRAM_SUPPORTED/NUC472.ld @@ -2,13 +2,7 @@ * Nuvoton NUC472 GCC linker script file */ -#if !defined(MBED_APP_START) - #define MBED_APP_START 0x00000000 -#endif - -#if !defined(MBED_APP_SIZE) - #define MBED_APP_SIZE 0x00080000 -#endif +#include "../../NUC472_mem.h" #if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE) # if defined(MBED_BOOT_STACK_SIZE) @@ -24,10 +18,10 @@ StackSize = MBED_CONF_TARGET_BOOT_STACK_SIZE; MEMORY { - VECTORS (rx) : ORIGIN = MBED_APP_START, LENGTH = 0x00000400 - FLASH (rx) : ORIGIN = MBED_APP_START + 0x400, LENGTH = MBED_APP_SIZE - 0x00000400 - RAM_INTERN (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00010000 - 0x00000000 - RAM_EXTERN (rwx) : ORIGIN = 0x60000000, LENGTH = 0x00100000 + VECTORS (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START, LENGTH = 0x00000400 + FLASH (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START + 0x400, LENGTH = MBED_CONFIGURED_ROM_BANK_IROM1_SIZE - 0x00000400 + RAM_INTERN (rwx) : ORIGIN = MBED_CONFIGURED_RAM_BANK_IRAM1_START, LENGTH = MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE + RAM_EXTERN (rwx) : ORIGIN = MBED_CONFIGURED_RAM_BANK_XRAM1_START, LENGTH = MBED_CONFIGURED_RAM_BANK_XRAM1_SIZE } /** diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/TOOLCHAIN_GCC_ARM/TARGET_NU_XRAM_UNSUPPORTED/NUC472.ld b/targets/TARGET_NUVOTON/TARGET_NUC472/device/TOOLCHAIN_GCC_ARM/TARGET_NU_XRAM_UNSUPPORTED/NUC472.ld index c69d3f0635f..e80d6a387dc 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/TOOLCHAIN_GCC_ARM/TARGET_NU_XRAM_UNSUPPORTED/NUC472.ld +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/TOOLCHAIN_GCC_ARM/TARGET_NU_XRAM_UNSUPPORTED/NUC472.ld @@ -2,13 +2,7 @@ * Nuvoton NUC472 GCC linker script file */ -#if !defined(MBED_APP_START) - #define MBED_APP_START 0x00000000 -#endif - -#if !defined(MBED_APP_SIZE) - #define MBED_APP_SIZE 0x00080000 -#endif +#include "../../NUC472_mem.h" #if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE) # if defined(MBED_BOOT_STACK_SIZE) @@ -24,9 +18,9 @@ StackSize = MBED_CONF_TARGET_BOOT_STACK_SIZE; MEMORY { - VECTORS (rx) : ORIGIN = MBED_APP_START, LENGTH = 0x00000400 - FLASH (rx) : ORIGIN = MBED_APP_START + 0x400, LENGTH = MBED_APP_SIZE - 0x00000400 - RAM_INTERN (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00010000 - 0x00000000 + VECTORS (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START, LENGTH = 0x00000400 + FLASH (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START + 0x400, LENGTH = MBED_CONFIGURED_ROM_BANK_IROM1_SIZE - 0x00000400 + RAM_INTERN (rwx) : ORIGIN = MBED_CONFIGURED_RAM_BANK_IRAM1_START, LENGTH = MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE } /** diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/flash_api.c b/targets/TARGET_NUVOTON/TARGET_NUC472/flash_api.c index f39fefbb9c4..74edba442a1 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/flash_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/flash_api.c @@ -18,6 +18,7 @@ #include "flash_api.h" #include "flash_data.h" #include "mbed_critical.h" +#include "NUC472_mem.h" // This is a flash algo binary blob. It is PIC (position independent code) that should be stored in RAM // NOTE: On ARMv7-M/ARMv8-M, instruction fetches are always little-endian. @@ -64,14 +65,14 @@ static const flash_algo_t flash_algo_config = { }; static const sector_info_t sectors_info[] = { - {0x0, 0x800}, // (start, sector size) + {MBED_ROM_BANK_IROM1_START, 0x800}, }; static const flash_target_config_t flash_target_config = { .page_size = 4, // 4 bytes // Here page_size is program unit, which is different than FMC definition. - .flash_start = 0x0, - .flash_size = 0x80000, // 512 KB + .flash_start = MBED_ROM_BANK_IROM1_START, + .flash_size = MBED_ROM_BANK_IROM1_SIZE, .sectors = sectors_info, .sector_info_count = sizeof(sectors_info) / sizeof(sector_info_t) }; diff --git a/targets/targets.json5 b/targets/targets.json5 index 56bdb74d7a4..66403f664d7 100644 --- a/targets/targets.json5 +++ b/targets/targets.json5 @@ -8203,6 +8203,34 @@ "usb-uart-tx": "PA_7", "usb-uart-rx": "PA_6" }, + "memory_banks": { + "NS_CODE": { + "access": { + "execute": true, + "peripheral": false, + "read": true, + "secure": false, + "write": false + }, + "default": false, + "size": 0x8D000, + "start": 0x10071000, + "startup": false + }, + "NS_DATA": { + "access": { + "execute": false, + "peripheral": false, + "read": true, + "secure": false, + "write": true + }, + "default": false, + "size": 0x28000, + "start": 0x30018000, + "startup": false + } + }, "OUTPUT_EXT": "bin", "components_add": [ "TFM_S_FW"