Skip to content

Commit 14775cb

Browse files
committed
[M2351] Refactor for memory partittion support
Add partition_M2351_mem.h/partition_M2351_mem.icf to centralize memory partition
1 parent 894f71e commit 14775cb

File tree

7 files changed

+232
-91
lines changed

7 files changed

+232
-91
lines changed

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

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,6 @@
11
#! armclang -E
22

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-
14-
#ifndef MBED_ROM_SIZE_S
15-
#define MBED_ROM_SIZE_S (0x40000)
16-
#endif
17-
18-
#ifndef MBED_RAM_SIZE_S
19-
#define MBED_RAM_SIZE_S (0x8000)
20-
#endif
3+
#include "../partition_M2351_mem.h"
214

225
#ifndef NU_TZ_NSC_SIZE
236
#define NU_TZ_NSC_SIZE (0x1000)
@@ -26,19 +9,19 @@
269
#if defined(DOMAIN_NS) && DOMAIN_NS
2710

2811
#ifndef MBED_APP_START
29-
#define MBED_APP_START (0x10000000 + MBED_ROM_START + MBED_ROM_SIZE_S)
12+
#define MBED_APP_START NU_ROM_START_NS
3013
#endif
3114

3215
#ifndef MBED_APP_SIZE
33-
#define MBED_APP_SIZE (MBED_ROM_SIZE - MBED_ROM_SIZE_S)
16+
#define MBED_APP_SIZE NU_ROM_SIZE_NS
3417
#endif
3518

3619
#ifndef MBED_RAM_APP_START
37-
#define MBED_RAM_APP_START (0x10000000 + MBED_RAM_START + MBED_RAM_SIZE_S)
20+
#define MBED_RAM_APP_START NU_RAM_START_NS
3821
#endif
3922

4023
#ifndef MBED_RAM_APP_SIZE
41-
#define MBED_RAM_APP_SIZE (MBED_RAM_SIZE - MBED_RAM_SIZE_S)
24+
#define MBED_RAM_APP_SIZE NU_RAM_SIZE_NS
4225
#endif
4326

4427
#if !defined(MBED_BOOT_STACK_SIZE)
@@ -48,19 +31,19 @@
4831
#else
4932

5033
#ifndef MBED_APP_START
51-
#define MBED_APP_START MBED_ROM_START
34+
#define MBED_APP_START NU_ROM_START_S
5235
#endif
5336

5437
#ifndef MBED_APP_SIZE
55-
#define MBED_APP_SIZE MBED_ROM_SIZE_S
38+
#define MBED_APP_SIZE NU_ROM_SIZE_S
5639
#endif
5740

5841
#ifndef MBED_RAM_APP_START
59-
#define MBED_RAM_APP_START MBED_RAM_START
42+
#define MBED_RAM_APP_START NU_RAM_START_S
6043
#endif
6144

6245
#ifndef MBED_RAM_APP_SIZE
63-
#define MBED_RAM_APP_SIZE MBED_RAM_SIZE_S
46+
#define MBED_RAM_APP_SIZE NU_RAM_SIZE_S
6447
#endif
6548

6649
#if !defined(MBED_BOOT_STACK_SIZE)

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

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,28 @@
22
* Nuvoton M2351 GCC linker script file
33
*/
44

5-
/* Default flash/SRAM partition
6-
*
7-
* Default flash partition:
8-
* Secure: 256KiB
9-
* Non-secure: 256KiB
10-
*
11-
* Default SRAM partition:
12-
* Secure: 32KiB
13-
* Non-secure: 64KiB
14-
*/
15-
16-
#ifndef MBED_ROM_SIZE_S
17-
#define MBED_ROM_SIZE_S (0x40000)
18-
#endif
19-
20-
#ifndef MBED_RAM_SIZE_S
21-
#define MBED_RAM_SIZE_S (0x8000)
22-
#endif
5+
#include "../partition_M2351_mem.h"
236

247
#ifndef NU_TZ_NSC_SIZE
25-
#define NU_TZ_NSC_SIZE (0x1000)
8+
#define NU_TZ_NSC_SIZE (0x1000)
269
#endif
2710

2811
#if defined(DOMAIN_NS) && DOMAIN_NS
2912

3013
#ifndef MBED_APP_START
31-
#define MBED_APP_START (0x10000000 + MBED_ROM_START + MBED_ROM_SIZE_S)
14+
#define MBED_APP_START NU_ROM_START_NS
3215
#endif
3316

3417
#ifndef MBED_APP_SIZE
35-
#define MBED_APP_SIZE (MBED_ROM_SIZE - MBED_ROM_SIZE_S)
18+
#define MBED_APP_SIZE NU_ROM_SIZE_NS
3619
#endif
3720

3821
#ifndef MBED_RAM_APP_START
39-
#define MBED_RAM_APP_START (0x10000000 + MBED_RAM_START + MBED_RAM_SIZE_S)
22+
#define MBED_RAM_APP_START NU_RAM_START_NS
4023
#endif
4124

4225
#ifndef MBED_RAM_APP_SIZE
43-
#define MBED_RAM_APP_SIZE (MBED_RAM_SIZE - MBED_RAM_SIZE_S)
26+
#define MBED_RAM_APP_SIZE NU_RAM_SIZE_NS
4427
#endif
4528

4629
#if !defined(MBED_BOOT_STACK_SIZE)
@@ -50,19 +33,19 @@
5033
#else
5134

5235
#ifndef MBED_APP_START
53-
#define MBED_APP_START MBED_ROM_START
36+
#define MBED_APP_START NU_ROM_START_S
5437
#endif
5538

5639
#ifndef MBED_APP_SIZE
57-
#define MBED_APP_SIZE MBED_ROM_SIZE_S
40+
#define MBED_APP_SIZE NU_ROM_SIZE_S
5841
#endif
5942

6043
#ifndef MBED_RAM_APP_START
61-
#define MBED_RAM_APP_START MBED_RAM_START
44+
#define MBED_RAM_APP_START NU_RAM_START_S
6245
#endif
6346

6447
#ifndef MBED_RAM_APP_SIZE
65-
#define MBED_RAM_APP_SIZE MBED_RAM_SIZE_S
48+
#define MBED_RAM_APP_SIZE NU_RAM_SIZE_S
6649
#endif
6750

6851
#ifndef MBED_BOOT_STACK_SIZE

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

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,28 @@
22
/*-Editor annotation file-*/
33
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
44

5-
6-
if (! isdefinedsymbol(MBED_RAM_SIZE_S)) {
7-
define symbol MBED_RAM_SIZE_S = 0x8000;
8-
}
9-
10-
if (! isdefinedsymbol(MBED_ROM_SIZE_S)) {
11-
define symbol MBED_ROM_SIZE_S = 0x40000;
12-
}
5+
include "../partition_M2351_mem.icf";
136

147
if (! isdefinedsymbol(NU_TZ_NSC_SIZE)) {
15-
define symbol NU_TZ_NSC_SIZE = 0x1000;
8+
define symbol NU_TZ_NSC_SIZE = 0x1000;
169
}
1710

1811
if (isdefinedsymbol(DOMAIN_NS)) {
1912

2013
if (! isdefinedsymbol(MBED_APP_START)) {
21-
define symbol MBED_APP_START = (0x10000000 + MBED_ROM_START + MBED_ROM_SIZE_S);
14+
define symbol MBED_APP_START = NU_ROM_START_NS;
2215
}
2316

2417
if (! isdefinedsymbol(MBED_APP_SIZE)) {
25-
define symbol MBED_APP_SIZE = (MBED_ROM_SIZE - MBED_ROM_SIZE_S);
18+
define symbol MBED_APP_SIZE = NU_ROM_SIZE_NS;
2619
}
2720

2821
if (! isdefinedsymbol(MBED_RAM_APP_START)) {
29-
define symbol MBED_RAM_APP_START = (0x10000000 + MBED_RAM_START + MBED_RAM_SIZE_S);
22+
define symbol MBED_RAM_APP_START = NU_RAM_START_NS;
3023
}
3124

3225
if (! isdefinedsymbol(MBED_RAM_APP_SIZE)) {
33-
define symbol MBED_RAM_APP_SIZE = (MBED_RAM_SIZE - MBED_RAM_SIZE_S);
26+
define symbol MBED_RAM_APP_SIZE = NU_RAM_SIZE_NS;
3427
}
3528

3629
if (! isdefinedsymbol(MBED_BOOT_STACK_SIZE)) {
@@ -52,19 +45,19 @@ if (isdefinedsymbol(DOMAIN_NS)) {
5245
} else {
5346

5447
if (! isdefinedsymbol(MBED_APP_START)) {
55-
define symbol MBED_APP_START = MBED_ROM_START;
48+
define symbol MBED_APP_START = NU_ROM_START_S;
5649
}
5750

5851
if (! isdefinedsymbol(MBED_APP_SIZE)) {
59-
define symbol MBED_APP_SIZE = MBED_ROM_SIZE_S;
52+
define symbol MBED_APP_SIZE = NU_ROM_SIZE_S;
6053
}
6154

6255
if (! isdefinedsymbol(MBED_RAM_APP_START)) {
63-
define symbol MBED_RAM_APP_START = MBED_RAM_START;
56+
define symbol MBED_RAM_APP_START = NU_RAM_START_S;
6457
}
6558

6659
if (! isdefinedsymbol(MBED_RAM_APP_SIZE)) {
67-
define symbol MBED_RAM_APP_SIZE = MBED_RAM_SIZE_S;
60+
define symbol MBED_RAM_APP_SIZE = NU_RAM_SIZE_S;
6861
}
6962

7063
if (! isdefinedsymbol(MBED_BOOT_STACK_SIZE)) {

targets/TARGET_NUVOTON/TARGET_M2351/device/partition_M2351.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,10 @@
1111
#ifndef PARTITION_M2351
1212
#define PARTITION_M2351
1313

14-
#ifndef MBED_ROM_SIZE_S
15-
#define MBED_ROM_SIZE_S (0x40000)
16-
#endif
17-
18-
#ifndef MBED_RAM_SIZE_S
19-
#define MBED_RAM_SIZE_S (0x8000)
20-
#endif
14+
#include "partition_M2351_mem.h"
2115

22-
#define NU_TZ_SECURE_FLASH_SIZE MBED_ROM_SIZE_S
23-
#define NU_TZ_SECURE_SRAM_SIZE MBED_RAM_SIZE_S
16+
#define NU_TZ_SECURE_FLASH_SIZE NU_ROM_SIZE_S
17+
#define NU_TZ_SECURE_SRAM_SIZE NU_RAM_SIZE_S
2418

2519
#if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
2620

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/*
2+
* Copyright (c) 2019-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+
#ifndef __PARTITION_M2351_MEM_H__
20+
#define __PARTITION_M2351_MEM_H__
21+
22+
/* About partition_M2351_mem.h/partition_M2351_mem.icf
23+
*
24+
* 1. partition_M2351_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_M2351_mem.icf, duplicate of partition_M2351_mem.h
27+
* is created for IAR linker file.
28+
*/
29+
30+
/* Default flash/SRAM partition
31+
*
32+
* Default flash partition:
33+
* Secure: 256KiB
34+
* Non-secure: 256KiB
35+
*
36+
* Default SRAM partition:
37+
* Secure: 32KiB
38+
* Non-secure: 64KiB
39+
*/
40+
#if defined(DOMAIN_NS) && DOMAIN_NS
41+
42+
/* Default non-secure ROM layout */
43+
#ifndef MBED_ROM_START
44+
#define MBED_ROM_START (0x10040000)
45+
#endif
46+
#ifndef MBED_ROM_SIZE
47+
#define MBED_ROM_SIZE (0x40000)
48+
#endif
49+
/* Default non-secure RAM layout */
50+
#ifndef MBED_RAM_START
51+
#define MBED_RAM_START (0x30008000)
52+
#endif
53+
#ifndef MBED_RAM_SIZE
54+
#define MBED_RAM_SIZE (0x10000)
55+
#endif
56+
57+
#else
58+
59+
/* Default secure ROM layout */
60+
#ifndef MBED_ROM_START
61+
#define MBED_ROM_START (0x0)
62+
#endif
63+
#ifndef MBED_ROM_SIZE
64+
#define MBED_ROM_SIZE (0x40000)
65+
#endif
66+
/* Default secure RAM layout */
67+
#ifndef MBED_RAM_START
68+
#define MBED_RAM_START (0x20000000)
69+
#endif
70+
#ifndef MBED_RAM_SIZE
71+
#define MBED_RAM_SIZE (0x8000)
72+
#endif
73+
74+
#endif
75+
76+
/* Resolved flash/SRAM partition */
77+
#if defined(DOMAIN_NS) && DOMAIN_NS
78+
79+
/* Resolved secure ROM layout */
80+
#define NU_ROM_START_S 0x0
81+
#define NU_ROM_SIZE_S (0x80000 - MBED_ROM_SIZE)
82+
/* Resolved secure RAM layout */
83+
#define NU_RAM_START_S 0x20000000
84+
#define NU_RAM_SIZE_S (0x18000 - MBED_RAM_SIZE)
85+
86+
/* Resolved non-secure ROM layout */
87+
#define NU_ROM_START_NS MBED_ROM_START
88+
#define NU_ROM_SIZE_NS MBED_ROM_SIZE
89+
/* Resolved non-secure RAM layout */
90+
#define NU_RAM_START_NS MBED_RAM_START
91+
#define NU_RAM_SIZE_NS MBED_RAM_SIZE
92+
93+
#else
94+
95+
/* Resolved secure ROM layout */
96+
#define NU_ROM_START_S MBED_ROM_START
97+
#define NU_ROM_SIZE_S MBED_ROM_SIZE
98+
/* Resolved secure RAM layout */
99+
#define NU_RAM_START_S MBED_RAM_START
100+
#define NU_RAM_SIZE_S MBED_RAM_SIZE
101+
102+
/* Resolved non-secure ROM layout */
103+
#define NU_ROM_START_NS (0x10000000 + MBED_ROM_SIZE)
104+
#define NU_ROM_SIZE_NS (0x80000 - MBED_ROM_SIZE)
105+
/* Resolved non-secure RAM layout */
106+
#define NU_RAM_START_NS (0x30000000 + MBED_RAM_SIZE)
107+
#define NU_RAM_SIZE_NS (0x18000 - MBED_RAM_SIZE)
108+
109+
#endif
110+
111+
#endif /* __PARTITION_M2351_MEM_H__ */

0 commit comments

Comments
 (0)