blob: 6531403e104b266c65be296511f1e39fac9b11f9 [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
87 *timing_adapter.c.obj)
88 .text*)
89
90 KEEP(*(.init))
91 KEEP(*(.fini))
92
93 /* .ctors */
94 *crtbegin.o(.ctors)
95 *crtbegin?.o(.ctors)
96 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
97 *(SORT(.ctors.*))
98 *(.ctors)
99
100 /* .dtors */
101 *crtbegin.o(.dtors)
102 *crtbegin?.o(.dtors)
103 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
104 *(SORT(.dtors.*))
105 *(.dtors)
106
107 KEEP(*(.eh_frame*))
108 } > ITCM
109
110 __exidx_start = .;
111 .ARM.exidx.at_itcm :
112 {
113 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
114 } > ITCM
115 __exidx_end = .;
116
117 .zero.table.at_itcm :
118 {
119 . = ALIGN(4);
120 __zero_table_start__ = .;
121
122 LONG (__bss_start__)
123 LONG ((__bss_end__ - __bss_start__)/4) /* Size is in 32-bit words */
124
125 __zero_table_end__ = .;
126 } > ITCM
127
128 .copy.table.at_itcm :
129 {
130 . = ALIGN(4);
131 __copy_table_start__ = .;
132
133 /* Section to be copied - part 1: any data to be placed in BRAM */
134 LONG (__etext)
135 LONG (__data_start__)
136 LONG ((__data_end__ - __data_start__)/4) /* Size is in 32-bit words */
137
138 /* Section to be copied - part 2: RO data for for DTCM */
139 LONG (__etext2)
140 LONG (__ro_data_start__)
141 LONG ((__ro_data_end__ - __ro_data_start__)/4) /* Size is in 32-bit words */
142
143 __copy_table_end__ = .;
144 } > ITCM
145
146 __itcm_total = ALIGN(4);
147
148 ASSERT( __itcm_total < (ORIGIN(ITCM) + LENGTH(ITCM)), "ITCM overflow")
149
150 .sram :
151 {
152 . = ALIGN(16);
153 /* Cache area (if used) */
154 *(.bss.NoInit.ethos_u_cache)
155 . = ALIGN (16);
156 /* activation buffers a.k.a tensor arena when memory mode sram only or shared sram */
157 *(.bss.NoInit.activation_buf_sram)
158 . = ALIGN(16);
159 } > SRAM AT > SRAM
160
161 .bss :
162 {
163 . = ALIGN(4);
164 __bss_start__ = .;
165 *(.bss)
166 *(.bss.*)
167 *(COMMON)
168 . = ALIGN(4);
169 __bss_end__ = .;
170 } > DTCM AT > DTCM
171
172 .stack (ORIGIN(DTCM) + LENGTH(DTCM) - __STACK_SIZE) (COPY) :
173 {
174 . = ALIGN(8);
175 __StackLimit = .;
176 . = . + __STACK_SIZE;
177 . = ALIGN(8);
178 __StackTop = .;
179 } > DTCM
180 PROVIDE(__stack = __StackTop);
181 ASSERT(
182 (__STACK_SIZE + __bss_end__ - __bss_start__) <= LENGTH(DTCM),
183 "DTCM overflow")
184
185 .ddr.at_ddr :
186 {
187 /* __attribute__((aligned(16))) is not handled by the CMSIS startup code.
188 * Force the alignment here as a workaround */
189 . = ALIGN(16);
190 /* nn model's baked in input matrices */
191 *(ifm)
192 . = ALIGN(16);
193 /* nn model's default space */
194 *(nn_model)
195 . = ALIGN (16);
196 /* labels */
197 *(labels)
198 . = ALIGN (16);
Richard Burton973158f2023-11-06 14:40:28 +0000199 *Labels*.obj (*.rodata*)
200 . = ALIGN (16);
Kshitij Sisodia26bc9232023-03-10 16:33:23 +0000201 /* activation buffers a.k.a tensor arena when memory mode dedicated sram */
202 *(activation_buf_dram)
203 . = ALIGN (16);
204 } > DDR AT > DDR
205
206 .text.at_ddr :
207 {
208 . = ALIGN(4);
209 *Profiler*.obj (*.text*)
210 . = ALIGN(4);
211 } > DDR AT > DDR
212
213 /**
214 * Location counter can end up 2byte aligned with narrow Thumb code but
215 * __etext is assumed by startup code to be the LMA of a section in DTCM
216 * which must be 4byte aligned
217 */
218 __etext = ALIGN (4);
219
220 .bram.at_ddr : AT (__etext)
221 {
222 __data_start__ = .;
223 *(vtable)
224 *(.data)
225 *(.data.*)
226 . = ALIGN(4);
227 PROVIDE_HIDDEN (__preinit_array_start = .);
228 KEEP(*(.preinit_array))
229 PROVIDE_HIDDEN (__preinit_array_end = .);
230 . = ALIGN(4);
231 PROVIDE_HIDDEN (__init_array_start = .);
232 KEEP(*(SORT(.init_array.*)))
233 KEEP(*(.init_array))
234 PROVIDE_HIDDEN (__init_array_end = .);
235 . = ALIGN(4);
236 PROVIDE_HIDDEN (__fini_array_start = .);
237 KEEP(*(SORT(.fini_array.*)))
238 KEEP(*(.fini_array))
239 PROVIDE_HIDDEN (__fini_array_end = .);
240 KEEP(*(.jcr*))
241 . = ALIGN(4);
242
243 *(.ARM.extab* .gnu.linkonce.armextab.*)
244 . = ALIGN(4);
245
246 /**
247 * Place the all ops resolver code data here. This accounts
Richard Burton4865c4f2023-11-13 15:21:11 +0000248 * for ~9k worth of saving on the ITCM load region. It is
Kshitij Sisodia26bc9232023-03-10 16:33:23 +0000249 * only designed to be included (by default) for the inference
250 * runner use case.
251 **/
Richard Burton4865c4f2023-11-13 15:21:11 +0000252 *MicroMutableAllOpsResolver*.obj (*.text*)
Kshitij Sisodia26bc9232023-03-10 16:33:23 +0000253 . = ALIGN(4);
254 *hal.c.obj (*.text*)
255 . = ALIGN(4);
256 *_allocator.o (*.text*)
257 . = ALIGN(4);
258 *flatbuffer*.o (*.text*)
259 . = ALIGN(4);
260 *lcd*.obj (*.text*)
261 . = ALIGN(4);
262 *timing_adapter.* (*.text*)
263 . = ALIGN(4);
264
265 __data_end__ = .;
266 } > BRAM
267
268 __etext2 = __etext + (__data_end__ - __data_start__);
269
270 .data.at_ddr : AT (__etext2)
271 {
272 . = ALIGN(4);
273 __ro_data_start__ = .;
274
275 *(.rodata*)
276 . = ALIGN(4);
277 * (npu_driver_version)
278 . = ALIGN(4);
279 * (npu_driver_arch_version)
280 . = ALIGN(4);
281
282 __ro_data_end__ = .;
283 } > BRAM
284
285 .heap (COPY) :
286 {
287 . = ALIGN(8);
288 __end__ = .;
289 PROVIDE(end = .);
290 . = . + __HEAP_SIZE;
291 . = ALIGN(8);
292 __HeapLimit = .;
293 } > BRAM
294
295 ASSERT (
296 (__ro_data_end__ - __ro_data_start__)
297 + (__data_end__ - __data_start__)
298 + __HEAP_SIZE <= LENGTH(BRAM),
299 "BRAM overflow")
300}