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