blob: 35f59f69960388735eb8d791211710078c678868 [file] [log] [blame]
Kshitij Sisodia26bc9232023-03-10 16:33:23 +00001/*
2 * SPDX-FileCopyrightText: Copyright 2021, 2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18__STACK_SIZE = 0x00008000;
19__HEAP_SIZE = 0x000C0000;
20
21/* System memory brief */
22MEMORY
23{
24 ITCM (rx) : ORIGIN = 0x00000000, LENGTH = 0x00080000
25 DTCM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00080000
26 BRAM (rwx) : ORIGIN = 0x11000000, LENGTH = 0x00100000
27 SRAM (rwx) : ORIGIN = 0x31000000, LENGTH = 0x00200000
28 DDR (rwx) : ORIGIN = 0x70000000, LENGTH = 0x02000000
29
30 /* Dynamic load regions declared for use by FVP only
31 * These regions are mentioned in the CMake subsystem profile.
32 * Do not change the addresses here in isolation. */
33 DDR_dynamic_model (rx) : ORIGIN = 0x90000000, LENGTH = 0x02000000
34 DDR_dynamic_ifm (rx) : ORIGIN = 0x92000000, LENGTH = 0x01000000
35 DDR_dynamic_ofm (rx) : ORIGIN = 0x93000000, LENGTH = 0x01000000
36}
37
38/* Linker script to place sections and symbol values. Should be used together
39 * with other linker script that defines memory regions ITCM and RAM.
40 * It references following symbols, which must be defined in code:
41 * Reset_Handler : Entry of reset handler
42 *
43 * It defines following symbols, which code can use without definition:
44 * __exidx_start
45 * __exidx_end
46 * __copy_table_start__
47 * __copy_table_end__
48 * __zero_table_start__
49 * __zero_table_end__
50 * __etext
51 * __data_start__
52 * __preinit_array_start
53 * __preinit_array_end
54 * __init_array_start
55 * __init_array_end
56 * __fini_array_start
57 * __fini_array_end
58 * __data_end__
59 * __bss_start__
60 * __bss_end__
61 * __end__
62 * end
63 * __HeapLimit
64 * __StackLimit
65 * __StackTop
66 * __stack
67 */
68ENTRY(Reset_Handler)
69
70SECTIONS
71{
72 .text.at_itcm :
73 {
74 KEEP(*(.vectors))
75
76 /**
77 * Any code that is not time sensitive can be excluded from here.
78 * This code is instead placed on BRAM. See comment in the BRAM
79 * section for details.
80 */
Richard Burton4865c4f2023-11-13 15:21:11 +000081 *(EXCLUDE_FILE(*MicroMutableAllOpsResolver*.obj
Kshitij Sisodia26bc9232023-03-10 16:33:23 +000082 *hal.c.obj
83 *_allocator.o
84 *flatbuffer*.o
85 *Profiler*.obj
86 *lcd*.obj
Richard Burton49482d52023-11-30 11:38:45 +000087 *timing_adapter.c.obj
88 *s4*.o)
Kshitij Sisodia26bc9232023-03-10 16:33:23 +000089 .text*)
90
91 KEEP(*(.init))
92 KEEP(*(.fini))
93
94 /* .ctors */
95 *crtbegin.o(.ctors)
96 *crtbegin?.o(.ctors)
97 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
98 *(SORT(.ctors.*))
99 *(.ctors)
100
101 /* .dtors */
102 *crtbegin.o(.dtors)
103 *crtbegin?.o(.dtors)
104 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
105 *(SORT(.dtors.*))
106 *(.dtors)
107
108 KEEP(*(.eh_frame*))
109 } > ITCM
110
111 __exidx_start = .;
112 .ARM.exidx.at_itcm :
113 {
114 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
115 } > ITCM
116 __exidx_end = .;
117
118 .zero.table.at_itcm :
119 {
120 . = ALIGN(4);
121 __zero_table_start__ = .;
122
123 LONG (__bss_start__)
124 LONG ((__bss_end__ - __bss_start__)/4) /* Size is in 32-bit words */
125
126 __zero_table_end__ = .;
127 } > ITCM
128
129 .copy.table.at_itcm :
130 {
131 . = ALIGN(4);
132 __copy_table_start__ = .;
133
134 /* Section to be copied - part 1: any data to be placed in BRAM */
135 LONG (__etext)
136 LONG (__data_start__)
137 LONG ((__data_end__ - __data_start__)/4) /* Size is in 32-bit words */
138
139 /* Section to be copied - part 2: RO data for for DTCM */
140 LONG (__etext2)
141 LONG (__ro_data_start__)
142 LONG ((__ro_data_end__ - __ro_data_start__)/4) /* Size is in 32-bit words */
143
144 __copy_table_end__ = .;
145 } > ITCM
146
147 __itcm_total = ALIGN(4);
148
149 ASSERT( __itcm_total < (ORIGIN(ITCM) + LENGTH(ITCM)), "ITCM overflow")
150
151 .sram :
152 {
153 . = ALIGN(16);
154 /* Cache area (if used) */
155 *(.bss.NoInit.ethos_u_cache)
156 . = ALIGN (16);
157 /* activation buffers a.k.a tensor arena when memory mode sram only or shared sram */
158 *(.bss.NoInit.activation_buf_sram)
159 . = ALIGN(16);
160 } > SRAM AT > SRAM
161
162 .bss :
163 {
164 . = ALIGN(4);
165 __bss_start__ = .;
166 *(.bss)
167 *(.bss.*)
168 *(COMMON)
169 . = ALIGN(4);
170 __bss_end__ = .;
171 } > DTCM AT > DTCM
172
173 .stack (ORIGIN(DTCM) + LENGTH(DTCM) - __STACK_SIZE) (COPY) :
174 {
175 . = ALIGN(8);
176 __StackLimit = .;
177 . = . + __STACK_SIZE;
178 . = ALIGN(8);
179 __StackTop = .;
180 } > DTCM
181 PROVIDE(__stack = __StackTop);
182 ASSERT(
183 (__STACK_SIZE + __bss_end__ - __bss_start__) <= LENGTH(DTCM),
184 "DTCM overflow")
185
186 .ddr.at_ddr :
187 {
188 /* __attribute__((aligned(16))) is not handled by the CMSIS startup code.
189 * Force the alignment here as a workaround */
190 . = ALIGN(16);
191 /* nn model's baked in input matrices */
192 *(ifm)
193 . = ALIGN(16);
194 /* nn model's default space */
195 *(nn_model)
196 . = ALIGN (16);
197 /* labels */
198 *(labels)
199 . = ALIGN (16);
Richard Burton973158f2023-11-06 14:40:28 +0000200 *Labels*.obj (*.rodata*)
201 . = ALIGN (16);
Kshitij Sisodia26bc9232023-03-10 16:33:23 +0000202 /* activation buffers a.k.a tensor arena when memory mode dedicated sram */
203 *(activation_buf_dram)
204 . = ALIGN (16);
205 } > DDR AT > DDR
206
207 .text.at_ddr :
208 {
209 . = ALIGN(4);
210 *Profiler*.obj (*.text*)
211 . = ALIGN(4);
Richard Burton49482d52023-11-30 11:38:45 +0000212 *s4*.o (*.text*) /* Temporary solution to move s4 operations to DDR. */
213 . = ALIGN(4);
Kshitij Sisodia26bc9232023-03-10 16:33:23 +0000214 } > DDR AT > DDR
215
216 /**
217 * Location counter can end up 2byte aligned with narrow Thumb code but
218 * __etext is assumed by startup code to be the LMA of a section in DTCM
219 * which must be 4byte aligned
220 */
221 __etext = ALIGN (4);
222
223 .bram.at_ddr : AT (__etext)
224 {
225 __data_start__ = .;
226 *(vtable)
227 *(.data)
228 *(.data.*)
229 . = ALIGN(4);
230 PROVIDE_HIDDEN (__preinit_array_start = .);
231 KEEP(*(.preinit_array))
232 PROVIDE_HIDDEN (__preinit_array_end = .);
233 . = ALIGN(4);
234 PROVIDE_HIDDEN (__init_array_start = .);
235 KEEP(*(SORT(.init_array.*)))
236 KEEP(*(.init_array))
237 PROVIDE_HIDDEN (__init_array_end = .);
238 . = ALIGN(4);
239 PROVIDE_HIDDEN (__fini_array_start = .);
240 KEEP(*(SORT(.fini_array.*)))
241 KEEP(*(.fini_array))
242 PROVIDE_HIDDEN (__fini_array_end = .);
243 KEEP(*(.jcr*))
244 . = ALIGN(4);
245
246 *(.ARM.extab* .gnu.linkonce.armextab.*)
247 . = ALIGN(4);
248
249 /**
250 * Place the all ops resolver code data here. This accounts
Richard Burton4865c4f2023-11-13 15:21:11 +0000251 * for ~9k worth of saving on the ITCM load region. It is
Kshitij Sisodia26bc9232023-03-10 16:33:23 +0000252 * only designed to be included (by default) for the inference
253 * runner use case.
254 **/
Richard Burton4865c4f2023-11-13 15:21:11 +0000255 *MicroMutableAllOpsResolver*.obj (*.text*)
Kshitij Sisodia26bc9232023-03-10 16:33:23 +0000256 . = ALIGN(4);
257 *hal.c.obj (*.text*)
258 . = ALIGN(4);
259 *_allocator.o (*.text*)
260 . = ALIGN(4);
261 *flatbuffer*.o (*.text*)
262 . = ALIGN(4);
263 *lcd*.obj (*.text*)
264 . = ALIGN(4);
265 *timing_adapter.* (*.text*)
266 . = ALIGN(4);
267
268 __data_end__ = .;
269 } > BRAM
270
271 __etext2 = __etext + (__data_end__ - __data_start__);
272
273 .data.at_ddr : AT (__etext2)
274 {
275 . = ALIGN(4);
276 __ro_data_start__ = .;
277
278 *(.rodata*)
279 . = ALIGN(4);
280 * (npu_driver_version)
281 . = ALIGN(4);
282 * (npu_driver_arch_version)
283 . = ALIGN(4);
284
285 __ro_data_end__ = .;
286 } > BRAM
287
288 .heap (COPY) :
289 {
290 . = ALIGN(8);
291 __end__ = .;
292 PROVIDE(end = .);
293 . = . + __HEAP_SIZE;
294 . = ALIGN(8);
295 __HeapLimit = .;
296 } > BRAM
297
298 ASSERT (
299 (__ro_data_end__ - __ro_data_start__)
300 + (__data_end__ - __data_start__)
301 + __HEAP_SIZE <= LENGTH(BRAM),
302 "BRAM overflow")
303}