Skip to content

Commit 6bf8e19

Browse files
committed
[M2351] Support configurable for partitioning flash/SRAM
1 parent 778aa1e commit 6bf8e19

File tree

11 files changed

+264
-241
lines changed

11 files changed

+264
-241
lines changed

targets/TARGET_NUVOTON/TARGET_M2351/device/TOOLCHAIN_ARM_MICRO/M2351.sct

Lines changed: 65 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,66 @@
11
#! armcc -E
22

3-
#include "partition_M2351_sub.h"
3+
/* Default flash/SRAM partition
4+
*
5+
* Default flash partition:
6+
* Secure: 256KiB
7+
* Non-secure: 256KiB
8+
*
9+
* Default SRAM partition:
10+
* Secure: 32KiB
11+
* Non-secure: 64KiB
12+
*/
13+
#if defined(__DOMAIN_NS) && __DOMAIN_NS
14+
15+
#ifndef MBED_APP_START
16+
#define MBED_APP_START 0x10040000
17+
#endif
18+
19+
#ifndef MBED_APP_SIZE
20+
#define MBED_APP_SIZE 0x40000
21+
#endif
22+
23+
#ifndef MBED_RAM_START
24+
#define MBED_RAM_START 0x30008000
25+
#endif
26+
27+
#ifndef MBED_RAM_SIZE
28+
#define MBED_RAM_SIZE 0x10000
29+
#endif
30+
31+
#else
432

5-
/* Check relevant macros have been defined */
6-
#if (! defined(NU_TZ_SECURE_FLASH_SIZE))
7-
#error("NU_TZ_SECURE_FLASH_SIZE not defined")
33+
#ifndef MBED_APP_START
34+
#define MBED_APP_START 0x0
835
#endif
9-
#if (! defined(NU_TZ_SECURE_SRAM_SIZE))
10-
#error("NU_TZ_SECURE_SRAM_SIZE not defined")
36+
37+
#ifndef MBED_APP_SIZE
38+
#define MBED_APP_SIZE 0x40000
1139
#endif
12-
#if (! defined(NU_TZ_NSC_REGION_SIZE))
13-
#error("NU_TZ_NSC_REGION_SIZE not defined")
40+
41+
#ifndef MBED_RAM_START
42+
#define MBED_RAM_START 0x20000000
43+
#endif
44+
45+
#ifndef MBED_RAM_SIZE
46+
#define MBED_RAM_SIZE 0x8000
47+
#endif
48+
1449
#endif
1550

1651
/* Requirements for NSC location
1752
*
1853
* 1. By IDAU, 0~0x4000 is secure. NSC can only locate in 0x4000~0x10000000.
1954
* 2. Greentea flash IAP uses last 4 sectors for its test. Avoid this range.
20-
* 3. Greentea NVSTORE uses last 2 sectors or 4KB x 2 for its test. Avoid this range.
55+
* 3. Greentea NVSTORE uses last 2 sectors or 4KiB x 2 for its test. Avoid this range.
56+
* 4. NSC region size defaults to 4KiB if not defined.
2157
*/
22-
#define NU_TZ_NSC_REGION_BASE (MBED_APP_START + MBED_APP_SIZE - 0x2000 - NU_TZ_NSC_REGION_SIZE)
58+
#ifndef NU_TZ_NSC_START
59+
#define NU_TZ_NSC_START (MBED_APP_START + MBED_APP_SIZE - 0x2000 - NU_TZ_NSC_SIZE)
60+
#endif
61+
#ifndef NU_TZ_NSC_SIZE
62+
#define NU_TZ_NSC_SIZE 0x1000
63+
#endif
2364

2465
/* Initial/ISR stack size */
2566
#if (! defined(NU_INITIAL_STACK_SIZE))
@@ -32,14 +73,6 @@
3273

3374
#if defined(__DOMAIN_NS) && __DOMAIN_NS
3475

35-
#if (! defined(MBED_APP_START))
36-
#define MBED_APP_START (0x10000000 + NU_TZ_SECURE_FLASH_SIZE)
37-
#endif
38-
39-
#if (! defined(MBED_APP_SIZE))
40-
#define MBED_APP_SIZE (0x80000 - NU_TZ_SECURE_FLASH_SIZE)
41-
#endif
42-
4376
LR_IROM1 MBED_APP_START
4477
{
4578
/* load address = execution address */
@@ -50,7 +83,7 @@ LR_IROM1 MBED_APP_START
5083
.ANY (+RO)
5184
}
5285

53-
ARM_LIB_STACK 0x30000000 + NU_TZ_SECURE_SRAM_SIZE EMPTY NU_INITIAL_STACK_SIZE
86+
ARM_LIB_STACK MBED_RAM_START EMPTY NU_INITIAL_STACK_SIZE
5487
{
5588
}
5689

@@ -68,24 +101,16 @@ LR_IROM1 MBED_APP_START
68101
.ANY (+RW +ZI)
69102
}
70103

71-
ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (0x30018000 - AlignExpr(ImageLimit(RW_IRAM1), 16))
104+
ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_START + MBED_RAM_SIZE - AlignExpr(ImageLimit(RW_IRAM1), 16))
72105
{
73106
}
74107
}
75108

76109
ScatterAssert(LoadLimit(LR_IROM1) <= (MBED_APP_START + MBED_APP_SIZE))
77-
ScatterAssert(ImageLimit(ARM_LIB_HEAP) <= 0x30018000)
110+
ScatterAssert(ImageLimit(ARM_LIB_HEAP) <= MBED_RAM_START + MBED_RAM_SIZE)
78111

79112
#else
80113

81-
#if (! defined(MBED_APP_START))
82-
#define MBED_APP_START 0
83-
#endif
84-
85-
#if (! defined(MBED_APP_SIZE))
86-
#define MBED_APP_SIZE NU_TZ_SECURE_FLASH_SIZE
87-
#endif
88-
89114
LR_IROM1 MBED_APP_START
90115
{
91116
/* load address = execution address */
@@ -114,23 +139,27 @@ LR_IROM1 MBED_APP_START
114139
.ANY (+RW +ZI)
115140
}
116141

117-
ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (0x20000000 + NU_TZ_SECURE_SRAM_SIZE - AlignExpr(ImageLimit(RW_IRAM1), 16))
142+
ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_START + MBED_RAM_SIZE - AlignExpr(ImageLimit(RW_IRAM1), 16))
118143
{
119144
}
120145
}
121146

122-
LR_IROM2 NU_TZ_NSC_REGION_BASE
147+
LR_IROM_NSC NU_TZ_NSC_START NU_TZ_NSC_SIZE
123148
{
124-
NSC_ROM +0 NU_TZ_NSC_REGION_SIZE
149+
ER_IROM_NSC +0
125150
{
126151
*(Veneer$$CMSE)
127152
}
153+
154+
ER_IROM_NSC_PAD +0 FILL 0xFFFFFFFF (NU_TZ_NSC_START + NU_TZ_NSC_SIZE - ImageLimit(ER_IROM_NSC))
155+
{
156+
}
128157
}
129158

130-
ScatterAssert(LoadLimit(LR_IROM1) <= NU_TZ_NSC_REGION_BASE)
131-
ScatterAssert(LoadLimit(LR_IROM2) <= (NU_TZ_NSC_REGION_BASE + NU_TZ_NSC_REGION_SIZE))
159+
ScatterAssert(LoadLimit(LR_IROM1) <= NU_TZ_NSC_START)
160+
ScatterAssert(LoadLimit(LR_IROM_NSC) <= (NU_TZ_NSC_START + NU_TZ_NSC_SIZE))
132161
/* By IDAU, 0~0x4000 is secure. NSC can only locate in 0x4000~0x10000000 */
133-
ScatterAssert(LoadBase(LR_IROM2) >= 0x4000)
134-
ScatterAssert(ImageLimit(ARM_LIB_HEAP) <= (0x20000000 + NU_TZ_SECURE_SRAM_SIZE))
162+
ScatterAssert(LoadBase(LR_IROM_NSC) >= 0x4000)
163+
ScatterAssert(ImageLimit(ARM_LIB_HEAP) <= (MBED_RAM_START + MBED_RAM_SIZE))
135164

136165
#endif

targets/TARGET_NUVOTON/TARGET_M2351/device/TOOLCHAIN_ARM_MICRO/partition_M2351_sub.h

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

targets/TARGET_NUVOTON/TARGET_M2351/device/TOOLCHAIN_ARM_STD/M2351.sct

Lines changed: 65 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,66 @@
11
#! armcc -E
22

3-
#include "partition_M2351_sub.h"
3+
/* Default flash/SRAM partition
4+
*
5+
* Default flash partition:
6+
* Secure: 256KiB
7+
* Non-secure: 256KiB
8+
*
9+
* Default SRAM partition:
10+
* Secure: 32KiB
11+
* Non-secure: 64KiB
12+
*/
13+
#if defined(__DOMAIN_NS) && __DOMAIN_NS
14+
15+
#ifndef MBED_APP_START
16+
#define MBED_APP_START 0x10040000
17+
#endif
18+
19+
#ifndef MBED_APP_SIZE
20+
#define MBED_APP_SIZE 0x40000
21+
#endif
22+
23+
#ifndef MBED_RAM_START
24+
#define MBED_RAM_START 0x30008000
25+
#endif
26+
27+
#ifndef MBED_RAM_SIZE
28+
#define MBED_RAM_SIZE 0x10000
29+
#endif
30+
31+
#else
432

5-
/* Check relevant macros have been defined */
6-
#if (! defined(NU_TZ_SECURE_FLASH_SIZE))
7-
#error("NU_TZ_SECURE_FLASH_SIZE not defined")
33+
#ifndef MBED_APP_START
34+
#define MBED_APP_START 0x0
835
#endif
9-
#if (! defined(NU_TZ_SECURE_SRAM_SIZE))
10-
#error("NU_TZ_SECURE_SRAM_SIZE not defined")
36+
37+
#ifndef MBED_APP_SIZE
38+
#define MBED_APP_SIZE 0x40000
1139
#endif
12-
#if (! defined(NU_TZ_NSC_REGION_SIZE))
13-
#error("NU_TZ_NSC_REGION_SIZE not defined")
40+
41+
#ifndef MBED_RAM_START
42+
#define MBED_RAM_START 0x20000000
43+
#endif
44+
45+
#ifndef MBED_RAM_SIZE
46+
#define MBED_RAM_SIZE 0x8000
47+
#endif
48+
1449
#endif
1550

1651
/* Requirements for NSC location
1752
*
1853
* 1. By IDAU, 0~0x4000 is secure. NSC can only locate in 0x4000~0x10000000.
1954
* 2. Greentea flash IAP uses last 4 sectors for its test. Avoid this range.
20-
* 3. Greentea NVSTORE uses last 2 sectors or 4KB x 2 for its test. Avoid this range.
55+
* 3. Greentea NVSTORE uses last 2 sectors or 4KiB x 2 for its test. Avoid this range.
56+
* 4. NSC region size defaults to 4KiB if not defined.
2157
*/
22-
#define NU_TZ_NSC_REGION_BASE (MBED_APP_START + MBED_APP_SIZE - 0x2000 - NU_TZ_NSC_REGION_SIZE)
58+
#ifndef NU_TZ_NSC_START
59+
#define NU_TZ_NSC_START (MBED_APP_START + MBED_APP_SIZE - 0x2000 - NU_TZ_NSC_SIZE)
60+
#endif
61+
#ifndef NU_TZ_NSC_SIZE
62+
#define NU_TZ_NSC_SIZE 0x1000
63+
#endif
2364

2465
/* Initial/ISR stack size */
2566
#if (! defined(NU_INITIAL_STACK_SIZE))
@@ -32,14 +73,6 @@
3273

3374
#if defined(__DOMAIN_NS) && __DOMAIN_NS
3475

35-
#if (! defined(MBED_APP_START))
36-
#define MBED_APP_START (0x10000000 + NU_TZ_SECURE_FLASH_SIZE)
37-
#endif
38-
39-
#if (! defined(MBED_APP_SIZE))
40-
#define MBED_APP_SIZE (0x80000 - NU_TZ_SECURE_FLASH_SIZE)
41-
#endif
42-
4376
LR_IROM1 MBED_APP_START
4477
{
4578
/* load address = execution address */
@@ -50,7 +83,7 @@ LR_IROM1 MBED_APP_START
5083
.ANY (+RO)
5184
}
5285

53-
ARM_LIB_STACK 0x30000000 + NU_TZ_SECURE_SRAM_SIZE EMPTY NU_INITIAL_STACK_SIZE
86+
ARM_LIB_STACK MBED_RAM_START EMPTY NU_INITIAL_STACK_SIZE
5487
{
5588
}
5689

@@ -68,24 +101,16 @@ LR_IROM1 MBED_APP_START
68101
.ANY (+RW +ZI)
69102
}
70103

71-
ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (0x30018000 - AlignExpr(ImageLimit(RW_IRAM1), 16))
104+
ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_START + MBED_RAM_SIZE - AlignExpr(ImageLimit(RW_IRAM1), 16))
72105
{
73106
}
74107
}
75108

76109
ScatterAssert(LoadLimit(LR_IROM1) <= (MBED_APP_START + MBED_APP_SIZE))
77-
ScatterAssert(ImageLimit(ARM_LIB_HEAP) <= 0x30018000)
110+
ScatterAssert(ImageLimit(ARM_LIB_HEAP) <= MBED_RAM_START + MBED_RAM_SIZE)
78111

79112
#else
80113

81-
#if (! defined(MBED_APP_START))
82-
#define MBED_APP_START 0
83-
#endif
84-
85-
#if (! defined(MBED_APP_SIZE))
86-
#define MBED_APP_SIZE NU_TZ_SECURE_FLASH_SIZE
87-
#endif
88-
89114
LR_IROM1 MBED_APP_START
90115
{
91116
/* load address = execution address */
@@ -114,23 +139,27 @@ LR_IROM1 MBED_APP_START
114139
.ANY (+RW +ZI)
115140
}
116141

117-
ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (0x20000000 + NU_TZ_SECURE_SRAM_SIZE - AlignExpr(ImageLimit(RW_IRAM1), 16))
142+
ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_START + MBED_RAM_SIZE - AlignExpr(ImageLimit(RW_IRAM1), 16))
118143
{
119144
}
120145
}
121146

122-
LR_IROM2 NU_TZ_NSC_REGION_BASE
147+
LR_IROM_NSC NU_TZ_NSC_START NU_TZ_NSC_SIZE
123148
{
124-
NSC_ROM +0 NU_TZ_NSC_REGION_SIZE
149+
ER_IROM_NSC +0
125150
{
126151
*(Veneer$$CMSE)
127152
}
153+
154+
ER_IROM_NSC_PAD +0 FILL 0xFFFFFFFF (NU_TZ_NSC_START + NU_TZ_NSC_SIZE - ImageLimit(ER_IROM_NSC))
155+
{
156+
}
128157
}
129158

130-
ScatterAssert(LoadLimit(LR_IROM1) <= NU_TZ_NSC_REGION_BASE)
131-
ScatterAssert(LoadLimit(LR_IROM2) <= (NU_TZ_NSC_REGION_BASE + NU_TZ_NSC_REGION_SIZE))
159+
ScatterAssert(LoadLimit(LR_IROM1) <= NU_TZ_NSC_START)
160+
ScatterAssert(LoadLimit(LR_IROM_NSC) <= (NU_TZ_NSC_START + NU_TZ_NSC_SIZE))
132161
/* By IDAU, 0~0x4000 is secure. NSC can only locate in 0x4000~0x10000000 */
133-
ScatterAssert(LoadBase(LR_IROM2) >= 0x4000)
134-
ScatterAssert(ImageLimit(ARM_LIB_HEAP) <= (0x20000000 + NU_TZ_SECURE_SRAM_SIZE))
162+
ScatterAssert(LoadBase(LR_IROM_NSC) >= 0x4000)
163+
ScatterAssert(ImageLimit(ARM_LIB_HEAP) <= (MBED_RAM_START + MBED_RAM_SIZE))
135164

136165
#endif

targets/TARGET_NUVOTON/TARGET_M2351/device/TOOLCHAIN_ARM_STD/partition_M2351_sub.h

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

0 commit comments

Comments
 (0)