Skip to content

Commit e3b5f35

Browse files
authored
Merge pull request #12865 from OpenNuvoton/nuvoton_baremetal_nano130_m453
Nuvoton: Support bare-metal profile on NANO130 and M453
2 parents d5c9220 + e7dd405 commit e3b5f35

File tree

16 files changed

+732
-201
lines changed

16 files changed

+732
-201
lines changed
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/*
2+
* Copyright (c) 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 __M451_MEM_H__
20+
#define __M451_MEM_H__
21+
22+
/* About M451_mem.h/M451_mem.icf.h
23+
*
24+
* 1. M451_mem.h is created for centralizing memory configuration. It will be included by C/C++ files
25+
* and linker files (except IAR linker file).
26+
* 2. IAR linker doesn't support preprocessor, so M451_mem.icf.h, duplicate of M451_mem.h
27+
* is created for IAR linker file.
28+
* 3. To continue above, we name M451_mem.icf.h instead of M451_mem.icf because:
29+
* (1) Mbed OS build tool may mis-regard M451_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 M451_mem.icf.h instead because *.h files are always present in these builds
33+
* (already there or via copy).
34+
*/
35+
36+
/* Default memory specification
37+
*
38+
* Flash size: 256KiB
39+
* SRAM size: 32KiB
40+
*/
41+
42+
/* Resolve ROM start */
43+
#ifndef MBED_ROM_START
44+
#define MBED_ROM_START (0x0)
45+
#endif
46+
47+
/* Resolve ROM size */
48+
#ifndef MBED_ROM_SIZE
49+
#define MBED_ROM_SIZE (0x40000)
50+
#endif
51+
52+
/* Resolve RAM start */
53+
#ifndef MBED_RAM_START
54+
#define MBED_RAM_START (0x20000000)
55+
#endif
56+
57+
/* Resolve RAM size */
58+
#ifndef MBED_RAM_SIZE
59+
#define MBED_RAM_SIZE (0x8000)
60+
#endif
61+
62+
63+
/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just
64+
* MBED_APP_xxx macros to linker files even though they mean the same thing.
65+
* Because this file is to include by both C/C++ files and linker files, we add
66+
* these macros according to the others for consistency when they are missing
67+
* in compile or link stage. */
68+
69+
#ifndef APPLICATION_ADDR
70+
#ifdef MBED_APP_START
71+
#define APPLICATION_ADDR MBED_APP_START
72+
#else
73+
#define APPLICATION_ADDR MBED_ROM_START
74+
#endif
75+
#endif
76+
77+
#ifndef APPLICATION_SIZE
78+
#ifdef MBED_APP_SIZE
79+
#define APPLICATION_SIZE MBED_APP_SIZE
80+
#else
81+
#define APPLICATION_SIZE MBED_ROM_SIZE
82+
#endif
83+
#endif
84+
85+
#ifndef APPLICATION_RAM_ADDR
86+
#ifdef MBED_RAM_APP_START
87+
#define APPLICATION_RAM_ADDR MBED_RAM_APP_START
88+
#else
89+
#define APPLICATION_RAM_ADDR MBED_RAM_START
90+
#endif
91+
#endif
92+
93+
#ifndef APPLICATION_RAM_SIZE
94+
#ifdef MBED_RAM_APP_SIZE
95+
#define APPLICATION_RAM_SIZE MBED_RAM_APP_SIZE
96+
#else
97+
#define APPLICATION_RAM_SIZE MBED_RAM_SIZE
98+
#endif
99+
#endif
100+
101+
#ifndef MBED_APP_START
102+
#define MBED_APP_START APPLICATION_ADDR
103+
#endif
104+
105+
#ifndef MBED_APP_SIZE
106+
#define MBED_APP_SIZE APPLICATION_SIZE
107+
#endif
108+
109+
#ifndef MBED_RAM_APP_START
110+
#define MBED_RAM_APP_START APPLICATION_RAM_ADDR
111+
#endif
112+
113+
#ifndef MBED_RAM_APP_SIZE
114+
#define MBED_RAM_APP_SIZE APPLICATION_RAM_SIZE
115+
#endif
116+
117+
#if (APPLICATION_ADDR != MBED_APP_START)
118+
#error("APPLICATION_ADDR and MBED_APP_START are not the same!!!")
119+
#endif
120+
121+
#if (APPLICATION_SIZE != MBED_APP_SIZE)
122+
#error("APPLICATION_SIZE and MBED_APP_SIZE are not the same!!!")
123+
#endif
124+
125+
#if (APPLICATION_RAM_ADDR != MBED_RAM_APP_START)
126+
#error("APPLICATION_RAM_ADDR and MBED_RAM_APP_START are not the same!!!")
127+
#endif
128+
129+
#if (APPLICATION_RAM_SIZE != MBED_RAM_APP_SIZE)
130+
#error("APPLICATION_RAM_SIZE and MBED_RAM_APP_SIZE are not the same!!!")
131+
#endif
132+
133+
#endif /* __M451_MEM_H__ */
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/*
2+
* Copyright (c) 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+
/* See M451_mem.h for documentation */
20+
21+
/* Default memory specification
22+
*
23+
* Flash size: 256KiB
24+
* SRAM size: 32KiB
25+
*/
26+
27+
/* Resolve ROM start */
28+
if (!isdefinedsymbol(MBED_ROM_START)) {
29+
define symbol MBED_ROM_START = 0x0;
30+
}
31+
32+
/* Resolve ROM size */
33+
if (!isdefinedsymbol(MBED_ROM_SIZE)) {
34+
define symbol MBED_ROM_SIZE = 0x40000;
35+
}
36+
37+
/* Resolve RAM start */
38+
if (!isdefinedsymbol(MBED_RAM_START)) {
39+
define symbol MBED_RAM_START = 0x20000000;
40+
}
41+
42+
/* Resolve RAM size */
43+
if (!isdefinedsymbol(MBED_RAM_SIZE)) {
44+
define symbol MBED_RAM_SIZE = 0x8000;
45+
}
46+
47+
/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just
48+
* MBED_APP_xxx macros to linker files even though they mean the same thing.
49+
* Because this file is to include by both C/C++ files and linker files, we add
50+
* these macros according to the others for consistency when they are missing
51+
* in compile or link stage. */
52+
53+
if (!isdefinedsymbol(APPLICATION_ADDR)) {
54+
if (isdefinedsymbol(MBED_APP_START)) {
55+
define symbol APPLICATION_ADDR = MBED_APP_START;
56+
} else {
57+
define symbol APPLICATION_ADDR = MBED_ROM_START;
58+
}
59+
}
60+
61+
if (!isdefinedsymbol(APPLICATION_SIZE)) {
62+
if (isdefinedsymbol(MBED_APP_SIZE)) {
63+
define symbol APPLICATION_SIZE = MBED_APP_SIZE;
64+
} else {
65+
define symbol APPLICATION_SIZE = MBED_ROM_SIZE;
66+
}
67+
}
68+
69+
if (!isdefinedsymbol(APPLICATION_RAM_ADDR)) {
70+
if (isdefinedsymbol(MBED_RAM_APP_START)) {
71+
define symbol APPLICATION_RAM_ADDR = MBED_RAM_APP_START;
72+
} else {
73+
define symbol APPLICATION_RAM_ADDR = MBED_RAM_START;
74+
}
75+
}
76+
77+
if (!isdefinedsymbol(APPLICATION_RAM_SIZE)) {
78+
if (isdefinedsymbol(MBED_RAM_APP_SIZE)) {
79+
define symbol APPLICATION_RAM_SIZE = MBED_RAM_APP_SIZE;
80+
} else {
81+
define symbol APPLICATION_RAM_SIZE = MBED_RAM_SIZE;
82+
}
83+
}
84+
85+
if (!isdefinedsymbol(MBED_APP_START)) {
86+
define symbol MBED_APP_START = APPLICATION_ADDR;
87+
}
88+
89+
if (!isdefinedsymbol(MBED_APP_SIZE)) {
90+
define symbol MBED_APP_SIZE = APPLICATION_SIZE;
91+
}
92+
93+
if (!isdefinedsymbol(MBED_RAM_APP_START)) {
94+
define symbol MBED_RAM_APP_START = APPLICATION_RAM_ADDR;
95+
}
96+
97+
if (!isdefinedsymbol(MBED_RAM_APP_SIZE)) {
98+
define symbol MBED_RAM_APP_SIZE = APPLICATION_RAM_SIZE;
99+
}
100+
101+
if (APPLICATION_ADDR != MBED_APP_START) {
102+
error "APPLICATION_ADDR and MBED_APP_START are not the same!!!";
103+
}
104+
105+
if (APPLICATION_SIZE != MBED_APP_SIZE) {
106+
error "APPLICATION_SIZE and MBED_APP_SIZE are not the same!!!";
107+
}
108+
109+
if (APPLICATION_RAM_ADDR != MBED_RAM_APP_START) {
110+
error "APPLICATION_RAM_ADDR and MBED_RAM_APP_START are not the same!!!";
111+
}
112+
113+
if (APPLICATION_RAM_SIZE != MBED_RAM_APP_SIZE) {
114+
error "APPLICATION_RAM_SIZE and MBED_RAM_APP_SIZE are not the same!!!";
115+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#! armcc -E
2+
3+
/*
4+
* Copyright (c) 2020, Nuvoton Technology Corporation
5+
*
6+
* SPDX-License-Identifier: Apache-2.0
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
21+
#include "../M451_mem.h"
22+
23+
#if !defined(MBED_BOOT_STACK_SIZE)
24+
#define MBED_BOOT_STACK_SIZE 0x400
25+
#endif
26+
27+
#define VECTOR_SIZE (4*(16 + 64))
28+
29+
LR_IROM1 MBED_APP_START MBED_APP_SIZE {
30+
ER_IROM1 MBED_APP_START MBED_APP_SIZE { ; load address = execution address
31+
*(RESET, +First)
32+
*(InRoot$$Sections)
33+
.ANY (+RO)
34+
}
35+
36+
ARM_LIB_STACK MBED_RAM_APP_START EMPTY MBED_BOOT_STACK_SIZE {
37+
}
38+
39+
/* VTOR[TBLOFF] alignment requires:
40+
*
41+
* 1. Minumum 32-word
42+
* 2. Rounding up to the next power of two of table size
43+
*/
44+
ER_IRAMVEC AlignExpr(+0, 512) EMPTY VECTOR_SIZE { ; Reserve for vectors
45+
}
46+
47+
RW_IRAM1 AlignExpr(+0, 16) { ; 16 byte-aligned
48+
.ANY (+RW +ZI)
49+
}
50+
51+
ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_APP_START + MBED_RAM_APP_SIZE - AlignExpr(ImageLimit(RW_IRAM1), 16)) {
52+
}
53+
}
54+
55+
ScatterAssert(LoadLimit(LR_IROM1) <= (MBED_APP_START + MBED_APP_SIZE))
56+
ScatterAssert(ImageLimit(ARM_LIB_HEAP) <= (MBED_RAM_APP_START + MBED_RAM_APP_SIZE))
57+

targets/TARGET_NUVOTON/TARGET_M451/device/TOOLCHAIN_ARM_MICRO/M453.sct

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

0 commit comments

Comments
 (0)