blob: 43ea575c09f40f3ee23047176cd70c50232129c0 [file] [log] [blame]
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +01001/*
Kshitij Sisodia987efae2023-02-14 16:28:40 +00002 * SPDX-FileCopyrightText: Copyright 2021, 2023 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 /**
Kshitij Sisodia987efae2023-02-14 16:28:40 +000077 * 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(*hal.c.obj
Kshitij Sisodia987efae2023-02-14 16:28:40 +000082 *_allocator.o
83 *flatbuffer*.o
84 *lcd*.obj
Aron Virginas-Tar10b8f412023-12-01 15:29:44 +000085 *timing_adapter.c.obj
86 *s4*.o)
87
Kshitij Sisodia987efae2023-02-14 16:28:40 +000088 .text*)
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +010089
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
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +0100110 __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);
Isabella Gottardi118f73e2021-09-16 17:54:35 +0100153 /* 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)
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +0100158 . = 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);
Isabella Gottardi118f73e2021-09-16 17:54:35 +0100190 /* nn model's baked in input matrices */
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +0100191 *(ifm)
192 . = ALIGN(16);
Isabella Gottardi118f73e2021-09-16 17:54:35 +0100193 /* nn model's default space */
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +0100194 *(nn_model)
195 . = ALIGN (16);
Isabella Gottardi118f73e2021-09-16 17:54:35 +0100196 /* labels */
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +0100197 *(labels)
198 . = ALIGN (16);
Richard Burton973158f2023-11-06 14:40:28 +0000199 *Labels*.obj (*.rodata*)
200 . = ALIGN (16);
Isabella Gottardi118f73e2021-09-16 17:54:35 +0100201 /* activation buffers a.k.a tensor arena when memory mode dedicated sram */
202 *(activation_buf_dram)
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +0100203 . = ALIGN (16);
204 } > DDR AT > DDR
205
206 /**
207 * Location counter can end up 2byte aligned with narrow Thumb code but
208 * __etext is assumed by startup code to be the LMA of a section in DTCM
209 * which must be 4byte aligned
210 */
211 __etext = ALIGN (4);
212
213 .bram.at_ddr : AT (__etext)
214 {
215 __data_start__ = .;
216 *(vtable)
217 *(.data)
218 *(.data.*)
219 . = ALIGN(4);
220 PROVIDE_HIDDEN (__preinit_array_start = .);
221 KEEP(*(.preinit_array))
222 PROVIDE_HIDDEN (__preinit_array_end = .);
223 . = ALIGN(4);
224 PROVIDE_HIDDEN (__init_array_start = .);
225 KEEP(*(SORT(.init_array.*)))
226 KEEP(*(.init_array))
227 PROVIDE_HIDDEN (__init_array_end = .);
228 . = ALIGN(4);
229 PROVIDE_HIDDEN (__fini_array_start = .);
230 KEEP(*(SORT(.fini_array.*)))
231 KEEP(*(.fini_array))
232 PROVIDE_HIDDEN (__fini_array_end = .);
233 KEEP(*(.jcr*))
234 . = ALIGN(4);
235
Richard Burton0d110592021-08-12 17:26:30 +0100236 *(.ARM.extab* .gnu.linkonce.armextab.*)
237 . = ALIGN(4);
238
Éanna Ó Catháin8f958872021-09-15 09:32:30 +0100239 *hal.c.obj (*.text*)
240 . = ALIGN(4);
Kshitij Sisodia987efae2023-02-14 16:28:40 +0000241 *_allocator.o (*.text*)
242 . = ALIGN(4);
243 *flatbuffer*.o (*.text*)
244 . = ALIGN(4);
245 *lcd*.obj (*.text*)
246 . = ALIGN(4);
247 *timing_adapter.* (*.text*)
248 . = ALIGN(4);
Aron Virginas-Tar10b8f412023-12-01 15:29:44 +0000249 *s4*.o (*.text*) /* Temporary solution to move s4 operations to DDR. */
250 . = ALIGN(4);
Richard Burton0d110592021-08-12 17:26:30 +0100251
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +0100252 __data_end__ = .;
253 } > BRAM
254
255 __etext2 = __etext + (__data_end__ - __data_start__);
256
257 .data.at_ddr : AT (__etext2)
258 {
259 . = ALIGN(4);
260 __ro_data_start__ = .;
261
262 *(.rodata*)
263 . = ALIGN(4);
264 * (npu_driver_version)
265 . = ALIGN(4);
266 * (npu_driver_arch_version)
267 . = ALIGN(4);
268
269 __ro_data_end__ = .;
270 } > BRAM
271
272 .heap (COPY) :
273 {
274 . = ALIGN(8);
275 __end__ = .;
276 PROVIDE(end = .);
277 . = . + __HEAP_SIZE;
278 . = ALIGN(8);
279 __HeapLimit = .;
280 } > BRAM
281
282 ASSERT (
283 (__ro_data_end__ - __ro_data_start__)
284 + (__data_end__ - __data_start__)
285 + __HEAP_SIZE <= LENGTH(BRAM),
286 "BRAM overflow")
287}