blob: 880a23303628ab621106c788c2c6787635ea4d1b [file] [log] [blame]
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +01001/*
Richard Burtonf32a86a2022-11-15 11:46:11 +00002 * SPDX-FileCopyrightText: Copyright 2021 Arm Limited and/or its affiliates <open-source-office@arm.com>
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +01003 * 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
Kshitij Sisodia7e56d8f2022-04-11 10:34:29 +010018__STACK_SIZE = 0x00008000;
Kshitij Sisodia661959c2021-11-24 10:39:52 +000019__HEAP_SIZE = 0x000C0000;
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +010020
21/* System memory brief */
22MEMORY
23{
24 ITCM (rx) : ORIGIN = 0x00000000, LENGTH = 0x00080000
25 DTCM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00080000
Kshitij Sisodia661959c2021-11-24 10:39:52 +000026 BRAM (rwx) : ORIGIN = 0x11000000, LENGTH = 0x00100000
27 SRAM (rwx) : ORIGIN = 0x31000000, LENGTH = 0x00200000
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +010028 DDR (rwx) : ORIGIN = 0x70000000, LENGTH = 0x02000000
Kshitij Sisodiaaa5e1f62021-09-24 14:42:08 +010029
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
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +010036}
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))
Richard Burton0d110592021-08-12 17:26:30 +010075
76 /**
77 * All code goes here, with one exception of
78 * all_ops_resolver object file. This code
79 * instead placed on BRAM. See comment in the
80 * BRAM section for details.
81 **/
Éanna Ó Catháin8f958872021-09-15 09:32:30 +010082 *(EXCLUDE_FILE(*all_ops_resolver.o *hal.c.obj) .text*)
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +010083
84 KEEP(*(.init))
85 KEEP(*(.fini))
86
87 /* .ctors */
88 *crtbegin.o(.ctors)
89 *crtbegin?.o(.ctors)
90 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
91 *(SORT(.ctors.*))
92 *(.ctors)
93
94 /* .dtors */
95 *crtbegin.o(.dtors)
96 *crtbegin?.o(.dtors)
97 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
98 *(SORT(.dtors.*))
99 *(.dtors)
100
101 KEEP(*(.eh_frame*))
102 } > ITCM
103
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +0100104 __exidx_start = .;
105 .ARM.exidx.at_itcm :
106 {
107 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
108 } > ITCM
109 __exidx_end = .;
110
111 .zero.table.at_itcm :
112 {
113 . = ALIGN(4);
114 __zero_table_start__ = .;
115
116 LONG (__bss_start__)
117 LONG ((__bss_end__ - __bss_start__)/4) /* Size is in 32-bit words */
118
119 __zero_table_end__ = .;
120 } > ITCM
121
122 .copy.table.at_itcm :
123 {
124 . = ALIGN(4);
125 __copy_table_start__ = .;
126
127 /* Section to be copied - part 1: any data to be placed in BRAM */
128 LONG (__etext)
129 LONG (__data_start__)
130 LONG ((__data_end__ - __data_start__)/4) /* Size is in 32-bit words */
131
132 /* Section to be copied - part 2: RO data for for DTCM */
133 LONG (__etext2)
134 LONG (__ro_data_start__)
135 LONG ((__ro_data_end__ - __ro_data_start__)/4) /* Size is in 32-bit words */
136
137 __copy_table_end__ = .;
138 } > ITCM
139
140 __itcm_total = ALIGN(4);
141
142 ASSERT( __itcm_total < (ORIGIN(ITCM) + LENGTH(ITCM)), "ITCM overflow")
143
144 .sram :
145 {
146 . = ALIGN(16);
Isabella Gottardi118f73e2021-09-16 17:54:35 +0100147 /* Cache area (if used) */
148 *(.bss.NoInit.ethos_u_cache)
149 . = ALIGN (16);
150 /* activation buffers a.k.a tensor arena when memory mode sram only or shared sram */
151 *(.bss.NoInit.activation_buf_sram)
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +0100152 . = ALIGN(16);
153 } > SRAM AT > SRAM
154
155 .bss :
156 {
157 . = ALIGN(4);
158 __bss_start__ = .;
159 *(.bss)
160 *(.bss.*)
161 *(COMMON)
162 . = ALIGN(4);
163 __bss_end__ = .;
164 } > DTCM AT > DTCM
165
166 .stack (ORIGIN(DTCM) + LENGTH(DTCM) - __STACK_SIZE) (COPY) :
167 {
168 . = ALIGN(8);
169 __StackLimit = .;
170 . = . + __STACK_SIZE;
171 . = ALIGN(8);
172 __StackTop = .;
173 } > DTCM
174 PROVIDE(__stack = __StackTop);
175 ASSERT(
176 (__STACK_SIZE + __bss_end__ - __bss_start__) <= LENGTH(DTCM),
177 "DTCM overflow")
178
179 .ddr.at_ddr :
180 {
181 /* __attribute__((aligned(16))) is not handled by the CMSIS startup code.
182 * Force the alignment here as a workaround */
183 . = ALIGN(16);
Isabella Gottardi118f73e2021-09-16 17:54:35 +0100184 /* nn model's baked in input matrices */
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +0100185 *(ifm)
186 . = ALIGN(16);
Isabella Gottardi118f73e2021-09-16 17:54:35 +0100187 /* nn model's default space */
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +0100188 *(nn_model)
189 . = ALIGN (16);
Isabella Gottardi118f73e2021-09-16 17:54:35 +0100190 /* labels */
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +0100191 *(labels)
192 . = ALIGN (16);
Isabella Gottardi118f73e2021-09-16 17:54:35 +0100193 /* activation buffers a.k.a tensor arena when memory mode dedicated sram */
194 *(activation_buf_dram)
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +0100195 . = ALIGN (16);
196 } > DDR AT > DDR
197
198 /**
199 * Location counter can end up 2byte aligned with narrow Thumb code but
200 * __etext is assumed by startup code to be the LMA of a section in DTCM
201 * which must be 4byte aligned
202 */
203 __etext = ALIGN (4);
204
205 .bram.at_ddr : AT (__etext)
206 {
207 __data_start__ = .;
208 *(vtable)
209 *(.data)
210 *(.data.*)
211 . = ALIGN(4);
212 PROVIDE_HIDDEN (__preinit_array_start = .);
213 KEEP(*(.preinit_array))
214 PROVIDE_HIDDEN (__preinit_array_end = .);
215 . = ALIGN(4);
216 PROVIDE_HIDDEN (__init_array_start = .);
217 KEEP(*(SORT(.init_array.*)))
218 KEEP(*(.init_array))
219 PROVIDE_HIDDEN (__init_array_end = .);
220 . = ALIGN(4);
221 PROVIDE_HIDDEN (__fini_array_start = .);
222 KEEP(*(SORT(.fini_array.*)))
223 KEEP(*(.fini_array))
224 PROVIDE_HIDDEN (__fini_array_end = .);
225 KEEP(*(.jcr*))
226 . = ALIGN(4);
227
Richard Burton0d110592021-08-12 17:26:30 +0100228 *(.ARM.extab* .gnu.linkonce.armextab.*)
229 . = ALIGN(4);
230
231 /**
232 * Place the all ops resolver code data here. This accounts
233 * for ~4k worth of saving on the ITCM load region. It is
234 * only designed to be included (by default) for the inference
235 * runner use case.
236 **/
237 *all_ops_resolver.o (*.text*)
238 . = ALIGN(4);
Éanna Ó Catháin8f958872021-09-15 09:32:30 +0100239 *hal.c.obj (*.text*)
240 . = ALIGN(4);
Richard Burton0d110592021-08-12 17:26:30 +0100241
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +0100242 __data_end__ = .;
243 } > BRAM
244
245 __etext2 = __etext + (__data_end__ - __data_start__);
246
247 .data.at_ddr : AT (__etext2)
248 {
249 . = ALIGN(4);
250 __ro_data_start__ = .;
251
252 *(.rodata*)
253 . = ALIGN(4);
254 * (npu_driver_version)
255 . = ALIGN(4);
256 * (npu_driver_arch_version)
257 . = ALIGN(4);
258
259 __ro_data_end__ = .;
260 } > BRAM
261
262 .heap (COPY) :
263 {
264 . = ALIGN(8);
265 __end__ = .;
266 PROVIDE(end = .);
267 . = . + __HEAP_SIZE;
268 . = ALIGN(8);
269 __HeapLimit = .;
270 } > BRAM
271
272 ASSERT (
273 (__ro_data_end__ - __ro_data_start__)
274 + (__data_end__ - __data_start__)
275 + __HEAP_SIZE <= LENGTH(BRAM),
276 "BRAM overflow")
277}