Skip to content

Commit 1aca8a5

Browse files
committed
[M2351] Make exported NSC symbols consistent across toolchains
This idea comes from TFM.
1 parent 85dfc1a commit 1aca8a5

File tree

3 files changed

+7
-25
lines changed

3 files changed

+7
-25
lines changed

targets/TARGET_NUVOTON/TARGET_M2351/device/TOOLCHAIN_GCC_ARM/M2351.ld

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ SECTIONS
216216
__sgstubs_end = .;
217217
} > NSC_FLASH
218218

219-
__nu_tz_nsc_start = NU_TZ_NSC_START;
220-
__nu_tz_nsc_size = NU_TZ_NSC_SIZE;
219+
Load$$LR$$LR_IROM_NSC$$Base = NU_TZ_NSC_START;
220+
Load$$LR$$LR_IROM_NSC$$Length = NU_TZ_NSC_SIZE;
221221

222222
/* By IDAU, 0~0x4000 is secure. NSC can only locate in 0x4000~0x10000000. */
223223
ASSERT(__sgstubs_start >= 0x4000, "By IDAU, 0~0x4000 is secure. NSC can only locate in 0x4000~0x10000000.")

targets/TARGET_NUVOTON/TARGET_M2351/device/TOOLCHAIN_IAR/M2351.icf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ if (isdefinedsymbol(DOMAIN_NS)) {
9292
if (! isdefinedsymbol(NU_TZ_NSC_START)) {
9393
define symbol NU_TZ_NSC_START = MBED_APP_START + MBED_APP_SIZE - 0x2000 - NU_TZ_NSC_SIZE;
9494
}
95-
define exported symbol __NU_TZ_NSC_start__ = NU_TZ_NSC_START;
96-
define exported symbol __NU_TZ_NSC_size__ = NU_TZ_NSC_SIZE;
95+
define exported symbol Load$$LR$$LR_IROM_NSC$$Base = NU_TZ_NSC_START;
96+
define exported symbol Load$$LR$$LR_IROM_NSC$$Length = NU_TZ_NSC_SIZE;
9797

9898
/*-Specials-*/
9999
define symbol __ICFEDIT_intvec_start__ = MBED_APP_START;

targets/TARGET_NUVOTON/TARGET_M2351/device/partition_M2351.h

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,14 @@
2424
#define NU_TZ_SECURE_FLASH_SIZE NU_ROM_SIZE_S
2525
#define NU_TZ_SECURE_SRAM_SIZE NU_RAM_SIZE_S
2626

27-
#if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
28-
27+
/* We make exported symbols consistent across toolchains. This helps for porting e.g. TFM.
28+
* Because Keil scatter file doesn't support custom exported symbols, other toolchains's
29+
* linker files must export the same symbol names as region names in Keil scatter file. */
2930
extern int Load$$LR$$LR_IROM_NSC$$Base;
3031
extern int Load$$LR$$LR_IROM_NSC$$Length;
31-
3232
#define NU_TZ_NSC_REGION_START ((uint32_t) &Load$$LR$$LR_IROM_NSC$$Base)
3333
#define NU_TZ_NSC_REGION_SIZE ((uint32_t) &Load$$LR$$LR_IROM_NSC$$Length)
3434

35-
#elif defined(__ICCARM__)
36-
37-
extern int __NU_TZ_NSC_start__;
38-
extern int __NU_TZ_NSC_size__;
39-
40-
#define NU_TZ_NSC_REGION_START ((uint32_t) &__NU_TZ_NSC_start__)
41-
#define NU_TZ_NSC_REGION_SIZE ((uint32_t) &__NU_TZ_NSC_size__)
42-
43-
#elif defined(__GNUC__)
44-
45-
extern int __nu_tz_nsc_start;
46-
extern int __nu_tz_nsc_size;
47-
48-
#define NU_TZ_NSC_REGION_START ((uint32_t) &__nu_tz_nsc_start)
49-
#define NU_TZ_NSC_REGION_SIZE ((uint32_t) &__nu_tz_nsc_size)
50-
51-
#endif
52-
5335
/* Check relevant macros have been defined */
5436
#if (! defined(NU_TZ_SECURE_FLASH_SIZE))
5537
#error("NU_TZ_SECURE_FLASH_SIZE not defined")

0 commit comments

Comments
 (0)