diff --git a/targets/TARGET_NUVOTON/TARGET_M2351/device/TOOLCHAIN_ARM_MICRO/M2351.sct b/targets/TARGET_NUVOTON/TARGET_M2351/device/TOOLCHAIN_ARMC6/M2351.sct similarity index 74% rename from targets/TARGET_NUVOTON/TARGET_M2351/device/TOOLCHAIN_ARM_MICRO/M2351.sct rename to targets/TARGET_NUVOTON/TARGET_M2351/device/TOOLCHAIN_ARMC6/M2351.sct index 71332995ea..4d1cf89bf8 100644 --- a/targets/TARGET_NUVOTON/TARGET_M2351/device/TOOLCHAIN_ARM_MICRO/M2351.sct +++ b/targets/TARGET_NUVOTON/TARGET_M2351/device/TOOLCHAIN_ARMC6/M2351.sct @@ -1,23 +1,24 @@ -#! armcc -E +#! armclang -E -/* Default flash/SRAM partition +/* + * Copyright (c) 2019-2020, Nuvoton Technology Corporation * - * Default flash partition: - * Secure: 256KiB - * Non-secure: 256KiB - * - * Default SRAM partition: - * Secure: 32KiB - * Non-secure: 64KiB + * 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 MBED_ROM_SIZE_S -#define MBED_ROM_SIZE_S (0x40000) -#endif - -#ifndef MBED_RAM_SIZE_S -#define MBED_RAM_SIZE_S (0x8000) -#endif +#include "../partition_M2351_mem.h" #ifndef NU_TZ_NSC_SIZE #define NU_TZ_NSC_SIZE (0x1000) @@ -26,19 +27,19 @@ #if defined(DOMAIN_NS) && DOMAIN_NS #ifndef MBED_APP_START -#define MBED_APP_START (0x10000000 + MBED_ROM_START + MBED_ROM_SIZE_S) +#define MBED_APP_START NU_ROM_START_NS #endif #ifndef MBED_APP_SIZE -#define MBED_APP_SIZE (MBED_ROM_SIZE - MBED_ROM_SIZE_S) +#define MBED_APP_SIZE NU_ROM_SIZE_NS #endif #ifndef MBED_RAM_APP_START -#define MBED_RAM_APP_START (0x10000000 + MBED_RAM_START + MBED_RAM_SIZE_S) +#define MBED_RAM_APP_START NU_RAM_START_NS #endif #ifndef MBED_RAM_APP_SIZE -#define MBED_RAM_APP_SIZE (MBED_RAM_SIZE - MBED_RAM_SIZE_S) +#define MBED_RAM_APP_SIZE NU_RAM_SIZE_NS #endif #if !defined(MBED_BOOT_STACK_SIZE) @@ -48,19 +49,19 @@ #else #ifndef MBED_APP_START -#define MBED_APP_START MBED_ROM_START +#define MBED_APP_START NU_ROM_START_S #endif #ifndef MBED_APP_SIZE -#define MBED_APP_SIZE MBED_ROM_SIZE_S +#define MBED_APP_SIZE NU_ROM_SIZE_S #endif #ifndef MBED_RAM_APP_START -#define MBED_RAM_APP_START MBED_RAM_START +#define MBED_RAM_APP_START NU_RAM_START_S #endif #ifndef MBED_RAM_APP_SIZE -#define MBED_RAM_APP_SIZE MBED_RAM_SIZE_S +#define MBED_RAM_APP_SIZE NU_RAM_SIZE_S #endif #if !defined(MBED_BOOT_STACK_SIZE) diff --git a/targets/TARGET_NUVOTON/TARGET_M2351/device/TOOLCHAIN_ARM_STD/M2351.sct b/targets/TARGET_NUVOTON/TARGET_M2351/device/TOOLCHAIN_ARM_STD/M2351.sct deleted file mode 100644 index 71332995ea..0000000000 --- a/targets/TARGET_NUVOTON/TARGET_M2351/device/TOOLCHAIN_ARM_STD/M2351.sct +++ /dev/null @@ -1,172 +0,0 @@ -#! armcc -E - -/* Default flash/SRAM partition - * - * Default flash partition: - * Secure: 256KiB - * Non-secure: 256KiB - * - * Default SRAM partition: - * Secure: 32KiB - * Non-secure: 64KiB - */ - -#ifndef MBED_ROM_SIZE_S -#define MBED_ROM_SIZE_S (0x40000) -#endif - -#ifndef MBED_RAM_SIZE_S -#define MBED_RAM_SIZE_S (0x8000) -#endif - -#ifndef NU_TZ_NSC_SIZE -#define NU_TZ_NSC_SIZE (0x1000) -#endif - -#if defined(DOMAIN_NS) && DOMAIN_NS - -#ifndef MBED_APP_START -#define MBED_APP_START (0x10000000 + MBED_ROM_START + MBED_ROM_SIZE_S) -#endif - -#ifndef MBED_APP_SIZE -#define MBED_APP_SIZE (MBED_ROM_SIZE - MBED_ROM_SIZE_S) -#endif - -#ifndef MBED_RAM_APP_START -#define MBED_RAM_APP_START (0x10000000 + MBED_RAM_START + MBED_RAM_SIZE_S) -#endif - -#ifndef MBED_RAM_APP_SIZE -#define MBED_RAM_APP_SIZE (MBED_RAM_SIZE - MBED_RAM_SIZE_S) -#endif - -#if !defined(MBED_BOOT_STACK_SIZE) -#define MBED_BOOT_STACK_SIZE 0x400 -#endif - -#else - -#ifndef MBED_APP_START -#define MBED_APP_START MBED_ROM_START -#endif - -#ifndef MBED_APP_SIZE -#define MBED_APP_SIZE MBED_ROM_SIZE_S -#endif - -#ifndef MBED_RAM_APP_START -#define MBED_RAM_APP_START MBED_RAM_START -#endif - -#ifndef MBED_RAM_APP_SIZE -#define MBED_RAM_APP_SIZE MBED_RAM_SIZE_S -#endif - -#if !defined(MBED_BOOT_STACK_SIZE) -#define MBED_BOOT_STACK_SIZE 0x400 -#endif - -#endif - -/* Requirements for NSC location - * - * 1. By IDAU, 0~0x4000 is secure. NSC can only locate in 0x4000~0x10000000. - * 2. Greentea flash IAP uses last 4 sectors for its test. Avoid this range. - * 3. Greentea NVSTORE uses last 2 sectors or 4KiB x 2 for its test. Avoid this range. - * 4. NSC region size defaults to 4KiB if not defined. - */ -#define NU_TZ_NSC_START (MBED_APP_START + MBED_APP_SIZE - 0x2000 - NU_TZ_NSC_SIZE) - -#if defined(DOMAIN_NS) && DOMAIN_NS - -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_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 + 102)) - { - } - - /* 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) - -#else - -LR_IROM1 MBED_APP_START -{ - /* load address = execution address */ - ER_IROM1 +0 - { - *(RESET, +First) - *(InRoot$$Sections) - .ANY (+RO) - } - - ARM_LIB_STACK 0x20000000 EMPTY MBED_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 + 102)) - { - } - - /* 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)) - { - } -} - -LR_IROM_NSC NU_TZ_NSC_START NU_TZ_NSC_SIZE -{ - ER_IROM_NSC +0 - { - *(Veneer$$CMSE) - } - - ER_IROM_NSC_PAD +0 FILL 0xFFFFFFFF (NU_TZ_NSC_START + NU_TZ_NSC_SIZE - ImageLimit(ER_IROM_NSC)) - { - } -} - -ScatterAssert(LoadLimit(LR_IROM1) <= NU_TZ_NSC_START) -ScatterAssert(LoadLimit(LR_IROM_NSC) <= (NU_TZ_NSC_START + NU_TZ_NSC_SIZE)) -/* By IDAU, 0~0x4000 is secure. NSC can only locate in 0x4000~0x10000000 */ -ScatterAssert(LoadBase(LR_IROM_NSC) >= 0x4000) -ScatterAssert(ImageLimit(ARM_LIB_HEAP) <= (MBED_RAM_APP_START + MBED_RAM_APP_SIZE)) - -#endif diff --git a/targets/TARGET_NUVOTON/TARGET_M2351/device/TOOLCHAIN_GCC_ARM/M2351.ld b/targets/TARGET_NUVOTON/TARGET_M2351/device/TOOLCHAIN_GCC_ARM/M2351.ld index d1e9d67305..a0efebb5a2 100644 --- a/targets/TARGET_NUVOTON/TARGET_M2351/device/TOOLCHAIN_GCC_ARM/M2351.ld +++ b/targets/TARGET_NUVOTON/TARGET_M2351/device/TOOLCHAIN_GCC_ARM/M2351.ld @@ -1,46 +1,47 @@ +/* + * 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. + */ + /* * Nuvoton M2351 GCC linker script file */ -/* Default flash/SRAM partition - * - * Default flash partition: - * Secure: 256KiB - * Non-secure: 256KiB - * - * Default SRAM partition: - * Secure: 32KiB - * Non-secure: 64KiB - */ - -#ifndef MBED_ROM_SIZE_S -#define MBED_ROM_SIZE_S (0x40000) -#endif - -#ifndef MBED_RAM_SIZE_S -#define MBED_RAM_SIZE_S (0x8000) -#endif +#include "../partition_M2351_mem.h" #ifndef NU_TZ_NSC_SIZE -#define NU_TZ_NSC_SIZE (0x1000) +#define NU_TZ_NSC_SIZE (0x1000) #endif #if defined(DOMAIN_NS) && DOMAIN_NS #ifndef MBED_APP_START -#define MBED_APP_START (0x10000000 + MBED_ROM_START + MBED_ROM_SIZE_S) +#define MBED_APP_START NU_ROM_START_NS #endif #ifndef MBED_APP_SIZE -#define MBED_APP_SIZE (MBED_ROM_SIZE - MBED_ROM_SIZE_S) +#define MBED_APP_SIZE NU_ROM_SIZE_NS #endif #ifndef MBED_RAM_APP_START -#define MBED_RAM_APP_START (0x10000000 + MBED_RAM_START + MBED_RAM_SIZE_S) +#define MBED_RAM_APP_START NU_RAM_START_NS #endif #ifndef MBED_RAM_APP_SIZE -#define MBED_RAM_APP_SIZE (MBED_RAM_SIZE - MBED_RAM_SIZE_S) +#define MBED_RAM_APP_SIZE NU_RAM_SIZE_NS #endif #if !defined(MBED_BOOT_STACK_SIZE) @@ -50,19 +51,19 @@ #else #ifndef MBED_APP_START -#define MBED_APP_START MBED_ROM_START +#define MBED_APP_START NU_ROM_START_S #endif #ifndef MBED_APP_SIZE -#define MBED_APP_SIZE MBED_ROM_SIZE_S +#define MBED_APP_SIZE NU_ROM_SIZE_S #endif #ifndef MBED_RAM_APP_START -#define MBED_RAM_APP_START MBED_RAM_START +#define MBED_RAM_APP_START NU_RAM_START_S #endif #ifndef MBED_RAM_APP_SIZE -#define MBED_RAM_APP_SIZE MBED_RAM_SIZE_S +#define MBED_RAM_APP_SIZE NU_RAM_SIZE_S #endif #ifndef MBED_BOOT_STACK_SIZE diff --git a/targets/TARGET_NUVOTON/TARGET_M2351/device/TOOLCHAIN_IAR/M2351.icf b/targets/TARGET_NUVOTON/TARGET_M2351/device/TOOLCHAIN_IAR/M2351.icf index 6ee617cfa0..66751d29f8 100644 --- a/targets/TARGET_NUVOTON/TARGET_M2351/device/TOOLCHAIN_IAR/M2351.icf +++ b/targets/TARGET_NUVOTON/TARGET_M2351/device/TOOLCHAIN_IAR/M2351.icf @@ -1,36 +1,47 @@ +/* + * 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. + */ + /*###ICF### Section handled by ICF editor, don't touch! ****/ /*-Editor annotation file-*/ /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */ - -if (! isdefinedsymbol(MBED_RAM_SIZE_S)) { - define symbol MBED_RAM_SIZE_S = 0x8000; -} - -if (! isdefinedsymbol(MBED_ROM_SIZE_S)) { - define symbol MBED_ROM_SIZE_S = 0x40000; -} +include "../partition_M2351_mem.icf"; if (! isdefinedsymbol(NU_TZ_NSC_SIZE)) { - define symbol NU_TZ_NSC_SIZE = 0x1000; + define symbol NU_TZ_NSC_SIZE = 0x1000; } if (isdefinedsymbol(DOMAIN_NS)) { if (! isdefinedsymbol(MBED_APP_START)) { - define symbol MBED_APP_START = (0x10000000 + MBED_ROM_START + MBED_ROM_SIZE_S); + define symbol MBED_APP_START = NU_ROM_START_NS; } if (! isdefinedsymbol(MBED_APP_SIZE)) { - define symbol MBED_APP_SIZE = (MBED_ROM_SIZE - MBED_ROM_SIZE_S); + define symbol MBED_APP_SIZE = NU_ROM_SIZE_NS; } if (! isdefinedsymbol(MBED_RAM_APP_START)) { - define symbol MBED_RAM_APP_START = (0x10000000 + MBED_RAM_START + MBED_RAM_SIZE_S); + define symbol MBED_RAM_APP_START = NU_RAM_START_NS; } if (! isdefinedsymbol(MBED_RAM_APP_SIZE)) { - define symbol MBED_RAM_APP_SIZE = (MBED_RAM_SIZE - MBED_RAM_SIZE_S); + define symbol MBED_RAM_APP_SIZE = NU_RAM_SIZE_NS; } if (! isdefinedsymbol(MBED_BOOT_STACK_SIZE)) { @@ -52,19 +63,19 @@ if (isdefinedsymbol(DOMAIN_NS)) { } else { if (! isdefinedsymbol(MBED_APP_START)) { - define symbol MBED_APP_START = MBED_ROM_START; + define symbol MBED_APP_START = NU_ROM_START_S; } if (! isdefinedsymbol(MBED_APP_SIZE)) { - define symbol MBED_APP_SIZE = MBED_ROM_SIZE_S; + define symbol MBED_APP_SIZE = NU_ROM_SIZE_S; } if (! isdefinedsymbol(MBED_RAM_APP_START)) { - define symbol MBED_RAM_APP_START = MBED_RAM_START; + define symbol MBED_RAM_APP_START = NU_RAM_START_S; } if (! isdefinedsymbol(MBED_RAM_APP_SIZE)) { - define symbol MBED_RAM_APP_SIZE = MBED_RAM_SIZE_S; + define symbol MBED_RAM_APP_SIZE = NU_RAM_SIZE_S; } if (! isdefinedsymbol(MBED_BOOT_STACK_SIZE)) { diff --git a/targets/TARGET_NUVOTON/TARGET_M2351/device/partition_M2351.h b/targets/TARGET_NUVOTON/TARGET_M2351/device/partition_M2351.h index c5f62439e9..0f43a786ba 100644 --- a/targets/TARGET_NUVOTON/TARGET_M2351/device/partition_M2351.h +++ b/targets/TARGET_NUVOTON/TARGET_M2351/device/partition_M2351.h @@ -1,26 +1,28 @@ -/**************************************************************************//** - * @file partition_M2351.c - * @version V3.00 - * @brief SAU configuration for secure/nonsecure region settings. +/* + * Copyright (c) 2019-2020, Nuvoton Technology Corporation * - * @note - * Copyright (C) 2016 Nuvoton Technology Corp. All rights reserved. + * 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 PARTITION_M2351 #define PARTITION_M2351 -#ifndef MBED_ROM_SIZE_S -#define MBED_ROM_SIZE_S (0x40000) -#endif +#include "partition_M2351_mem.h" -#ifndef MBED_RAM_SIZE_S -#define MBED_RAM_SIZE_S (0x8000) -#endif - -#define NU_TZ_SECURE_FLASH_SIZE MBED_ROM_SIZE_S -#define NU_TZ_SECURE_SRAM_SIZE MBED_RAM_SIZE_S +#define NU_TZ_SECURE_FLASH_SIZE NU_ROM_SIZE_S +#define NU_TZ_SECURE_SRAM_SIZE NU_RAM_SIZE_S #if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) diff --git a/targets/TARGET_NUVOTON/TARGET_M2351/device/partition_M2351_mem.h b/targets/TARGET_NUVOTON/TARGET_M2351/device/partition_M2351_mem.h new file mode 100644 index 0000000000..39504d30e3 --- /dev/null +++ b/targets/TARGET_NUVOTON/TARGET_M2351/device/partition_M2351_mem.h @@ -0,0 +1,111 @@ +/* + * 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. + */ + +#ifndef __PARTITION_M2351_MEM_H__ +#define __PARTITION_M2351_MEM_H__ + +/* About partition_M2351_mem.h/partition_M2351_mem.icf + * + * 1. partition_M2351_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_M2351_mem.icf, duplicate of partition_M2351_mem.h + * is created for IAR linker file. + */ + +/* Default flash/SRAM partition + * + * Default flash partition: + * Secure: 256KiB + * Non-secure: 256KiB + * + * Default SRAM partition: + * Secure: 32KiB + * Non-secure: 64KiB + */ +#if defined(DOMAIN_NS) && DOMAIN_NS + +/* Default non-secure ROM layout */ +#ifndef MBED_ROM_START +#define MBED_ROM_START (0x10040000) +#endif +#ifndef MBED_ROM_SIZE +#define MBED_ROM_SIZE (0x40000) +#endif +/* Default non-secure RAM layout */ +#ifndef MBED_RAM_START +#define MBED_RAM_START (0x30008000) +#endif +#ifndef MBED_RAM_SIZE +#define MBED_RAM_SIZE (0x10000) +#endif + +#else + +/* Default secure ROM layout */ +#ifndef MBED_ROM_START +#define MBED_ROM_START (0x0) +#endif +#ifndef MBED_ROM_SIZE +#define MBED_ROM_SIZE (0x40000) +#endif +/* Default secure RAM layout */ +#ifndef MBED_RAM_START +#define MBED_RAM_START (0x20000000) +#endif +#ifndef MBED_RAM_SIZE +#define MBED_RAM_SIZE (0x8000) +#endif + +#endif + +/* Resolved flash/SRAM partition */ +#if defined(DOMAIN_NS) && DOMAIN_NS + +/* Resolved secure ROM layout */ +#define NU_ROM_START_S 0x0 +#define NU_ROM_SIZE_S (0x80000 - MBED_ROM_SIZE) +/* Resolved secure RAM layout */ +#define NU_RAM_START_S 0x20000000 +#define NU_RAM_SIZE_S (0x18000 - MBED_RAM_SIZE) + +/* Resolved non-secure ROM layout */ +#define NU_ROM_START_NS MBED_ROM_START +#define NU_ROM_SIZE_NS MBED_ROM_SIZE +/* Resolved non-secure RAM layout */ +#define NU_RAM_START_NS MBED_RAM_START +#define NU_RAM_SIZE_NS MBED_RAM_SIZE + +#else + +/* Resolved secure ROM layout */ +#define NU_ROM_START_S MBED_ROM_START +#define NU_ROM_SIZE_S MBED_ROM_SIZE +/* Resolved secure RAM layout */ +#define NU_RAM_START_S MBED_RAM_START +#define NU_RAM_SIZE_S MBED_RAM_SIZE + +/* Resolved non-secure ROM layout */ +#define NU_ROM_START_NS (0x10000000 + MBED_ROM_SIZE) +#define NU_ROM_SIZE_NS (0x80000 - MBED_ROM_SIZE) +/* Resolved non-secure RAM layout */ +#define NU_RAM_START_NS (0x30000000 + MBED_RAM_SIZE) +#define NU_RAM_SIZE_NS (0x18000 - MBED_RAM_SIZE) + +#endif + +#endif /* __PARTITION_M2351_MEM_H__ */ diff --git a/targets/TARGET_NUVOTON/TARGET_M2351/device/partition_M2351_mem.icf b/targets/TARGET_NUVOTON/TARGET_M2351/device/partition_M2351_mem.icf new file mode 100644 index 0000000000..809204d5f8 --- /dev/null +++ b/targets/TARGET_NUVOTON/TARGET_M2351/device/partition_M2351_mem.icf @@ -0,0 +1,100 @@ +/* + * 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. + */ + +/* See partition_M2351_mem.h for documentation */ + +/* Default flash/SRAM partition + * + * Default flash partition: + * Secure: 256KiB + * Non-secure: 256KiB + * + * Default SRAM partition: + * Secure: 32KiB + * Non-secure: 64KiB + */ +#if defined(DOMAIN_NS) && DOMAIN_NS + +/* Default non-secure ROM layout */ +if (! isdefinedsymbol(MBED_ROM_START)) { + define symbol MBED_ROM_START = 0x10040000; +} +if (! isdefinedsymbol(MBED_ROM_SIZE)) { + define symbol MBED_ROM_SIZE = 0x40000; +} +/* Default non-secure RAM layout */ +if (! isdefinedsymbol(MBED_RAM_START)) { + define symbol MBED_RAM_START = 0x30008000; +} +if (! isdefinedsymbol(MBED_RAM_SIZE)) { + define symbol MBED_RAM_SIZE = 0x10000; +} + +#else + +/* Default secure ROM layout */ +if (! isdefinedsymbol(MBED_ROM_START)) { + define symbol MBED_ROM_START = 0x0; +} +if (! isdefinedsymbol(MBED_ROM_SIZE)) { + define symbol MBED_ROM_SIZE = 0x40000; +} +/* Default secure RAM layout */ +if (! isdefinedsymbol(MBED_RAM_START)) { + define symbol MBED_RAM_START = 0x20000000; +} +if (! isdefinedsymbol(MBED_RAM_SIZE)) { + define symbol MBED_RAM_SIZE = 0x8000; +} + +#endif + +/* Resolved flash/SRAM partition */ +#if defined(DOMAIN_NS) && DOMAIN_NS + +/* Resolved secure ROM layout */ +define symbol NU_ROM_START_S = 0x0; +define symbol NU_ROM_SIZE_S = (0x80000 - MBED_ROM_SIZE); +/* Resolved secure RAM layout */ +define symbol NU_RAM_START_S = 0x20000000; +define symbol NU_RAM_SIZE_S = (0x18000 - MBED_RAM_SIZE); + +/* Resolved non-secure ROM layout */ +define symbol NU_ROM_START_NS = MBED_ROM_START; +define symbol NU_ROM_SIZE_NS = MBED_ROM_SIZE; +/* Resolved non-secure RAM layout */ +define symbol NU_RAM_START_NS = MBED_RAM_START; +define symbol NU_RAM_SIZE_NS = MBED_RAM_SIZE; + +#else + +/* Resolved secure ROM layout */ +define symbol NU_ROM_START_S = MBED_ROM_START; +define symbol NU_ROM_SIZE_S = MBED_ROM_SIZE; +/* Resolved secure RAM layout */ +define symbol NU_RAM_START_S = MBED_RAM_START; +define symbol NU_RAM_SIZE_S = MBED_RAM_SIZE; + +/* Resolved non-secure ROM layout */ +define symbol NU_ROM_START_NS = (0x10000000 + MBED_ROM_SIZE); +define symbol NU_ROM_SIZE_NS = (0x80000 - MBED_ROM_SIZE); +/* Resolved non-secure RAM layout */ +define symbol NU_RAM_START_NS = (0x30000000 + MBED_RAM_SIZE); +define symbol NU_RAM_SIZE_NS = (0x18000 - MBED_RAM_SIZE); + +#endif diff --git a/targets/TARGET_NUVOTON/TARGET_M2351/flash_api.c b/targets/TARGET_NUVOTON/TARGET_M2351/flash_api.c index a3e52c5c8d..a99d0424fa 100644 --- a/targets/TARGET_NUVOTON/TARGET_M2351/flash_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M2351/flash_api.c @@ -25,12 +25,7 @@ #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) -#ifndef MBED_ROM_SIZE_S -#define MBED_ROM_SIZE_S (0x40000) -#endif - -#define NU_SECURE_FLASH_START (MBED_ROM_START) -#define NU_SECURE_FLASH_SIZE (MBED_ROM_SIZE_S) +#include "device/partition_M2351_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. @@ -92,7 +87,7 @@ static const flash_algo_t flash_algo_config = { /* Secure flash */ static const sector_info_t sectors_info[] = { - {NU_SECURE_FLASH_START, 0x800}, // (start, sector size) + {NU_ROM_START_S, 0x800}, // (start, sector size) }; /* Secure flash */ @@ -100,15 +95,15 @@ 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 = NU_SECURE_FLASH_START, - .flash_size = NU_SECURE_FLASH_SIZE, + .flash_start = NU_ROM_START_S, + .flash_size = NU_ROM_SIZE_S, .sectors = sectors_info, .sector_info_count = sizeof(sectors_info) / sizeof(sector_info_t) }; /* Non-secure flash */ static const sector_info_t sectors_info_ns[] = { - {(NS_OFFSET + NU_SECURE_FLASH_SIZE), 0x800}, // (start, sector size) + {NU_ROM_START_NS, 0x800}, // (start, sector size) }; /* Non-secure flash */ @@ -116,8 +111,8 @@ static const flash_target_config_t flash_target_config_ns = { .page_size = 4, // 4 bytes // Here page_size is program unit, which is different // than FMC definition. - .flash_start = NS_OFFSET + NU_SECURE_FLASH_SIZE, - .flash_size = MBED_ROM_SIZE - NU_SECURE_FLASH_SIZE, + .flash_start = NU_ROM_START_NS, + .flash_size = NU_ROM_SIZE_NS, .sectors = sectors_info_ns, .sector_info_count = sizeof(sectors_info_ns) / sizeof(sector_info_t) }; diff --git a/targets/targets.json b/targets/targets.json index bb9ba49618..34586f931d 100644 --- a/targets/targets.json +++ b/targets/targets.json @@ -8073,7 +8073,11 @@ "release_versions": ["5"], "device_name": "M2351KIAAEES", "bootloader_supported": true, - "tickless-from-us-ticker": true + "tickless-from-us-ticker": true, + "mbed_rom_start" : "0x10040000", + "mbed_rom_size" : "0x40000", + "mbed_ram_start" : "0x30008000", + "mbed_ram_size" : "0x10000" }, "TMPM3H6": { "inherits": ["Target"],