blob: ebf7021ec23e8703d3560489ad087fa4a356e28b [file] [log] [blame]
Kristofer Jonsson43ce4912020-11-20 09:42:53 +01001/*
Johan Alfvénd188e902022-03-03 09:07:51 +01002 * Copyright (c) 2009-2022 Arm Limited. All rights reserved.
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 {
137 KEEP(*(.vectors))
Kristofer Jonsson34b1bd22022-09-19 14:14:39 +0200138 *(EXCLUDE_FILE(lstm_eval.*) .text*)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100139
140 KEEP(*(.init))
141 KEEP(*(.fini))
142
143 /* .ctors */
144 *crtbegin.o(.ctors)
145 *crtbegin?.o(.ctors)
146 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
147 *(SORT(.ctors.*))
148 *(.ctors)
149
150 /* .dtors */
151 *crtbegin.o(.dtors)
152 *crtbegin?.o(.dtors)
153 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
154 *(SORT(.dtors.*))
155 *(.dtors)
156
157 *(.rodata*)
158
159 KEEP(*(.eh_frame*))
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100160 } > ITCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100161
162 /*
163 * SG veneers:
164 * All SG veneers are placed in the special output section .gnu.sgstubs. Its start address
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100165 * must be set, either with the command line option '--section-start' or in a linker script,
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100166 * to indicate where to place these veneers in memory.
167 */
168/*
169 .gnu.sgstubs :
170 {
171 . = ALIGN(32);
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100172 } > ITCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100173*/
174 .ARM.extab :
175 {
176 *(.ARM.extab* .gnu.linkonce.armextab.*)
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100177 } > ITCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100178
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100179 .ARM.exidx :
180 {
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100181 __exidx_start = .;
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100182 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100183 __exidx_end = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100184 } > ITCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100185
186 .copy.table :
187 {
188 . = ALIGN(4);
189 __copy_table_start__ = .;
190 LONG (__etext)
191 LONG (__data_start__)
Davide Grohmann8b53aad2022-05-05 17:15:19 +0200192 LONG ((__data_end__ - __data_start__) / 4)
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100193
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100194 LONG (__eddr_data)
195 LONG (__sram_data_start__)
Davide Grohmann8b53aad2022-05-05 17:15:19 +0200196 LONG ((__sram_data_end__ - __sram_data_start__) / 4)
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100197
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100198 __copy_table_end__ = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100199 } > ITCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100200
201 .zero.table :
202 {
203 . = ALIGN(4);
204 __zero_table_start__ = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100205 LONG (__bss_start__)
Davide Grohmann8b53aad2022-05-05 17:15:19 +0200206 LONG ((__bss_end__ - __bss_start__) / 4)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100207 __zero_table_end__ = .;
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100208
209 /**
210 * Location counter can end up 2byte aligned with narrow Thumb code but
211 * __etext is assumed by startup code to be the LMA of a section in DTCM
212 * which must be 4byte aligned
213 */
214 __etext = ALIGN (4);
215
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100216 } > ITCM :rom_exec
217
218 .data : AT(__etext)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100219 {
220 __data_start__ = .;
221 *(vtable)
Kristofer Jonsson34b1bd22022-09-19 14:14:39 +0200222 *(EXCLUDE_FILE(lstm_eval.*) .data .data.*)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100223
224 . = ALIGN(4);
225 /* preinit data */
226 PROVIDE_HIDDEN (__preinit_array_start = .);
227 KEEP(*(.preinit_array))
228 PROVIDE_HIDDEN (__preinit_array_end = .);
229
230 . = ALIGN(4);
231 /* init data */
232 PROVIDE_HIDDEN (__init_array_start = .);
233 KEEP(*(SORT(.init_array.*)))
234 KEEP(*(.init_array))
235 PROVIDE_HIDDEN (__init_array_end = .);
236
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100237 . = ALIGN(4);
238 /* finit data */
239 PROVIDE_HIDDEN (__fini_array_start = .);
240 KEEP(*(SORT(.fini_array.*)))
241 KEEP(*(.fini_array))
242 PROVIDE_HIDDEN (__fini_array_end = .);
243
244 KEEP(*(.jcr*))
245 . = ALIGN(4);
246 /* All data end */
247 __data_end__ = .;
248
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100249 } > DTCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100250
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100251 .sram.bss :
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100252 {
253 . = ALIGN(16);
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300254#if (ETHOSU_MODEL == 0)
255 * (network_model_sec)
256#endif
257
258#if (ETHOSU_ARENA == 0)
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100259 *(.bss.tensor_arena)
260#endif
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300261
262 *(.bss.ethosu_scratch);
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100263 *.(output_data_sec)
264 } > SRAM :null
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100265
266 .ddr :
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100267 {
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300268#if (ETHOSU_ARENA == 1)
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100269 . = ALIGN(16);
Jonny Svärdf521be92021-03-01 14:35:49 +0100270 *(.bss.tensor_arena)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100271#endif
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300272
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100273 . = ALIGN(4);
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100274 *(input_data_sec)
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100275 . = ALIGN(16);
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300276#if (ETHOSU_MODEL == 1)
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100277 *(network_model_sec)
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300278#endif
279 * (expected_output_data_sec)
Davide Grohmannf4379e92022-06-15 11:20:41 +0200280 * (sec_command_stream, sec_weight_data, sec_input_data)
281
282 * (ethosu_core_in_queue)
283 * (ethosu_core_out_queue)
Johan Alfvénd188e902022-03-03 09:07:51 +0100284 . = ALIGN(4);
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100285 } > DDR :rom_dram
286
Johan Alfvénd188e902022-03-03 09:07:51 +0100287 __eddr_data = ALIGN (4) ;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100288 .sram.data : {
289 __sram_data_start__ = .;
290 *(.sram.data)
Kristofer Jonsson34b1bd22022-09-19 14:14:39 +0200291 lstm_eval.*(.text* .data .data.*)
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100292 __sram_data_end__ = .;
Nir Ekhauz3adfbc12021-05-24 13:16:52 +0300293 } > BRAM AT >DDR :rom_dram
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100294
295 .bss :
296 {
297 . = ALIGN(4);
298 __bss_start__ = .;
299 *(.bss)
300 *(.bss.*)
301 *(COMMON)
302 . = ALIGN(4);
303 __bss_end__ = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100304 } > DTCM :null
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100305
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100306 .heap (COPY) :
307 {
308 . = ALIGN(8);
309 __end__ = .;
310 PROVIDE(end = .);
311 . = . + __HEAP_SIZE;
312 . = ALIGN(8);
313 __HeapLimit = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100314 } > DTCM :null
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100315
316 .stack (ORIGIN(DTCM) + LENGTH(DTCM) - __STACK_SIZE) (COPY) :
317 {
318 . = ALIGN(8);
319 __StackLimit = .;
320 . = . + __STACK_SIZE;
321 . = ALIGN(8);
322 __StackTop = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100323 } > DTCM :null
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100324 PROVIDE(__stack = __StackTop);
325
326 /* Check if data + heap + stack exceeds DTCM limit */
327 ASSERT(__StackLimit >= __HeapLimit, "region DTCM overflowed with stack")
328}