Skip to content

Commit 767e74b

Browse files
committed
[M2351] Support TrustZone and bootloader for IAR
1 parent 8f2c717 commit 767e74b

File tree

3 files changed

+83
-27
lines changed

3 files changed

+83
-27
lines changed
Lines changed: 63 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,70 @@
1+
include partition_M2351_sub
2+
13
/*###ICF### Section handled by ICF editor, don't touch! ****/
24
/*-Editor annotation file-*/
35
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
46

57
if (isdefinedsymbol(__DOMAIN_NS)) {
6-
/*-Specials-*/
7-
define symbol __ICFEDIT_intvec_start__ = 0x10040000;
8-
/*-Memory Regions-*/
9-
define symbol __ICFEDIT_region_ROM_start__ = 0x10040000;
10-
define symbol __ICFEDIT_region_ROM_end__ = 0x10080000 - 1;
11-
define symbol __ICFEDIT_region_IRAM_start__ = 0x30006000;
12-
define symbol __ICFEDIT_region_IRAM_end__ = 0x30018000 - 1;
13-
} else {
14-
/*-Specials-*/
15-
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
16-
/*-Memory Regions-*/
17-
define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
18-
define symbol __ICFEDIT_region_ROM_end__ = 0x0003F000 - 1;
19-
define symbol __ICFEDIT_region_NSCROM_start__ = 0x0003F000;
20-
define symbol __ICFEDIT_region_NSCROM_end__ = 0x00040000 - 1;
21-
define symbol __ICFEDIT_region_IRAM_start__ = 0x20000000;
22-
define symbol __ICFEDIT_region_IRAM_end__ = 0x20006000 - 1;
23-
}
24-
/*-Sizes-*/
25-
define symbol __ICFEDIT_size_cstack__ = 0x800;
26-
if (isdefinedsymbol(__DOMAIN_NS)) {
27-
define symbol __ICFEDIT_size_heap__ = 0x4000;
8+
9+
if (! isdefinedsymbol(MBED_APP_START)) {
10+
define symbol MBED_APP_START = 0x10000000 + NU_TZ_SECURE_FLASH_SIZE;
11+
}
12+
13+
if (! isdefinedsymbol(MBED_APP_SIZE)) {
14+
define symbol MBED_APP_SIZE = 0x80000 - NU_TZ_SECURE_FLASH_SIZE;
15+
}
16+
17+
18+
/*-Specials-*/
19+
define symbol __ICFEDIT_intvec_start__ = MBED_APP_START;
20+
/*-Memory Regions-*/
21+
define symbol __ICFEDIT_region_ROM_start__ = MBED_APP_START;
22+
define symbol __ICFEDIT_region_ROM_end__ = MBED_APP_START + MBED_APP_SIZE - 1;
23+
define symbol __ICFEDIT_region_IRAM_start__ = 0x30000000 + NU_TZ_SECURE_SRAM_SIZE;
24+
define symbol __ICFEDIT_region_IRAM_end__ = 0x30018000 - 1;
25+
26+
/*-Sizes-*/
27+
define symbol __ICFEDIT_size_cstack__ = 0x800;
28+
define symbol __ICFEDIT_size_heap__ = 0x4000;
29+
2830
} else {
29-
define symbol __ICFEDIT_size_heap__ = 0x1000;
31+
32+
if (! isdefinedsymbol(MBED_APP_START)) {
33+
define symbol MBED_APP_START = 0;
34+
}
35+
36+
if (! isdefinedsymbol(MBED_APP_SIZE)) {
37+
define symbol MBED_APP_SIZE = NU_TZ_SECURE_FLASH_SIZE;
38+
}
39+
40+
/* Requirements for NSC location
41+
*
42+
* 1. By IDAU, 0~0x4000 is secure. NSC can only locate in 0x4000~0x10000000.
43+
* 2. Greentea flash IAP uses last 4 sectors for its test. Avoid this range.
44+
* 3. Greentea NVSTORE uses last 2 sectors or 4KB x 2 for its test. Avoid this range.
45+
*/
46+
define exported symbol NU_TZ_NSC_REGION_BASE = MBED_APP_START + MBED_APP_SIZE - 0x2000 - NU_TZ_NSC_REGION_SIZE;
47+
48+
/*-Specials-*/
49+
define symbol __ICFEDIT_intvec_start__ = MBED_APP_START;
50+
/*-Memory Regions-*/
51+
define symbol __ICFEDIT_region_ROM_start__ = MBED_APP_START;
52+
define symbol __ICFEDIT_region_ROM_end__ = MBED_APP_START + MBED_APP_SIZE - 1;
53+
define symbol __ICFEDIT_region_NSCROM_start__ = NU_TZ_NSC_REGION_BASE;
54+
define symbol __ICFEDIT_region_NSCROM_end__ = NU_TZ_NSC_REGION_BASE + NU_TZ_NSC_REGION_SIZE - 1;
55+
define symbol __ICFEDIT_region_IRAM_start__ = 0x20000000;
56+
define symbol __ICFEDIT_region_IRAM_end__ = 0x20000000 + NU_TZ_SECURE_SRAM_SIZE - 1;
57+
58+
export symbol __NU_TZ_SECURE_FLASH_SIZE__ = NU_TZ_SECURE_FLASH_SIZE;
59+
export symbol __NU_TZ_SECURE_SRAM_SIZE__ = NU_TZ_SECURE_SRAM_SIZE;
60+
export symbol __NU_TZ_NSC_REGION_BASE__ = NU_TZ_NSC_REGION_BASE;
61+
export symbol __NU_TZ_NSC_REGION_SIZE__ = NU_TZ_NSC_REGION_SIZE;
62+
63+
/*-Sizes-*/
64+
define symbol __ICFEDIT_size_cstack__ = 0x800;
65+
define symbol __ICFEDIT_size_heap__ = 0x1000;
3066
}
67+
3168
/**** End of ICF editor section. ###ICF###*/
3269

3370

@@ -47,10 +84,10 @@ do not initialize { section .noinit };
4784
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
4885

4986
place in ROM_region { readonly };
50-
if (!isdefinedsymbol(__DOMAIN_NS)) {
51-
place at address mem:__ICFEDIT_region_NSCROM_start__ { readonly section Veneer$$CMSE };
87+
if (! isdefinedsymbol(__DOMAIN_NS)) {
88+
place at address mem:__ICFEDIT_region_NSCROM_start__ { readonly section Veneer$$CMSE };
5289
}
5390
place at start of IRAM_region { block CSTACK };
5491
place in IRAM_region { block IRAMVEC };
5592
place in IRAM_region { readwrite };
56-
place in IRAM_region { block HEAP };
93+
place in IRAM_region { block HEAP };
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
3+
/* Secure flash size: 256 KB */
4+
define exported symbol NU_TZ_SECURE_FLASH_SIZE = 0x40000
5+
6+
/* Secure SRAM size: 24 KB */
7+
define exported symbol NU_TZ_SECURE_SRAM_SIZE = 0x6000
8+
9+
/* NSC region size: 4 KB */
10+
define exported symbol NU_TZ_NSC_REGION_SIZE = 0x1000
11+

targets/TARGET_NUVOTON/TARGET_M2351/device/partition_M2351.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,15 @@ extern int Image$$NSC_ROM$$Base;
2121

2222
#elif defined(__ICCARM__)
2323

24-
#error ("TODO: Support IAR")
24+
extern int __NU_TZ_SECURE_FLASH_SIZE__;
25+
extern int __NU_TZ_SECURE_SRAM_SIZE__;
26+
extern int __NU_TZ_NSC_REGION_BASE__;
27+
extern int __NU_TZ_NSC_REGION_SIZE__;
28+
29+
#define NU_TZ_SECURE_FLASH_SIZE ((uint32_t) &__NU_TZ_SECURE_FLASH_SIZE__)
30+
#define NU_TZ_SECURE_SRAM_SIZE ((uint32_t) &__NU_TZ_SECURE_SRAM_SIZE__)
31+
#define NU_TZ_NSC_REGION_BASE ((uint32_t) &__NU_TZ_NSC_REGION_BASE__)
32+
#define NU_TZ_NSC_REGION_SIZE ((uint32_t) &__NU_TZ_NSC_REGION_SIZE__)
2533

2634
#elif defined(__GNUC__)
2735

0 commit comments

Comments
 (0)