From c8271661155f7545a1a66cb342cfb2f01f739f94 Mon Sep 17 00:00:00 2001 From: Chun-Chieh Li Date: Mon, 7 Oct 2024 16:42:53 +0800 Subject: [PATCH] Nuvoton: Migrate to new style memory bank information Change memory bank symbols: 1. MBED_APP_START/SIZE -> MBED_CONFIGURED_ROM_BANK_IROM1_START/SIZE 2. MBED_RAM_APP_START/SIZE -> MBED_CONFIGURED_RAM_BANK_IRAM1_START/SIZE 3. APPLICATION_ADDR/SIZE -> MBED_CONFIGURED_ROM_BANK_IROM1_START/SIZE 4. APPLICATION_RAM_ADDR/SIZE -> MBED_CONFIGURED_RAM_BANK_IRAM1_START/SIZE 5. -> MBED_CONFIGURED_RAM_BANK_XRAM1_START/SIZE NOTE: Specific to NUC472 6. NU_HYPERRAM_START/SIZE -> MBED_CONFIGURED_RAM_BANK_HYPERRAM1_START/SIZE NOTE: Specific to M467 --- .../device/TOOLCHAIN_GCC_ARM/M2354.ld | 6 +- .../TARGET_M2354/device/partition_M2354_mem.h | 126 ++++-------------- .../TARGET_M251/device/M251_mem.h | 117 +++------------- .../device/TOOLCHAIN_GCC_ARM/M251.ld | 6 +- .../TARGET_NUVOTON/TARGET_M251/flash_api.c | 6 +- .../TARGET_M261/device/M261_mem.h | 117 +++------------- .../device/TOOLCHAIN_GCC_ARM/M261.ld | 6 +- .../TARGET_NUVOTON/TARGET_M261/flash_api.c | 6 +- .../TARGET_M451/device/M451_mem.h | 117 +++------------- .../device/TOOLCHAIN_GCC_ARM/M453.ld | 6 +- .../TARGET_NUVOTON/TARGET_M451/flash_api.c | 6 +- .../TARGET_M460/device/M460_mem.h | 121 +++++------------ .../device/TOOLCHAIN_GCC_ARM/M467.ld | 16 +-- .../TARGET_NUVOTON/TARGET_M460/flash_api.c | 6 +- .../TARGET_M480/device/M480_mem.h | 117 +++------------- .../device/TOOLCHAIN_GCC_ARM/M487.ld | 6 +- .../TARGET_NUVOTON/TARGET_M480/flash_api.c | 6 +- .../TARGET_NANO100/device/NANO100_mem.h | 117 +++------------- .../device/TOOLCHAIN_GCC_ARM/NANO130.ld | 6 +- .../TARGET_NUC472/device/NUC472_mem.h | 76 +++++++++++ .../TARGET_NU_XRAM_SUPPORTED/NUC472.ld | 16 +-- .../TARGET_NU_XRAM_UNSUPPORTED/NUC472.ld | 14 +- .../TARGET_NUVOTON/TARGET_NUC472/flash_api.c | 7 +- 23 files changed, 293 insertions(+), 734 deletions(-) create mode 100644 targets/TARGET_NUVOTON/TARGET_NUC472/device/NUC472_mem.h 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..0f61ffa66a1 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_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 } /** 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..8668fdaa9ad 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,37 @@ #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_IROM1_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_IROM1_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 -#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 -#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!!!") -#endif +/* Physical IROM1 start/size */ +#undef MBED_ROM_BANK_IROM1_START +#define MBED_ROM_BANK_IROM1_START NS_CODE_START +#undef MBED_ROM_BANK_IROM1_SIZE +#define MBED_ROM_BANK_IROM1_SIZE NS_CODE_SIZE + +/* Physical IRAM1 start/size */ +#undef MBED_RAM_BANK_IRAM1_START +#define MBED_RAM_BANK_IRAM1_START NS_DATA_START +#undef MBED_RAM_BANK_IRAM1_SIZE +#define MBED_RAM_BANK_IRAM1_SIZE NS_DATA_SIZE + +/* Configured IROM1 start/size */ +#undef MBED_CONFIGURED_ROM_BANK_IROM1_START +#define MBED_CONFIGURED_ROM_BANK_IROM1_START MBED_ROM_BANK_IROM1_START +#undef MBED_CONFIGURED_ROM_BANK_IROM1_SIZE +#define MBED_CONFIGURED_ROM_BANK_IROM1_SIZE MBED_ROM_BANK_IROM1_SIZE + +/* Configured IRAM1 start/size */ +#undef MBED_CONFIGURED_RAM_BANK_IRAM1_START +#define MBED_CONFIGURED_RAM_BANK_IRAM1_START MBED_RAM_BANK_IRAM1_START +#undef MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE +#define MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE MBED_RAM_BANK_IRAM1_SIZE #endif /* __PARTITION_M2354_MEM_H__ */ 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/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/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/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/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/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/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) };