Skip to content

Commit 59675ae

Browse files
committed
Update linker script for Corstone-320 (simplify)
1 parent e647b35 commit 59675ae

2 files changed

Lines changed: 88 additions & 364 deletions

File tree

board/Corstone-320/Corstone-320.ld

Lines changed: 88 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,27 @@
11
/*
2-
* Copyright 2025 Arm Limited and/or its affiliates.
2+
* Copyright (c) 2025 Arm Limited. All rights reserved.
33
*
4-
* This source code is licensed under the BSD-style license found in the
5-
* LICENSE file in the root directory of this source tree.
6-
*/
7-
8-
/*
9-
* This is a simplified linkerscript for the Corstone-300 memory system.
10-
* This example has been modified to place certain sections in specific memory.
11-
* Please refer to the Corstone SSE-300 Technical Reference Manual for
12-
* further information.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the License); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
139
*
14-
* https://developer.arm.com/Processors/Corstone-320
10+
* 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, WITHOUT
14+
* 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.
1517
*/
1618

17-
/* default value - '1', for DRAM */
18-
#ifndef ETHOSU_MODEL
19-
#define ETHOSU_MODEL 1
20-
#endif
21-
22-
/* default value - '1', for DRAM */
23-
#ifndef ETHOSU_ARENA
24-
#define ETHOSU_ARENA 1
25-
#endif
26-
27-
/*
28-
#ifndef STACK_SIZE
29-
#define STACK_SIZE 0x8000
30-
#endif
31-
*/
32-
33-
/*
34-
#ifndef HEAP_SIZE
35-
#define HEAP_SIZE 0x10000
36-
#endif
37-
*/
38-
3919
__STACK_SIZE = 0x8000;
4020
__HEAP_SIZE = 0x10000;
4121

22+
/* ----------------------------------------------------------------------------
23+
Memory definition
24+
*----------------------------------------------------------------------------*/
4225
MEMORY
4326
{
4427
ITCM (rwx) : ORIGIN = 0x10000000, LENGTH = 0x00008000
@@ -50,16 +33,8 @@ MEMORY
5033
DDR (rw) : ORIGIN = 0x70000000, LENGTH = 0x10000000
5134
}
5235

53-
PHDRS
54-
{
55-
rom_boot PT_LOAD;
56-
rom_exec PT_LOAD;
57-
rom_dram PT_LOAD;
58-
null PT_NULL;
59-
}
60-
6136
/* Linker script to place sections and symbol values. Should be used together
62-
* with other linker script that defines memory regions ITCM and RAM.
37+
* with other linker script that defines memory regions ROM and RAM.
6338
* It references following symbols, which must be defined in code:
6439
* Reset_Handler : Entry of reset handler
6540
*
@@ -70,7 +45,7 @@ PHDRS
7045
* __copy_table_end__
7146
* __zero_table_start__
7247
* __zero_table_end__
73-
* __etext
48+
* __etext (deprecated)
7449
* __data_start__
7550
* __preinit_array_start
7651
* __preinit_array_end
@@ -81,40 +56,27 @@ PHDRS
8156
* __data_end__
8257
* __bss_start__
8358
* __bss_end__
59+
* __noinit_start
60+
* __noinit_end
8461
* __end__
8562
* end
8663
* __HeapLimit
8764
* __StackLimit
8865
* __StackTop
8966
* __stack
9067
*/
91-
9268
ENTRY(Reset_Handler)
9369

9470
SECTIONS
9571
{
9672
.text.vectors :
9773
{
9874
KEEP(*(.vectors))
99-
} > BROM :rom_boot
100-
101-
/*
102-
/* Vector table relocation to read write memory
103-
* Alignment requirement from up to 496 interrupts, rounded to the closest
104-
* power of two equals 512 (words), thus 2048 bytes.
105-
*/
106-
.data.vtable_rw (COPY):
107-
{
108-
. = ALIGN(0x800);
109-
KEEP(*(.vtable_rw))
110-
} > ITCM :null
75+
} > BROM
11176

11277
.text :
11378
{
114-
*crt* (.text*)
115-
*startup_ARMCM85.c.obj (.text*)
116-
*system_ARMCM85.c.obj (.text*)
117-
*target.cpp.obj (.text*)
79+
*(.text*)
11880

11981
KEEP(*(.init))
12082
KEEP(*(.fini))
@@ -133,48 +95,42 @@ SECTIONS
13395
*(SORT(.dtors.*))
13496
*(.dtors)
13597

136-
*(.text*)
98+
*(.rodata*)
13799

138100
KEEP(*(.eh_frame*))
139-
} > BRAM :rom_exec
101+
} > BRAM
140102

141-
.data :
103+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
104+
.gnu.sgstubs :
142105
{
143-
. = ALIGN(4);
144-
__data_start__ = .;
145-
146-
*(vtable)
147-
*(.data)
148-
*(.data.*)
149-
*(.rodata*)
150-
151-
. = ALIGN(4);
152-
__data_end__ = .;
153-
} > BRAM :rom_exec
106+
. = ALIGN(32);
107+
} > BRAM
108+
#endif
154109

155110
.ARM.extab :
156111
{
157112
*(.ARM.extab* .gnu.linkonce.armextab.*)
158-
} > BRAM :rom_exec
113+
} > BRAM
159114

115+
__exidx_start = .;
160116
.ARM.exidx :
161117
{
162-
__exidx_start = .;
163118
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
119+
120+
} > BRAM
164121
__exidx_end = .;
165-
} > BRAM :rom_exec
166122

167123
.copy.table :
168124
{
169125
. = ALIGN(4);
170126
__copy_table_start__ = .;
171127

172-
LONG (LOADADDR(.sram))
173-
LONG (ADDR(.sram))
174-
LONG (SIZEOF(.sram) / 4)
128+
LONG (LOADADDR(.data))
129+
LONG (ADDR(.data))
130+
LONG (SIZEOF(.data) / 4)
175131

176132
__copy_table_end__ = .;
177-
} > BRAM :rom_exec
133+
} > BRAM
178134

179135
.zero.table :
180136
{
@@ -184,21 +140,22 @@ SECTIONS
184140
LONG (ADDR(.bss))
185141
LONG (SIZEOF(.bss) / 4)
186142

187-
LONG (ADDR(.sram.bss))
188-
LONG (SIZEOF(.sram.bss) / 4)
189-
190143
__zero_table_end__ = .;
191-
} > BRAM :rom_exec
192144

193-
.sram : AT(__etext)
194-
{
195-
#if (ETHOSU_MODEL == 0)
196-
. = ALIGN(16);
197-
*(network_model_sec)
198-
#endif
145+
} > BRAM
199146

200-
. = ALIGN(16);
201-
*(.sram.data)
147+
/*
148+
* This __etext variable is kept for backward compatibility with older,
149+
* ASM based startup files.
150+
*/
151+
PROVIDE(__etext = LOADADDR(.data));
152+
153+
.data : ALIGN(4)
154+
{
155+
__data_start__ = .;
156+
*(vtable)
157+
*(.data)
158+
*(.data.*)
202159

203160
. = ALIGN(4);
204161
/* preinit data */
@@ -221,86 +178,75 @@ SECTIONS
221178
PROVIDE_HIDDEN (__fini_array_end = .);
222179

223180
KEEP(*(.jcr*))
224-
} > SRAM :rom_dram
181+
. = ALIGN(4);
182+
/* All data end */
183+
__data_end__ = .;
184+
} > SRAM AT > BRAM
225185

226-
.sram.bss :
186+
.bss :
187+
{
188+
. = ALIGN(4);
189+
__bss_start__ = .;
190+
*(.bss)
191+
*(.bss.*)
192+
*(COMMON)
193+
. = ALIGN(4);
194+
__bss_end__ = .;
195+
} > SRAM AT > BRAM
196+
197+
.sram.bss (NOLOAD) :
227198
{
228-
#if (ETHOSU_ARENA == 0)
229199
. = ALIGN(32);
230200
*(.bss.tensor_arena)
231-
#endif
201+
} > SRAM AT > BRAM
232202

233-
. = ALIGN(16);
234-
*(.bss.ethosu_scratch);
235-
} > SRAM :null
203+
/* This section contains data that is not initialized during load,
204+
or during the application's initialization sequence. */
205+
.noinit (NOLOAD) :
206+
{
207+
. = ALIGN(4);
208+
__noinit_start = .;
209+
*(.noinit)
210+
*(.noinit.*)
211+
. = ALIGN(4);
212+
__noinit_end = .;
213+
} > SRAM
236214

237215
.ddr :
238216
{
239-
#if (ETHOSU_ARENA == 1)
240-
. = ALIGN(32);
241-
*(.bss.tensor_arena)
242-
#endif
243-
244-
#if (ETHOSU_MODEL == 1)
245217
. = ALIGN(16);
246218
*(network_model_sec)
247-
#endif
219+
* (.got*)
248220

249-
. = ALIGN(4);
250-
*(input_data_sec)
251-
*(expected_output_data_sec)
252-
*(output_data_sec)
253-
254-
*(ethosu_core_in_queue ethosu_core_out_queue)
221+
} > DDR
255222

256-
/* Place data for scatter loading here */
257-
__etext = .;
258-
} > DDR :rom_dram
259-
.asan_shadow (NOLOAD) :
260-
{
261-
. = ALIGN(16);
262-
__asan_shadow_start = .;
263-
KEEP(*(.asan_shadow))
264-
__asan_shadow_end = .;
265-
} > DDR :null
266223
.ddr_noload (NOLOAD) :
267224
{
268225
. = ALIGN(16);
269226
*(input_data_sec)
270-
} > DDR :null
271-
.bss :
272-
{
273-
. = ALIGN(4);
274-
__bss_start__ = .;
227+
} > DDR
275228

276-
*(.bss)
277-
*(.bss.*)
278-
*(COMMON)
279-
280-
. = ALIGN(4);
281-
__bss_end__ = .;
282-
} > BRAM :null
283-
284-
.heap (ORIGIN(BRAM) + LENGTH(BRAM) - __HEAP_SIZE) (COPY) :
229+
.heap (NOLOAD) :
285230
{
286231
. = ALIGN(8);
287232
__end__ = .;
288233
PROVIDE(end = .);
289234
. = . + __HEAP_SIZE;
290235
. = ALIGN(8);
291236
__HeapLimit = .;
292-
} > BRAM :null
237+
} > SRAM
293238

294-
.stack (ORIGIN(DTCM) + LENGTH(DTCM) - __STACK_SIZE) (COPY) :
239+
.stack (ORIGIN(SRAM) + LENGTH(SRAM) - __STACK_SIZE) (NOLOAD) :
295240
{
296241
. = ALIGN(8);
297242
__StackLimit = .;
298243
. = . + __STACK_SIZE;
299244
. = ALIGN(8);
300245
__StackTop = .;
301-
} > DTCM :null
246+
} > SRAM
247+
302248
PROVIDE(__stack = __StackTop);
303249

304-
/* Check if stack exceeds DTCM limit */
305-
ASSERT(LENGTH(DTCM) >= __STACK_SIZE, "region DTCM overflowed with stack")
250+
/* Check if data + heap + stack exceeds RAM limit */
251+
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
306252
}

0 commit comments

Comments
 (0)