blob: d373970c7d05ea5865bca5110fa14ba389685d81 [file] [log] [blame]
Kristofer Jonsson43ce4912020-11-20 09:42:53 +01001/*
Per Åstrand81e01af2021-02-19 13:45:26 +01002 * Copyright (c) 2009-2021 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))
138 *(.text*)
139
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__)
192 LONG (__data_end__ - __data_start__)
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100193
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100194 LONG (__eddr_data)
195 LONG (__sram_data_start__)
196 LONG (__sram_data_end__ - __sram_data_start__ )
197
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__)
206 LONG (__bss_end__ - __bss_start__)
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)
222 *(.data)
223 *(.data.*)
224
225 . = ALIGN(4);
226 /* preinit data */
227 PROVIDE_HIDDEN (__preinit_array_start = .);
228 KEEP(*(.preinit_array))
229 PROVIDE_HIDDEN (__preinit_array_end = .);
230
231 . = ALIGN(4);
232 /* init data */
233 PROVIDE_HIDDEN (__init_array_start = .);
234 KEEP(*(SORT(.init_array.*)))
235 KEEP(*(.init_array))
236 PROVIDE_HIDDEN (__init_array_end = .);
237
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100238 . = ALIGN(4);
239 /* finit data */
240 PROVIDE_HIDDEN (__fini_array_start = .);
241 KEEP(*(SORT(.fini_array.*)))
242 KEEP(*(.fini_array))
243 PROVIDE_HIDDEN (__fini_array_end = .);
244
245 KEEP(*(.jcr*))
246 . = ALIGN(4);
247 /* All data end */
248 __data_end__ = .;
249
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100250 } > DTCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100251
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100252 .sram.bss :
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100253 {
254 . = ALIGN(16);
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300255#if (ETHOSU_MODEL == 0)
256 * (network_model_sec)
257#endif
258
259#if (ETHOSU_ARENA == 0)
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100260 *(.bss.tensor_arena)
261#endif
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300262
263 *(.bss.ethosu_scratch);
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100264 *.(output_data_sec)
265 } > SRAM :null
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100266
267 .ddr :
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100268 {
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300269#if (ETHOSU_ARENA == 1)
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100270 . = ALIGN(16);
Jonny Svärdf521be92021-03-01 14:35:49 +0100271 *(.bss.tensor_arena)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100272#endif
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300273
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100274 . = ALIGN(4);
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100275 *(input_data_sec)
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100276 . = ALIGN(16);
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300277#if (ETHOSU_MODEL == 1)
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100278 *(network_model_sec)
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300279#endif
280 * (expected_output_data_sec)
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100281 } > DDR :rom_dram
282
283 __eddr_data = ALIGN (16) ;
284 .sram.data : {
285 __sram_data_start__ = .;
286 *(.sram.data)
287 __sram_data_end__ = .;
Nir Ekhauz3adfbc12021-05-24 13:16:52 +0300288 } > BRAM AT >DDR :rom_dram
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100289
290 .bss :
291 {
292 . = ALIGN(4);
293 __bss_start__ = .;
294 *(.bss)
295 *(.bss.*)
296 *(COMMON)
297 . = ALIGN(4);
298 __bss_end__ = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100299 } > DTCM :null
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100300
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100301 .heap (COPY) :
302 {
303 . = ALIGN(8);
304 __end__ = .;
305 PROVIDE(end = .);
306 . = . + __HEAP_SIZE;
307 . = ALIGN(8);
308 __HeapLimit = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100309 } > DTCM :null
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100310
311 .stack (ORIGIN(DTCM) + LENGTH(DTCM) - __STACK_SIZE) (COPY) :
312 {
313 . = ALIGN(8);
314 __StackLimit = .;
315 . = . + __STACK_SIZE;
316 . = ALIGN(8);
317 __StackTop = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100318 } > DTCM :null
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100319 PROVIDE(__stack = __StackTop);
320
321 /* Check if data + heap + stack exceeds DTCM limit */
322 ASSERT(__StackLimit >= __HeapLimit, "region DTCM overflowed with stack")
323}