blob: 091a1177d90a51fd822a94e6f682d85c610d89a7 [file] [log] [blame]
Kristofer Jonsson43ce4912020-11-20 09:42:53 +01001/*
Per Åstrand81e01af2021-02-19 13:45:26 +01002 * Copyright (c) 2009-2021 Arm Limited. All rights reserved.
Kristofer Jonsson43ce4912020-11-20 09:42:53 +01003 *
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
9 *
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.
17 */
18
19/*
20 *-------- <<< Use Configuration Wizard in Context Menu >>> -------------------
21 */
22
23/*---------------------- ITCM Configuration ----------------------------------
24 <h> Flash Configuration
25 <o0> Flash Base Address <0x0-0xFFFFFFFF:8>
26 <o1> Flash Size (in Bytes) <0x0-0xFFFFFFFF:8>
27 </h>
28 -----------------------------------------------------------------------------*/
29__ROM_BASE = 0x00000000;
30__ROM_SIZE = 0x00080000;
31
32/*--------------------- DTCM RAM Configuration ----------------------------
33 <h> RAM Configuration
34 <o0> RAM Base Address <0x0-0xFFFFFFFF:8>
35 <o1> RAM Size (in Bytes) <0x0-0xFFFFFFFF:8>
36 </h>
37 -----------------------------------------------------------------------------*/
38__RAM_BASE = 0x20000000;
39__RAM_SIZE = 0x00080000;
40
41/*--------------------- Embedded SRAM Configuration ----------------------------
42 <h> SRAM Configuration
43 <o0> SRAM Base Address <0x0-0xFFFFFFFF:8>
44 <o1> SRAM Size (in Bytes) <0x0-0xFFFFFFFF:8>
45 </h>
46 -----------------------------------------------------------------------------*/
47__SRAM_BASE = 0x21000000;
48__SRAM_SIZE = 0x00200000;
49
50/*--------------------- Stack / Heap Configuration ----------------------------
51 <h> Stack / Heap Configuration
52 <o0> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
53 <o1> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
54 </h>
55 -----------------------------------------------------------------------------*/
56__STACK_SIZE = 0x00008000;
57__HEAP_SIZE = 0x00008000;
58
59/*--------------------- Embedded RAM Configuration ----------------------------
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +010060 <h> BRAM Configuration
61 <o0> BRAM Base Address <0x0-0xFFFFFFFF:8>
62 <o1> BRAM Size (in Bytes) <0x0-0xFFFFFFFF:8>
63 </h>
64 -----------------------------------------------------------------------------*/
65__BRAM_BASE = 0x11000000;
66__BRAM_SIZE = 0x00200000;
67
68/*--------------------- Embedded RAM Configuration ----------------------------
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010069 <h> DDR Configuration
70 <o0> DDR Base Address <0x0-0xFFFFFFFF:8>
71 <o1> DDR Size (in Bytes) <0x0-0xFFFFFFFF:8>
72 </h>
73 -----------------------------------------------------------------------------*/
74__DDR_BASE = 0x60000000;
75__DDR_SIZE = 0x02000000;
76
77/*
78 *-------------------- <<< end of configuration section >>> -------------------
79 */
80
81MEMORY
82{
83 ITCM (rx) : ORIGIN = __ROM_BASE, LENGTH = __ROM_SIZE
84 DTCM (rwx) : ORIGIN = __RAM_BASE, LENGTH = __RAM_SIZE
85 SRAM (rwx) : ORIGIN = __SRAM_BASE, LENGTH = __SRAM_SIZE
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +010086 BRAM (rwx) : ORIGIN = __BRAM_BASE, LENGTH = __BRAM_SIZE
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010087 DDR (rwx) : ORIGIN = __DDR_BASE, LENGTH = __DDR_SIZE
88}
89
90/* Linker script to place sections and symbol values. Should be used together
91 * with other linker script that defines memory regions ITCM and RAM.
92 * It references following symbols, which must be defined in code:
93 * Reset_Handler : Entry of reset handler
94 *
95 * It defines following symbols, which code can use without definition:
96 * __exidx_start
97 * __exidx_end
98 * __copy_table_start__
99 * __copy_table_end__
100 * __zero_table_start__
101 * __zero_table_end__
102 * __etext
103 * __data_start__
104 * __preinit_array_start
105 * __preinit_array_end
106 * __init_array_start
107 * __init_array_end
108 * __fini_array_start
109 * __fini_array_end
110 * __data_end__
111 * __bss_start__
112 * __bss_end__
113 * __end__
114 * end
115 * __HeapLimit
116 * __StackLimit
117 * __StackTop
118 * __stack
119 */
120ENTRY(Reset_Handler)
121
122SECTIONS
123{
124 .text :
125 {
126 KEEP(*(.vectors))
127 *(.text*)
128
129 KEEP(*(.init))
130 KEEP(*(.fini))
131
132 /* .ctors */
133 *crtbegin.o(.ctors)
134 *crtbegin?.o(.ctors)
135 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
136 *(SORT(.ctors.*))
137 *(.ctors)
138
139 /* .dtors */
140 *crtbegin.o(.dtors)
141 *crtbegin?.o(.dtors)
142 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
143 *(SORT(.dtors.*))
144 *(.dtors)
145
146 *(.rodata*)
147
148 KEEP(*(.eh_frame*))
149 } > ITCM
150
151 /*
152 * SG veneers:
153 * All SG veneers are placed in the special output section .gnu.sgstubs. Its start address
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100154 * must be set, either with the command line option '--section-start' or in a linker script,
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100155 * to indicate where to place these veneers in memory.
156 */
157/*
158 .gnu.sgstubs :
159 {
160 . = ALIGN(32);
161 } > ITCM
162*/
163 .ARM.extab :
164 {
165 *(.ARM.extab* .gnu.linkonce.armextab.*)
166 } > ITCM
167
168 __exidx_start = .;
169 .ARM.exidx :
170 {
171 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
172 } > ITCM
173 __exidx_end = .;
174
175 .copy.table :
176 {
177 . = ALIGN(4);
178 __copy_table_start__ = .;
179 LONG (__etext)
180 LONG (__data_start__)
181 LONG (__data_end__ - __data_start__)
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100182
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100183 /* Add each additional data section here */
184 __copy_table_end__ = .;
185 } > ITCM
186
187 .zero.table :
188 {
189 . = ALIGN(4);
190 __zero_table_start__ = .;
191 /* Add each additional bss section here */
192/*
193 LONG (__bss2_start__)
194 LONG (__bss2_end__ - __bss2_start__)
195*/
196 __zero_table_end__ = .;
197 } > ITCM
198
199 /**
200 * Location counter can end up 2byte aligned with narrow Thumb code but
201 * __etext is assumed by startup code to be the LMA of a section in DTCM
202 * which must be 4byte aligned
203 */
204 __etext = ALIGN (4);
205
206 .data : AT (__etext)
207 {
208 __data_start__ = .;
209 *(vtable)
210 *(.data)
211 *(.data.*)
212
213 . = ALIGN(4);
214 /* preinit data */
215 PROVIDE_HIDDEN (__preinit_array_start = .);
216 KEEP(*(.preinit_array))
217 PROVIDE_HIDDEN (__preinit_array_end = .);
218
219 . = ALIGN(4);
220 /* init data */
221 PROVIDE_HIDDEN (__init_array_start = .);
222 KEEP(*(SORT(.init_array.*)))
223 KEEP(*(.init_array))
224 PROVIDE_HIDDEN (__init_array_end = .);
225
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100226 . = ALIGN(4);
227 /* finit data */
228 PROVIDE_HIDDEN (__fini_array_start = .);
229 KEEP(*(SORT(.fini_array.*)))
230 KEEP(*(.fini_array))
231 PROVIDE_HIDDEN (__fini_array_end = .);
232
233 KEEP(*(.jcr*))
234 . = ALIGN(4);
235 /* All data end */
236 __data_end__ = .;
237
238 } > DTCM
239
240 /*
241 * Secondary data section, optional
242 *
243 * Remember to add each additional data section
244 * to the .copy.table above to asure proper
245 * initialization during startup.
246 */
247/*
248 __etext2 = ALIGN (4);
249
250 .data2 : AT (__etext2)
251 {
252 . = ALIGN(4);
253 __data2_start__ = .;
254 *(.data2)
255 *(.data2.*)
256 . = ALIGN(4);
257 __data2_end__ = .;
258
259 } > RAM2
260*/
261
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100262 .sram :
263 {
264 . = ALIGN(16);
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100265#ifdef ETHOSU_FAST_MEMORY_SIZE
Per Åstrand81e01af2021-02-19 13:45:26 +0100266 *(.bss.ethosu_scratch);
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100267#else
268 *(.bss.tensor_arena)
269#endif
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100270
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100271 . = ALIGN(16);
272 *(.sram.data)
273 } > BRAM AT > BRAM
274
275 .ddr :
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100276 {
277 . = ALIGN(16);
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100278#ifdef ETHOSU_FAST_MEMORY_SIZE
Jonny Svärdf521be92021-03-01 14:35:49 +0100279 *(.bss.tensor_arena)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100280#endif
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100281 . = ALIGN(16);
282 *(input_data_sec)
283
284 . = ALIGN(16);
285 *(network_model_sec)
286
287 . = ALIGN (16);
288 *(expected_output_data_sec)
289 } > DDR AT > DDR
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100290
291 .bss :
292 {
293 . = ALIGN(4);
294 __bss_start__ = .;
295 *(.bss)
296 *(.bss.*)
297 *(COMMON)
298 . = ALIGN(4);
299 __bss_end__ = .;
300 } > DTCM AT > DTCM
301
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100302 /*
303 * Secondary bss section, optional
304 *
305 * Remember to add each additional bss section
306 * to the .zero.table above to asure proper
307 * initialization during startup.
308 */
309/*
310 .bss2 :
311 {
312 . = ALIGN(4);
313 __bss2_start__ = .;
314 *(.bss2)
315 *(.bss2.*)
316 . = ALIGN(4);
317 __bss2_end__ = .;
318 } > RAM2 AT > RAM2
319*/
320
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100321 .heap (COPY) :
322 {
323 . = ALIGN(8);
324 __end__ = .;
325 PROVIDE(end = .);
326 . = . + __HEAP_SIZE;
327 . = ALIGN(8);
328 __HeapLimit = .;
329 } > DTCM
330
331 .stack (ORIGIN(DTCM) + LENGTH(DTCM) - __STACK_SIZE) (COPY) :
332 {
333 . = ALIGN(8);
334 __StackLimit = .;
335 . = . + __STACK_SIZE;
336 . = ALIGN(8);
337 __StackTop = .;
338 } > DTCM
339 PROVIDE(__stack = __StackTop);
340
341 /* Check if data + heap + stack exceeds DTCM limit */
342 ASSERT(__StackLimit >= __HeapLimit, "region DTCM overflowed with stack")
343}