blob: f5a4c1dc0713bbdf94d85ecae489b7ceb3118695 [file] [log] [blame]
Kristofer Jonsson43ce4912020-11-20 09:42:53 +01001/*
Mikael Olssonad5b6f22024-01-22 14:48:28 +01002 * SPDX-FileCopyrightText: Copyright 2009-2024 Arm Limited and/or its affiliates <open-source-office@arm.com>
Kristofer Jonsson43ce4912020-11-20 09:42:53 +01003 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Licensed under the Apache License, Version 2.0 (the License); you may
7 * not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * 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, WITHOUT
14 * 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
Nir Ekhauz3adfbc12021-05-24 13:16:52 +030019 /*
20 * This is a simplified picture of the Corstone-300 memory system.
21 * Please refer to the Corstone SSE-300 Technical Reference Manual for
22 * further information.
23 *
24 * https://developer.arm.com/ip-products/subsystem/corstone/corstone-300
25 *
26 * +---------------+ +---------------+ +------+
27 * | Ethos-U55 | | Cortex-M55 +--+ ITCM |
28 * | | | | +------+
29 * | | | |
30 * | | | | +------+
31 * | M1 M0 | | +--+ DTCM |
32 * +---+-------+---+ +-------+-------+ +------+
33 * | | |
34 * | +---+---------------+-----+
35 * | | AMBA AXI NIC-400-Lite |
36 * | +---+-----------------+---+
37 * | | |
38 * +---+-------+------------+ +--+-------+
39 * | AMBA AXI NIC-400 | | SSE-300 |
40 * +---+--------+--------+--+ | SRAM |
41 * | | | +----------+
42 * +---+---+ +--+---+ +--+--+
43 * | Flash | | BRAM | | DDR |
44 * +-------+ +------+ +-----+
45 *
46 * +-----------------------+-------------+-------------+----+--------------------------------------+
47 * | Memory region name | Base addr | Size |IDAU| MCC load address + remarks |
48 * +-----------------------+-------------+-------------+----+--------------------------------------+
49 * | ITCM | 0x0000_0000 | 0x0008_0000 | NS | 0x0000_0000; 512 kiB |
50 * | ITCM | 0x1000_0000 | 0x0008_0000 | S | Secure alias for NS ITCM |
Nir Ekhauz1a969392021-10-21 15:42:22 +030051 * | FPGA Data SRAM; BRAM | 0x0100_0000 | 0x0010_0000 | NS | 0x0100_0000; 1 MiB |
52 * | FPGA data SRAM; BRAM | 0x1100_0000 | 0x0010_0000 | S | Secure alias for NS BRAM |
Nir Ekhauz3adfbc12021-05-24 13:16:52 +030053 * | DTCM | 0x2000_0000 | 0x0008_0000 | NS | 512 kiB; 4 banks of 128k each |
54 * | DTCM | 0x3000_0000 | 0x0008_0000 | S | Secure alias for NS DTCM |
55 * | SSE-300 internal SRAM | 0x2100_0000 | 0x0020_0000 | NS | 1 bank of 2 MiB; 3cc latency) |
56 * | SSE-300 internal SRAM | 0x3100_0000 | 0x0020_0000 | S | Secure alias for NS internal SRAM |
Nir Ekhauz1a969392021-10-21 15:42:22 +030057 * | QSPI external flash | 0x2800_0000 | 0x0080_0000 | NS | 8MB |
58 * | QSPI external flash | 0x3800_0000 | 0x0080_0000 | S | 8MB |
Nir Ekhauz3adfbc12021-05-24 13:16:52 +030059 * | DDR | 0x6000_0000 | 0x1000_0000 | NS | 0x0800_0000; 256 MiB bank |
60 * | DDR | 0x7000_0000 | 0x1000_0000 | S | 0x0C00_0000; 256 MiB bank |
61 * +-----------------------+-------------+-------------+----+--------------------------------------+
62 *
63 * Note: Ethos-U55 can access BRAM, internal SRAM and the DDR sections => activation buffers and
64 * the model should only be placed in those regions.
65 *
66 * Note: Alias regions means that secure and non-secure addresses are mapped to the same physical
67 * memory banks.
68 */
69
Nir Ekhauz3c505ca2021-06-06 14:57:50 +030070#ifndef ETHOSU_MODEL
71 /* default value - '1', for DRAM */
72 #define ETHOSU_MODEL 1
73#endif
74
75#ifndef ETHOSU_ARENA
76 /* default value - '1', for DRAM */
77 #define ETHOSU_ARENA 1
78#endif
79
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010080__STACK_SIZE = 0x00008000;
81__HEAP_SIZE = 0x00008000;
82
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010083MEMORY
84{
Per Åstrand0b7bbb42021-03-25 12:34:24 +010085 ITCM (rx) : ORIGIN = 0x10000000, LENGTH = 0x00080000
Nir Ekhauz1a969392021-10-21 15:42:22 +030086 BRAM (rw) : ORIGIN = 0x11000000, LENGTH = 0x00100000
Per Åstrand0b7bbb42021-03-25 12:34:24 +010087 DTCM (rw) : ORIGIN = 0x30000000, LENGTH = 0x00080000
Nir Ekhauz3adfbc12021-05-24 13:16:52 +030088 SRAM (rw) : ORIGIN = 0x31000000, LENGTH = 0x00200000
Nir Ekhauz1a969392021-10-21 15:42:22 +030089 QSPI (rw) : ORIGIN = 0x38000000, LENGTH = 0x00800000
Per Åstrand0b7bbb42021-03-25 12:34:24 +010090 DDR (rwx) : ORIGIN = 0x70000000, LENGTH = 0x60000000
91}
92
93PHDRS
94{
95 rom_exec PT_LOAD;
96 rom_dram PT_LOAD;
97 null PT_NULL;
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010098}
99
100/* Linker script to place sections and symbol values. Should be used together
101 * with other linker script that defines memory regions ITCM and RAM.
102 * It references following symbols, which must be defined in code:
103 * Reset_Handler : Entry of reset handler
104 *
105 * It defines following symbols, which code can use without definition:
106 * __exidx_start
107 * __exidx_end
108 * __copy_table_start__
109 * __copy_table_end__
110 * __zero_table_start__
111 * __zero_table_end__
112 * __etext
113 * __data_start__
114 * __preinit_array_start
115 * __preinit_array_end
116 * __init_array_start
117 * __init_array_end
118 * __fini_array_start
119 * __fini_array_end
120 * __data_end__
121 * __bss_start__
122 * __bss_end__
123 * __end__
124 * end
125 * __HeapLimit
126 * __StackLimit
127 * __StackTop
128 * __stack
129 */
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100130
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100131ENTRY(Reset_Handler)
132
133SECTIONS
134{
135 .text :
136 {
Mikael Olssonad5b6f22024-01-22 14:48:28 +0100137 _vectors = .;
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100138 KEEP(*(.vectors))
Jonny Svärd91974432023-04-28 16:08:12 +0200139 *(.text*)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100140
141 KEEP(*(.init))
142 KEEP(*(.fini))
143
144 /* .ctors */
145 *crtbegin.o(.ctors)
146 *crtbegin?.o(.ctors)
147 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
148 *(SORT(.ctors.*))
149 *(.ctors)
150
151 /* .dtors */
152 *crtbegin.o(.dtors)
153 *crtbegin?.o(.dtors)
154 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
155 *(SORT(.dtors.*))
156 *(.dtors)
157
158 *(.rodata*)
159
160 KEEP(*(.eh_frame*))
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100161 } > ITCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100162
163 /*
164 * SG veneers:
165 * All SG veneers are placed in the special output section .gnu.sgstubs. Its start address
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100166 * must be set, either with the command line option '--section-start' or in a linker script,
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100167 * to indicate where to place these veneers in memory.
168 */
169/*
170 .gnu.sgstubs :
171 {
172 . = ALIGN(32);
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100173 } > ITCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100174*/
175 .ARM.extab :
176 {
177 *(.ARM.extab* .gnu.linkonce.armextab.*)
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100178 } > ITCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100179
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100180 .ARM.exidx :
181 {
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100182 __exidx_start = .;
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100183 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100184 __exidx_end = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100185 } > ITCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100186
187 .copy.table :
188 {
189 . = ALIGN(4);
190 __copy_table_start__ = .;
191 LONG (__etext)
192 LONG (__data_start__)
Davide Grohmann8b53aad2022-05-05 17:15:19 +0200193 LONG ((__data_end__ - __data_start__) / 4)
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100194
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100195 LONG (__eddr_data)
196 LONG (__sram_data_start__)
Davide Grohmann8b53aad2022-05-05 17:15:19 +0200197 LONG ((__sram_data_end__ - __sram_data_start__) / 4)
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100198
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100199 __copy_table_end__ = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100200 } > ITCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100201
202 .zero.table :
203 {
204 . = ALIGN(4);
205 __zero_table_start__ = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100206 LONG (__bss_start__)
Davide Grohmann8b53aad2022-05-05 17:15:19 +0200207 LONG ((__bss_end__ - __bss_start__) / 4)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100208 __zero_table_end__ = .;
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100209
210 /**
211 * Location counter can end up 2byte aligned with narrow Thumb code but
212 * __etext is assumed by startup code to be the LMA of a section in DTCM
213 * which must be 4byte aligned
214 */
215 __etext = ALIGN (4);
216
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100217 } > ITCM :rom_exec
218
219 .data : AT(__etext)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100220 {
221 __data_start__ = .;
222 *(vtable)
Jonny Svärd91974432023-04-28 16:08:12 +0200223 *(.data)
224 *(.data.*)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100225
226 . = ALIGN(4);
227 /* preinit data */
228 PROVIDE_HIDDEN (__preinit_array_start = .);
229 KEEP(*(.preinit_array))
230 PROVIDE_HIDDEN (__preinit_array_end = .);
231
232 . = ALIGN(4);
233 /* init data */
234 PROVIDE_HIDDEN (__init_array_start = .);
235 KEEP(*(SORT(.init_array.*)))
236 KEEP(*(.init_array))
237 PROVIDE_HIDDEN (__init_array_end = .);
238
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100239 . = ALIGN(4);
240 /* finit data */
241 PROVIDE_HIDDEN (__fini_array_start = .);
242 KEEP(*(SORT(.fini_array.*)))
243 KEEP(*(.fini_array))
244 PROVIDE_HIDDEN (__fini_array_end = .);
245
246 KEEP(*(.jcr*))
247 . = ALIGN(4);
248 /* All data end */
249 __data_end__ = .;
250
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100251 } > DTCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100252
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100253 .sram.bss :
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100254 {
255 . = ALIGN(16);
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300256#if (ETHOSU_MODEL == 0)
257 * (network_model_sec)
258#endif
259
260#if (ETHOSU_ARENA == 0)
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100261 *(.bss.tensor_arena)
262#endif
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300263
264 *(.bss.ethosu_scratch);
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100265 *.(output_data_sec)
266 } > SRAM :null
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100267
268 .ddr :
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100269 {
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300270#if (ETHOSU_ARENA == 1)
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100271 . = ALIGN(16);
Jonny Svärdf521be92021-03-01 14:35:49 +0100272 *(.bss.tensor_arena)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100273#endif
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300274
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100275 . = ALIGN(4);
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100276 *(input_data_sec)
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100277 . = ALIGN(16);
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300278#if (ETHOSU_MODEL == 1)
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100279 *(network_model_sec)
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300280#endif
281 * (expected_output_data_sec)
Davide Grohmannf4379e92022-06-15 11:20:41 +0200282 * (sec_command_stream, sec_weight_data, sec_input_data)
283
284 * (ethosu_core_in_queue)
285 * (ethosu_core_out_queue)
Johan Alfvénd188e902022-03-03 09:07:51 +0100286 . = ALIGN(4);
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100287 } > DDR :rom_dram
288
Johan Alfvénd188e902022-03-03 09:07:51 +0100289 __eddr_data = ALIGN (4) ;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100290 .sram.data : {
291 __sram_data_start__ = .;
292 *(.sram.data)
293 __sram_data_end__ = .;
Nir Ekhauz3adfbc12021-05-24 13:16:52 +0300294 } > BRAM AT >DDR :rom_dram
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100295
296 .bss :
297 {
298 . = ALIGN(4);
299 __bss_start__ = .;
300 *(.bss)
301 *(.bss.*)
302 *(COMMON)
303 . = ALIGN(4);
304 __bss_end__ = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100305 } > DTCM :null
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100306
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100307 .heap (COPY) :
308 {
309 . = ALIGN(8);
310 __end__ = .;
311 PROVIDE(end = .);
312 . = . + __HEAP_SIZE;
313 . = ALIGN(8);
314 __HeapLimit = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100315 } > DTCM :null
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100316
317 .stack (ORIGIN(DTCM) + LENGTH(DTCM) - __STACK_SIZE) (COPY) :
318 {
319 . = ALIGN(8);
320 __StackLimit = .;
321 . = . + __STACK_SIZE;
322 . = ALIGN(8);
323 __StackTop = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100324 } > DTCM :null
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100325 PROVIDE(__stack = __StackTop);
326
Mikael Olssonad5b6f22024-01-22 14:48:28 +0100327 __RAM_segment_used_end__ = .;
328
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100329 /* Check if data + heap + stack exceeds DTCM limit */
330 ASSERT(__StackLimit >= __HeapLimit, "region DTCM overflowed with stack")
331}