Skip to content

Commit 99fcb5b

Browse files
authored
Nuvoton: Migrate to new memory bankc information (#382)
* Nuvoton: Remove unsupported armclang and iar toolchains Armclang and IAR toolchains are not supported in Mbed CE. Remove them for clean. * Nuvoton: Migrate to new style memory bank information Change memory bank symbols: 1. MBED_APP_START/SIZE -> MBED_CONFIGURED_ROM_BANK_IROM1_START/SIZE NOTE: IROM2 for M2354 2. MBED_RAM_APP_START/SIZE -> MBED_CONFIGURED_RAM_BANK_IRAM1_START/SIZE NOTE: IRAM2 for M2354 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
1 parent ab43414 commit 99fcb5b

File tree

37 files changed

+371
-1719
lines changed

37 files changed

+371
-1719
lines changed

targets/TARGET_NUVOTON/TARGET_M2354/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ target_sources(mbed-m2354
1414
analogin_api.c
1515
analogout_api.c
1616

17+
device/partition_M2354_mem.c
1718
device/startup_M2354.c
1819
device/system_M2354.c
1920
device/StdDriver/src/m2354_acmp.c

targets/TARGET_NUVOTON/TARGET_M2354/TARGET_TFM/TARGET_NU_M2354/COMPONENT_TFM_S_FW/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,23 @@ Below summarize the copy paths from TF-M into Mbed:
152152
**NOTE**: `trusted-firmware-m/cmake_build/install/image_signing/keys/root-RSA-3072.pem` can be missing due to TF-M build tool issue.
153153
Try to get it from `trusted-firmware-m/bl2/ext/mcuboot/root-RSA-3072.pem` instead if it is just the original source.
154154

155+
Open `targets.json5` (for built-in target) or `custom_targets.json5` (for custom target),
156+
, locate the `memory_banks` section for this mbed target,
157+
and update the below symbols per above TF-M exported `region_defs.h`.
158+
159+
```json5
160+
"memory_banks": {
161+
"NS_CODE": {
162+
"size": /*<NS_CODE_SIZE>*/,
163+
"start": /*<NS_CODE_START>*/,
164+
},
165+
"NS_DATA": {
166+
"size": /*<NS_DATA_SIZE>*/,
167+
"start": /*<NS_DATA_START>*/,
168+
},
169+
},
170+
```
171+
155172
## PSA Firmware Update
156173

157174
### Requirement

targets/TARGET_NUVOTON/TARGET_M2354/device/TOOLCHAIN_ARMC6/M2354.sct

Lines changed: 0 additions & 64 deletions
This file was deleted.

targets/TARGET_NUVOTON/TARGET_M2354/device/TOOLCHAIN_GCC_ARM/M2354.ld

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ StackSize = MBED_CONF_TARGET_BOOT_STACK_SIZE;
3434

3535
MEMORY
3636
{
37-
VECTORS (rx) : ORIGIN = MBED_APP_START, LENGTH = 0x00000400
38-
FLASH (rx) : ORIGIN = MBED_APP_START + 0x400, LENGTH = MBED_APP_SIZE - 0x400
39-
RAM_INTERN (rwx) : ORIGIN = MBED_RAM_APP_START, LENGTH = MBED_RAM_APP_SIZE
37+
VECTORS (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_NS_CODE_START, LENGTH = 0x00000400
38+
FLASH (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_NS_CODE_START + 0x400, LENGTH = MBED_CONFIGURED_ROM_BANK_NS_CODE_SIZE - 0x400
39+
RAM_INTERN (rwx) : ORIGIN = MBED_CONFIGURED_RAM_BANK_NS_DATA_START, LENGTH = MBED_CONFIGURED_RAM_BANK_NS_DATA_SIZE
4040
}
4141

4242
/**
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2020, Nuvoton Technology Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#include <assert.h>
20+
#include "partition_M2354_mem.h"
21+
22+
/* Check MBED_ROM_BANK_NS_CODE_START and friends
23+
*
24+
* These symbols must be resolved by TF-M exported region_defs.h.
25+
*/
26+
static_assert(MBED_ROM_BANK_NS_CODE_START == NS_CODE_START,
27+
"MBED_ROM_BANK_NS_CODE_START not equal TF-M imported NS_CODE_START");
28+
static_assert(MBED_ROM_BANK_NS_CODE_SIZE == NS_CODE_SIZE,
29+
"MBED_ROM_BANK_NS_CODE_SIZE not equal TF-M imported NS_CODE_SIZE");
30+
static_assert(MBED_RAM_BANK_NS_DATA_START == NS_DATA_START,
31+
"MBED_RAM_BANK_NS_DATA_START not equal TF-M imported NS_DATA_START");
32+
static_assert(MBED_RAM_BANK_NS_DATA_SIZE == NS_DATA_SIZE,
33+
"MBED_RAM_BANK_NS_DATA_SIZE not equal TF-M imported NS_DATA_SIZE");

targets/TARGET_NUVOTON/TARGET_M2354/device/partition_M2354_mem.h

Lines changed: 24 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -19,113 +19,45 @@
1919
#ifndef __PARTITION_M2354_MEM_H__
2020
#define __PARTITION_M2354_MEM_H__
2121

22-
/* About partition_M2354_mem.h/partition_M2354_mem.icf.h
23-
*
24-
* 1. partition_M2354_mem.h is created for centralizing memory partition configuration. It will be
25-
* included by C/C++ files and linker files (except IAR linker file).
26-
* 2. IAR linker doesn't support preprocessor, so partition_M2354_mem.icf.h, duplicate of partition_M2354_mem.h
27-
* is created for IAR linker file.
28-
* 3. To continue above, we name partition_M2354_mem.icf.h instead of partition_M2354_mem.icf because:
29-
* (1) Mbed OS build tool may mis-regard partition_M2354_mem.icf as the main linker configuration file.
30-
* (2) *.icf files may not be present in search directories for "include" directive. Per observation,
31-
* the search directories are inconsistent among normal example build and test code build. To address
32-
* it, we name partition_M2354_mem.icf.h instead because *.h files are always present in these builds
33-
* (already there or via copy).
34-
*/
35-
3622
#include "nu_tfm_import_define.h"
3723
#include NU_TFM_S_REGION_DEFS_H_PATH
3824
#include "nu_tfm_import_undefine.h"
3925

40-
/* Resolve MBED_ROM_START and friends
26+
/* Resolve MBED_ROM_BANK_NS_CODE_START and friends
4127
*
42-
* TF-M exported region_defs.h essentially resolves MBED_ROM_START and friends.
43-
* target.mbed_rom_start and friends get unnecessary.
28+
* TF-M exported region_defs.h essentially resolves MBED_ROM_BANK_NS_CODE_START and friends.
4429
*/
45-
/* Resolve non-secure ROM start */
46-
#undef MBED_ROM_START
47-
#define MBED_ROM_START NS_CODE_START
48-
49-
/* Resolve non-secure ROM size */
50-
#undef MBED_ROM_SIZE
51-
#define MBED_ROM_SIZE NS_CODE_SIZE
52-
53-
/* Resolve non-secure RAM start */
54-
#undef MBED_RAM_START
55-
#define MBED_RAM_START NS_DATA_START
56-
57-
/* Resolve non-secure RAM size */
58-
#undef MBED_RAM_SIZE
59-
#define MBED_RAM_SIZE NS_DATA_SIZE
60-
61-
/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just
62-
* MBED_APP_xxx macros to linker files even though they mean the same thing.
63-
* Because this file is to include by both C/C++ files and linker files, we add
64-
* these macros according to the others for consistency when they are missing
65-
* in compile or link stage. */
6630

67-
#ifndef APPLICATION_ADDR
68-
#ifdef MBED_APP_START
69-
#define APPLICATION_ADDR MBED_APP_START
70-
#else
71-
#define APPLICATION_ADDR MBED_ROM_START
72-
#endif
73-
#endif
74-
75-
#ifndef APPLICATION_SIZE
76-
#ifdef MBED_APP_SIZE
77-
#define APPLICATION_SIZE MBED_APP_SIZE
78-
#else
79-
#define APPLICATION_SIZE MBED_ROM_SIZE
80-
#endif
31+
/* Physical NS_CODE start/size */
32+
#if !defined(MBED_ROM_BANK_NS_CODE_START)
33+
#define MBED_ROM_BANK_NS_CODE_START NS_CODE_START
8134
#endif
35+
#if !defined(MBED_ROM_BANK_NS_CODE_SIZE)
36+
#define MBED_ROM_BANK_NS_CODE_SIZE NS_CODE_SIZE
37+
#endif
8238

83-
#ifndef APPLICATION_RAM_ADDR
84-
#ifdef MBED_RAM_APP_START
85-
#define APPLICATION_RAM_ADDR MBED_RAM_APP_START
86-
#else
87-
#define APPLICATION_RAM_ADDR MBED_RAM_START
39+
/* Physical NS_DATA start/size */
40+
#if !defined(MBED_RAM_BANK_NS_DATA_START)
41+
#define MBED_RAM_BANK_NS_DATA_START NS_DATA_START
8842
#endif
43+
#if !defined(MBED_RAM_BANK_NS_DATA_SIZE)
44+
#define MBED_RAM_BANK_NS_DATA_SIZE NS_DATA_SIZE
8945
#endif
9046

91-
#ifndef APPLICATION_RAM_SIZE
92-
#ifdef MBED_RAM_APP_SIZE
93-
#define APPLICATION_RAM_SIZE MBED_RAM_APP_SIZE
94-
#else
95-
#define APPLICATION_RAM_SIZE MBED_RAM_SIZE
96-
#endif
47+
/* Configured NS_CODE start/size */
48+
#if !defined(MBED_CONFIGURED_ROM_BANK_NS_CODE_START)
49+
#define MBED_CONFIGURED_ROM_BANK_NS_CODE_START MBED_ROM_BANK_NS_CODE_START
9750
#endif
51+
#if !defined(MBED_CONFIGURED_ROM_BANK_NS_CODE_SIZE)
52+
#define MBED_CONFIGURED_ROM_BANK_NS_CODE_SIZE MBED_ROM_BANK_NS_CODE_SIZE
53+
#endif
9854

99-
#ifndef MBED_APP_START
100-
#define MBED_APP_START APPLICATION_ADDR
55+
/* Configured NS_DATA start/size */
56+
#if !defined(MBED_CONFIGURED_RAM_BANK_NS_DATA_START)
57+
#define MBED_CONFIGURED_RAM_BANK_NS_DATA_START MBED_RAM_BANK_NS_DATA_START
10158
#endif
102-
103-
#ifndef MBED_APP_SIZE
104-
#define MBED_APP_SIZE APPLICATION_SIZE
105-
#endif
106-
107-
#ifndef MBED_RAM_APP_START
108-
#define MBED_RAM_APP_START APPLICATION_RAM_ADDR
109-
#endif
110-
111-
#ifndef MBED_RAM_APP_SIZE
112-
#define MBED_RAM_APP_SIZE APPLICATION_RAM_SIZE
113-
#endif
114-
115-
#if (APPLICATION_ADDR != MBED_APP_START)
116-
#error("APPLICATION_ADDR and MBED_APP_START are not the same!!!")
117-
#endif
118-
119-
#if (APPLICATION_SIZE != MBED_APP_SIZE)
120-
#error("APPLICATION_SIZE and MBED_APP_SIZE are not the same!!!")
121-
#endif
122-
123-
#if (APPLICATION_RAM_ADDR != MBED_RAM_APP_START)
124-
#error("APPLICATION_RAM_ADDR and MBED_RAM_APP_START are not the same!!!")
125-
#endif
126-
127-
#if (APPLICATION_RAM_SIZE != MBED_RAM_APP_SIZE)
128-
#error("APPLICATION_RAM_SIZE and MBED_RAM_APP_SIZE are not the same!!!")
59+
#if !defined(MBED_CONFIGURED_RAM_BANK_NS_DATA_SIZE)
60+
#define MBED_CONFIGURED_RAM_BANK_NS_DATA_SIZE MBED_RAM_BANK_NS_DATA_SIZE
12961
#endif
13062

13163
#endif /* __PARTITION_M2354_MEM_H__ */

targets/TARGET_NUVOTON/TARGET_M2354/device/partition_M2354_mem.icf.h

Lines changed: 0 additions & 112 deletions
This file was deleted.

0 commit comments

Comments
 (0)