Skip to content

Commit f1e304b

Browse files
authored
Merge pull request #13643 from OpenNuvoton/nuvoton_m2351_gcc_iar_5.15
M2351: Support GCC and IAR
2 parents f5633c4 + a76e49c commit f1e304b

File tree

18 files changed

+1307
-929
lines changed

18 files changed

+1307
-929
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#! armclang -E
2+
3+
/*
4+
* Copyright (c) 2019-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 "../../../device/partition_M2351_mem.h"
22+
23+
#if !defined(MBED_BOOT_STACK_SIZE)
24+
#define MBED_BOOT_STACK_SIZE 0x400
25+
#endif
26+
27+
LR_IROM1 MBED_APP_START
28+
{
29+
/* load address = execution address */
30+
ER_IROM1 +0
31+
{
32+
*(RESET, +First)
33+
*(InRoot$$Sections)
34+
.ANY (+RO)
35+
}
36+
37+
ARM_LIB_STACK MBED_RAM_APP_START EMPTY MBED_BOOT_STACK_SIZE
38+
{
39+
}
40+
41+
/* Reserve for vectors
42+
*
43+
* Vector table base address is required to be 128-byte aligned at a minimum.
44+
* A PE might impose further restrictions on it. */
45+
ER_IRAMVEC AlignExpr(+0, 128) EMPTY (4*(16 + 102))
46+
{
47+
}
48+
49+
RW_IRAM1 AlignExpr(+0, 16)
50+
{
51+
.ANY (+RW +ZI)
52+
}
53+
54+
ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_APP_START + MBED_RAM_APP_SIZE - AlignExpr(ImageLimit(RW_IRAM1), 16))
55+
{
56+
}
57+
}
58+
59+
ScatterAssert(LoadLimit(LR_IROM1) <= (MBED_APP_START + MBED_APP_SIZE))
60+
ScatterAssert(ImageLimit(ARM_LIB_HEAP) <= MBED_RAM_APP_START + MBED_RAM_APP_SIZE)
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
/*
2+
* Copyright (c) 2018-2019, 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+
/*
20+
* Nuvoton M2351 GCC linker script file
21+
*/
22+
23+
#include "../../../device/partition_M2351_mem.h"
24+
25+
#if !defined(MBED_BOOT_STACK_SIZE)
26+
#define MBED_BOOT_STACK_SIZE 0x400
27+
#endif
28+
29+
StackSize = MBED_BOOT_STACK_SIZE;
30+
31+
MEMORY
32+
{
33+
VECTORS (rx) : ORIGIN = MBED_APP_START, LENGTH = 0x00000400
34+
FLASH (rx) : ORIGIN = MBED_APP_START + 0x400, LENGTH = MBED_APP_SIZE - 0x400
35+
RAM_INTERN (rwx) : ORIGIN = MBED_RAM_APP_START, LENGTH = MBED_RAM_APP_SIZE
36+
}
37+
38+
/**
39+
* Must match cmsis_nvic.h
40+
*/
41+
__vector_size = 4 * (16 + 102);
42+
43+
44+
/* Linker script to place sections and symbol values. Should be used together
45+
* with other linker script that defines memory regions FLASH and RAM.
46+
* It references following symbols, which must be defined in code:
47+
* Reset_Handler : Entry of reset handler
48+
*
49+
* It defines following symbols, which code can use without definition:
50+
* __exidx_start
51+
* __exidx_end
52+
* __etext
53+
* __data_start__
54+
* __preinit_array_start
55+
* __preinit_array_end
56+
* __init_array_start
57+
* __init_array_end
58+
* __fini_array_start
59+
* __fini_array_end
60+
* __data_end__
61+
* __bss_start__
62+
* __bss_end__
63+
* __end__
64+
* end
65+
* __HeapLimit
66+
* __StackLimit
67+
* __StackTop
68+
* __stack
69+
*/
70+
ENTRY(Reset_Handler)
71+
72+
SECTIONS
73+
{
74+
.isr_vector :
75+
{
76+
__vector_table = .;
77+
KEEP(*(.vector_table))
78+
. = ALIGN(8);
79+
} > VECTORS
80+
81+
.copy.table : ALIGN(4)
82+
{
83+
__copy_table_start__ = .;
84+
LONG (LOADADDR(.data))
85+
LONG (ADDR(.data))
86+
LONG (SIZEOF(.data))
87+
__copy_table_end__ = .;
88+
} > FLASH
89+
90+
.zero.table : ALIGN(4)
91+
{
92+
__zero_table_start__ = .;
93+
LONG (ADDR(.bss))
94+
LONG (SIZEOF(.bss))
95+
__zero_table_end__ = .;
96+
} > FLASH
97+
98+
.text :
99+
{
100+
*(.text*)
101+
102+
KEEP(*(.init))
103+
KEEP(*(.fini))
104+
105+
/* .ctors */
106+
*crtbegin.o(.ctors)
107+
*crtbegin?.o(.ctors)
108+
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
109+
*(SORT(.ctors.*))
110+
*(.ctors)
111+
112+
/* .dtors */
113+
*crtbegin.o(.dtors)
114+
*crtbegin?.o(.dtors)
115+
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
116+
*(SORT(.dtors.*))
117+
*(.dtors)
118+
119+
*(.rodata*)
120+
121+
KEEP(*(.eh_frame*))
122+
} > FLASH
123+
124+
.stack (NOLOAD) :
125+
{
126+
. = ALIGN(8);
127+
__StackLimit = .;
128+
. += StackSize;
129+
__StackTop = .;
130+
} > RAM_INTERN
131+
132+
PROVIDE(__stack = __StackTop);
133+
134+
.ARM.extab :
135+
{
136+
*(.ARM.extab* .gnu.linkonce.armextab.*)
137+
} > FLASH
138+
139+
.ARM.exidx :
140+
{
141+
__exidx_start = .;
142+
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
143+
__exidx_end = .;
144+
} > FLASH
145+
146+
/* Relocate vector table in SRAM */
147+
.isr_vector.reloc (NOLOAD) :
148+
{
149+
. = ALIGN(1 << LOG2CEIL(__vector_size));
150+
PROVIDE(__start_vector_table__ = .);
151+
. += __vector_size;
152+
PROVIDE(__end_vector_table__ = .);
153+
} > RAM_INTERN
154+
155+
.data :
156+
{
157+
PROVIDE( __etext = LOADADDR(.data) );
158+
159+
__data_start__ = .;
160+
*(vtable)
161+
*(.data*)
162+
163+
. = ALIGN(8);
164+
/* preinit data */
165+
PROVIDE_HIDDEN (__preinit_array_start = .);
166+
KEEP(*(.preinit_array))
167+
PROVIDE_HIDDEN (__preinit_array_end = .);
168+
169+
. = ALIGN(8);
170+
/* init data */
171+
PROVIDE_HIDDEN (__init_array_start = .);
172+
KEEP(*(SORT(.init_array.*)))
173+
KEEP(*(.init_array))
174+
PROVIDE_HIDDEN (__init_array_end = .);
175+
176+
. = ALIGN(8);
177+
/* finit data */
178+
PROVIDE_HIDDEN (__fini_array_start = .);
179+
KEEP(*(SORT(.fini_array.*)))
180+
KEEP(*(.fini_array))
181+
PROVIDE_HIDDEN (__fini_array_end = .);
182+
183+
/* All data end */
184+
. = ALIGN(32);
185+
__data_end__ = .;
186+
187+
} >RAM_INTERN AT>FLASH
188+
189+
.bss (NOLOAD):
190+
{
191+
__bss_start__ = .;
192+
*(.bss*)
193+
*(COMMON)
194+
__bss_end__ = .;
195+
} > RAM_INTERN
196+
197+
.heap (NOLOAD) :
198+
{
199+
. = ALIGN(8);
200+
__end__ = .;
201+
end = __end__;
202+
*(.heap*);
203+
. += (ORIGIN(RAM_INTERN) + LENGTH(RAM_INTERN) - .);
204+
__HeapLimit = .;
205+
} > RAM_INTERN
206+
Image$$ARM_LIB_HEAP$$ZI$$Base = ADDR(.heap);
207+
Image$$ARM_LIB_HEAP$$ZI$$Limit = ADDR(.heap) + SIZEOF(.heap);
208+
209+
PROVIDE(__heap_size = SIZEOF(.heap));
210+
PROVIDE(__mbed_sbrk_start = ADDR(.heap));
211+
PROVIDE(__mbed_krbs_start = ADDR(.heap) + SIZEOF(.heap));
212+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (c) 2018-2019, 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+
/*###ICF### Section handled by ICF editor, don't touch! ****/
20+
/*-Editor annotation file-*/
21+
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
22+
23+
include "../../../device/partition_M2351_mem.icf.h";
24+
25+
if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) {
26+
define symbol MBED_BOOT_STACK_SIZE = 0x400;
27+
}
28+
29+
/*-Specials-*/
30+
define symbol __ICFEDIT_intvec_start__ = MBED_APP_START;
31+
/*-Memory Regions-*/
32+
define symbol __ICFEDIT_region_ROM_start__ = MBED_APP_START;
33+
define symbol __ICFEDIT_region_ROM_end__ = MBED_APP_START + MBED_APP_SIZE - 1;
34+
define symbol __ICFEDIT_region_IRAM_start__ = MBED_RAM_APP_START;
35+
define symbol __ICFEDIT_region_IRAM_end__ = MBED_RAM_APP_START + MBED_RAM_APP_SIZE - 1;
36+
37+
/*-Sizes-*/
38+
define symbol __ICFEDIT_size_cstack__ = MBED_BOOT_STACK_SIZE;
39+
define symbol __ICFEDIT_size_intvec__ = 4 * (16 + 102);
40+
define symbol __ICFEDIT_size_heap__ = 0x400;
41+
42+
/**** End of ICF editor section. ###ICF###*/
43+
44+
45+
define memory mem with size = 4G;
46+
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
47+
define region IRAM_region = mem:[from __ICFEDIT_region_IRAM_start__ to __ICFEDIT_region_IRAM_end__];
48+
49+
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
50+
define block HEAP with expanding size, alignment = 8, minimum size = __ICFEDIT_size_heap__ { };
51+
/* NOTE: Vector table base requires to be aligned to the power of vector table size. Give a safe value here. */
52+
define block IRAMVEC with alignment = 1024, size = __ICFEDIT_size_intvec__ { };
53+
54+
55+
initialize by copy { readwrite };
56+
do not initialize { section .noinit };
57+
58+
place at address mem: __ICFEDIT_intvec_start__ { readonly section .intvec };
59+
place in ROM_region { readonly };
60+
61+
place at start of IRAM_region { block CSTACK };
62+
place in IRAM_region { block IRAMVEC };
63+
place in IRAM_region { readwrite };
64+
place in IRAM_region { block HEAP };

0 commit comments

Comments
 (0)