Skip to content

Commit 443802a

Browse files
authored
Merge pull request #12353 from OpenNuvoton/nuvoton_m2351_iar
M2351: Support IAR
2 parents 5165559 + 94762d0 commit 443802a

File tree

8 files changed

+390
-229
lines changed

8 files changed

+390
-229
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
/*-Editor annotation file-*/
2121
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
2222

23-
include "../../../device/partition_M2351_mem.icf";
23+
include "../../../device/partition_M2351_mem.icf.h";
2424

25-
if (! isdefinedsymbol(MBED_BOOT_STACK_SIZE)) {
25+
if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) {
2626
define symbol MBED_BOOT_STACK_SIZE = 0x400;
2727
}
2828

@@ -36,6 +36,7 @@ define symbol __ICFEDIT_region_IRAM_end__ = MBED_RAM_APP_START + MBED_RAM_
3636

3737
/*-Sizes-*/
3838
define symbol __ICFEDIT_size_cstack__ = MBED_BOOT_STACK_SIZE;
39+
define symbol __ICFEDIT_size_intvec__ = 4 * (16 + 102);
3940
define symbol __ICFEDIT_size_heap__ = 0x400;
4041

4142
/**** End of ICF editor section. ###ICF###*/
@@ -45,18 +46,17 @@ define memory mem with size = 4G;
4546
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
4647
define region IRAM_region = mem:[from __ICFEDIT_region_IRAM_start__ to __ICFEDIT_region_IRAM_end__];
4748

48-
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
49+
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
4950
define block HEAP with expanding size, alignment = 8, minimum size = __ICFEDIT_size_heap__ { };
5051
/* NOTE: Vector table base requires to be aligned to the power of vector table size. Give a safe value here. */
51-
define block IRAMVEC with alignment = 1024, size = 4 * (16 + 102) { };
52+
define block IRAMVEC with alignment = 1024, size = __ICFEDIT_size_intvec__ { };
5253

5354

5455
initialize by copy { readwrite };
5556
do not initialize { section .noinit };
5657

5758
place at address mem: __ICFEDIT_intvec_start__ { readonly section .intvec };
5859
place in ROM_region { readonly };
59-
place at address mem: NU_TZ_NSC_START { block Image$$ER_IROM_NSC }
6060

6161
place at start of IRAM_region { block CSTACK };
6262
place in IRAM_region { block IRAMVEC };

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

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
/*-Editor annotation file-*/
2121
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
2222

23-
include "../../../device/partition_M2351_mem.icf";
23+
include "../../../device/partition_M2351_mem.icf.h";
2424

25-
if (! isdefinedsymbol(MBED_BOOT_STACK_SIZE)) {
25+
if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) {
2626
define symbol MBED_BOOT_STACK_SIZE = 0x400;
2727
}
2828

@@ -38,6 +38,10 @@ define symbol __ICFEDIT_region_IRAM_end__ = MBED_RAM_APP_START + MBED_RAM_
3838

3939
/*-Sizes-*/
4040
define symbol __ICFEDIT_size_cstack__ = MBED_BOOT_STACK_SIZE;
41+
if (TFM_LVL > 0) {
42+
define symbol __ICFEDIT_size_cstack_msp__ = 0x800;
43+
}
44+
define symbol __ICFEDIT_size_intvec__ = 4 * (16 + 102);
4145
define symbol __ICFEDIT_size_heap__ = 0x400;
4246

4347

@@ -48,26 +52,72 @@ define memory mem with size = 4G;
4852
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
4953
define region IRAM_region = mem:[from __ICFEDIT_region_IRAM_start__ to __ICFEDIT_region_IRAM_end__];
5054

51-
define block Image$$ER_IROM_NSC with alignment = 32 { readonly section Veneer$$CMSE };
55+
/* IAR has something wrong with "$$" in section/block name. So unlike other toolchains,
56+
* we name "ER_IROM_NSC" instead of "Image$$ER_IROM_NSC". */
57+
define block ER_IROM_NSC with alignment = 32 { readonly section Veneer$$CMSE };
5258

53-
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
59+
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
60+
if (TFM_LVL > 0) {
61+
define block CSTACK_MSP with alignment = 8, size = __ICFEDIT_size_cstack_msp__ { };
62+
}
5463
define block HEAP with expanding size, alignment = 8, minimum size = __ICFEDIT_size_heap__ { };
5564
/* NOTE: Vector table base requires to be aligned to the power of vector table size. Give a safe value here. */
56-
define block IRAMVEC with alignment = 1024, size = 4 * (16 + 102) { };
57-
65+
define block IRAMVEC with alignment = 1024, size = __ICFEDIT_size_intvec__ { };
66+
67+
if (TFM_LVL == 1) {
68+
define block TDB_INTERNAL_STORAGE with size = NU_TDB_INTERNAL_STORAGE_SIZE{ };
69+
define block TFM_SECURE_STACK with alignment = 128, size = 0x1000 { };
70+
define block TFM_UNPRIV_SCRATCH with alignment = 32, size = 0x400 { };
71+
define block ER_TFM_DATA with alignment = 8 { readwrite };
72+
} else if (TFM_LVL > 1) {
73+
error "TFM level 2/3 are not supported yet";
74+
}
5875

5976
initialize by copy { readwrite };
6077
do not initialize { section .noinit };
6178

6279
place at address mem: __ICFEDIT_intvec_start__ { readonly section .intvec };
6380
place in ROM_region { readonly };
64-
place at address mem: NU_TZ_NSC_START { block Image$$ER_IROM_NSC }
81+
place at address mem: NU_TZ_NSC_START { block ER_IROM_NSC };
6582

66-
place at start of IRAM_region { block CSTACK };
83+
if (TFM_LVL == 0) {
84+
place at start of IRAM_region { block CSTACK };
85+
} else {
86+
place at start of IRAM_region { block CSTACK_MSP };
87+
place in IRAM_region { block CSTACK };
88+
}
6789
place in IRAM_region { block IRAMVEC };
68-
place in IRAM_region { readwrite };
90+
91+
if (TFM_LVL == 0) {
92+
place in IRAM_region { readwrite };
93+
} else if (TFM_LVL == 1) {
94+
place at address mem: NU_TDB_INTERNAL_STORAGE_START { block TDB_INTERNAL_STORAGE };
95+
place in IRAM_region { block TFM_SECURE_STACK };
96+
place in IRAM_region { block TFM_UNPRIV_SCRATCH };
97+
place in IRAM_region { block ER_TFM_DATA };
98+
} else {
99+
error "TFM level 2/3 are not supported yet";
100+
}
101+
69102
place in IRAM_region { block HEAP };
70103

104+
define exported symbol Image$$ER_IROM_NSC$$Base = NU_TZ_NSC_START;
105+
106+
/* TODO: Export the following symbols to support TFM secure code */
107+
/*
71108
if (TFM_LVL > 0) {
72-
/* TODO: Check if TDB internal storage area overlaps with application ROM code */
109+
define exported symbol Image$$ARM_LIB_STACK$$ZI$$Limit = Start of CSTACK;
110+
}
111+
if (TFM_LVL == 1) {
112+
define exported symbol Image$$TFM_SECURE_STACK$$ZI$$Base = Start of TFM_SECURE_STACK;
113+
define exported symbol Image$$TFM_SECURE_STACK$$ZI$$Limit = End of TFM_SECURE_STACK;
114+
define exported symbol Image$$TFM_UNPRIV_SCRATCH$$ZI$$Base = Start of TFM_UNPRIV_SCRATCH;
115+
define exported symbol Image$$TFM_UNPRIV_SCRATCH$$ZI$$Limit = End of TFM_UNPRIV_SCRATCH;
116+
define exported symbol Image$$ER_TFM_DATA$$RW$$Base = Start of ER_TFM_DATA (readwrite - zeroinit);
117+
define exported symbol Image$$ER_TFM_DATA$$RW$$Limit = End of ER_TFM_DATA (zeroinit);
118+
define exported symbol Image$$ER_TFM_DATA$$ZI$$Base = End of ER_TFM_DATA (zeroinit);
119+
define exported symbol Image$$ER_TFM_DATA$$ZI$$Limit = ADDR(.TFM_BSS) + SIZEOF(.TFM_BSS);
120+
define exported symbol Image$$ARM_LIB_HEAP$$ZI$$Base = Start of HEAP;
121+
define exported symbol Image$$ARM_LIB_HEAP$$ZI$$Limit = End of HEAP;
73122
}
123+
*/

targets/TARGET_NUVOTON/TARGET_M2351/device/partition_M2351_mem.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,18 @@
1919
#ifndef __PARTITION_M2351_MEM_H__
2020
#define __PARTITION_M2351_MEM_H__
2121

22-
/* About partition_M2351_mem.h/partition_M2351_mem.icf
22+
/* About partition_M2351_mem.h/partition_M2351_mem.icf.h
2323
*
2424
* 1. partition_M2351_mem.h is created for centralizing memory partition configuration. It will be
2525
* included by C/C++ files and linker files (except IAR linker file).
26-
* 2. IAR linker doesn't support preprocessor, so partition_M2351_mem.icf, duplicate of partition_M2351_mem.h
26+
* 2. IAR linker doesn't support preprocessor, so partition_M2351_mem.icf.h, duplicate of partition_M2351_mem.h
2727
* is created for IAR linker file.
28+
* 3. To continue above, we name partition_M2351_mem.icf.h instead of partition_M2351_mem.icf because:
29+
* (1) Mbed OS build tool may mis-regard partition_M2351_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_M2351_mem.icf.h instead because *.h files are always present in these builds
33+
* (already there or via copy).
2834
*/
2935

3036
/* Default flash/SRAM partition

targets/TARGET_NUVOTON/TARGET_M2351/device/partition_M2351_mem.icf

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

0 commit comments

Comments
 (0)