blob: ec58acc22d0505362a89e9b6f48071d2380f0cd0 [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 |
51 * | FPGA Data SRAM; BRAM | 0x0100_0000 | 0x0040_0000 | NS | 0x0040_0000; 2 MiB |
52 * | FPGA data SRAM; BRAM | 0x1100_0000 | 0x0040_0000 | S | Secure alias for NS BRAM |
53 * | 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 |
57 * | DDR | 0x6000_0000 | 0x1000_0000 | NS | 0x0800_0000; 256 MiB bank |
58 * | DDR | 0x7000_0000 | 0x1000_0000 | S | 0x0C00_0000; 256 MiB bank |
59 * +-----------------------+-------------+-------------+----+--------------------------------------+
60 *
61 * Note: Ethos-U55 can access BRAM, internal SRAM and the DDR sections => activation buffers and
62 * the model should only be placed in those regions.
63 *
64 * Note: Alias regions means that secure and non-secure addresses are mapped to the same physical
65 * memory banks.
66 */
67
Nir Ekhauz3c505ca2021-06-06 14:57:50 +030068#ifndef ETHOSU_MODEL
69 /* default value - '1', for DRAM */
70 #define ETHOSU_MODEL 1
71#endif
72
73#ifndef ETHOSU_ARENA
74 /* default value - '1', for DRAM */
75 #define ETHOSU_ARENA 1
76#endif
77
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010078__STACK_SIZE = 0x00008000;
79__HEAP_SIZE = 0x00008000;
80
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010081MEMORY
82{
Per Åstrand0b7bbb42021-03-25 12:34:24 +010083 ITCM (rx) : ORIGIN = 0x10000000, LENGTH = 0x00080000
Nir Ekhauz3adfbc12021-05-24 13:16:52 +030084 BRAM (rw) : ORIGIN = 0x11000000, LENGTH = 0x00400000
Per Åstrand0b7bbb42021-03-25 12:34:24 +010085 DTCM (rw) : ORIGIN = 0x30000000, LENGTH = 0x00080000
Nir Ekhauz3adfbc12021-05-24 13:16:52 +030086 SRAM (rw) : ORIGIN = 0x31000000, LENGTH = 0x00200000
Per Åstrand0b7bbb42021-03-25 12:34:24 +010087 DDR (rwx) : ORIGIN = 0x70000000, LENGTH = 0x60000000
88}
89
90PHDRS
91{
92 rom_exec PT_LOAD;
93 rom_dram PT_LOAD;
94 null PT_NULL;
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010095}
96
97/* Linker script to place sections and symbol values. Should be used together
98 * with other linker script that defines memory regions ITCM and RAM.
99 * It references following symbols, which must be defined in code:
100 * Reset_Handler : Entry of reset handler
101 *
102 * It defines following symbols, which code can use without definition:
103 * __exidx_start
104 * __exidx_end
105 * __copy_table_start__
106 * __copy_table_end__
107 * __zero_table_start__
108 * __zero_table_end__
109 * __etext
110 * __data_start__
111 * __preinit_array_start
112 * __preinit_array_end
113 * __init_array_start
114 * __init_array_end
115 * __fini_array_start
116 * __fini_array_end
117 * __data_end__
118 * __bss_start__
119 * __bss_end__
120 * __end__
121 * end
122 * __HeapLimit
123 * __StackLimit
124 * __StackTop
125 * __stack
126 */
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100127
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100128ENTRY(Reset_Handler)
129
130SECTIONS
131{
132 .text :
133 {
134 KEEP(*(.vectors))
135 *(.text*)
136
137 KEEP(*(.init))
138 KEEP(*(.fini))
139
140 /* .ctors */
141 *crtbegin.o(.ctors)
142 *crtbegin?.o(.ctors)
143 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
144 *(SORT(.ctors.*))
145 *(.ctors)
146
147 /* .dtors */
148 *crtbegin.o(.dtors)
149 *crtbegin?.o(.dtors)
150 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
151 *(SORT(.dtors.*))
152 *(.dtors)
153
154 *(.rodata*)
155
156 KEEP(*(.eh_frame*))
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100157 } > ITCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100158
159 /*
160 * SG veneers:
161 * All SG veneers are placed in the special output section .gnu.sgstubs. Its start address
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100162 * must be set, either with the command line option '--section-start' or in a linker script,
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100163 * to indicate where to place these veneers in memory.
164 */
165/*
166 .gnu.sgstubs :
167 {
168 . = ALIGN(32);
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100169 } > ITCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100170*/
171 .ARM.extab :
172 {
173 *(.ARM.extab* .gnu.linkonce.armextab.*)
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100174 } > ITCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100175
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100176 .ARM.exidx :
177 {
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100178 __exidx_start = .;
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100179 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100180 __exidx_end = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100181 } > ITCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100182
183 .copy.table :
184 {
185 . = ALIGN(4);
186 __copy_table_start__ = .;
187 LONG (__etext)
188 LONG (__data_start__)
189 LONG (__data_end__ - __data_start__)
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100190
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100191 LONG (__eddr_data)
192 LONG (__sram_data_start__)
193 LONG (__sram_data_end__ - __sram_data_start__ )
194
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100195 __copy_table_end__ = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100196 } > ITCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100197
198 .zero.table :
199 {
200 . = ALIGN(4);
201 __zero_table_start__ = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100202 LONG (__bss_start__)
203 LONG (__bss_end__ - __bss_start__)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100204 __zero_table_end__ = .;
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100205
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
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100213 } > ITCM :rom_exec
214
215 .data : AT(__etext)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100216 {
217 __data_start__ = .;
218 *(vtable)
219 *(.data)
220 *(.data.*)
221
222 . = ALIGN(4);
223 /* preinit data */
224 PROVIDE_HIDDEN (__preinit_array_start = .);
225 KEEP(*(.preinit_array))
226 PROVIDE_HIDDEN (__preinit_array_end = .);
227
228 . = ALIGN(4);
229 /* init data */
230 PROVIDE_HIDDEN (__init_array_start = .);
231 KEEP(*(SORT(.init_array.*)))
232 KEEP(*(.init_array))
233 PROVIDE_HIDDEN (__init_array_end = .);
234
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100235 . = ALIGN(4);
236 /* finit data */
237 PROVIDE_HIDDEN (__fini_array_start = .);
238 KEEP(*(SORT(.fini_array.*)))
239 KEEP(*(.fini_array))
240 PROVIDE_HIDDEN (__fini_array_end = .);
241
242 KEEP(*(.jcr*))
243 . = ALIGN(4);
244 /* All data end */
245 __data_end__ = .;
246
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100247 } > DTCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100248
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100249 .sram.bss :
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100250 {
251 . = ALIGN(16);
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300252#if (ETHOSU_MODEL == 0)
253 * (network_model_sec)
254#endif
255
256#if (ETHOSU_ARENA == 0)
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100257 *(.bss.tensor_arena)
258#endif
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300259
260 *(.bss.ethosu_scratch);
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100261 *.(output_data_sec)
262 } > SRAM :null
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100263
264 .ddr :
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100265 {
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300266#if (ETHOSU_ARENA == 1)
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100267 . = ALIGN(16);
Jonny Svärdf521be92021-03-01 14:35:49 +0100268 *(.bss.tensor_arena)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100269#endif
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300270
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100271 . = ALIGN(4);
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100272 *(input_data_sec)
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100273 . = ALIGN(16);
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300274#if (ETHOSU_MODEL == 1)
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100275 *(network_model_sec)
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300276#endif
277 * (expected_output_data_sec)
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100278 } > DDR :rom_dram
279
280 __eddr_data = ALIGN (16) ;
281 .sram.data : {
282 __sram_data_start__ = .;
283 *(.sram.data)
284 __sram_data_end__ = .;
Nir Ekhauz3adfbc12021-05-24 13:16:52 +0300285 } > BRAM AT >DDR :rom_dram
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100286
287 .bss :
288 {
289 . = ALIGN(4);
290 __bss_start__ = .;
291 *(.bss)
292 *(.bss.*)
293 *(COMMON)
294 . = ALIGN(4);
295 __bss_end__ = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100296 } > DTCM :null
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100297
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100298 .heap (COPY) :
299 {
300 . = ALIGN(8);
301 __end__ = .;
302 PROVIDE(end = .);
303 . = . + __HEAP_SIZE;
304 . = ALIGN(8);
305 __HeapLimit = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100306 } > DTCM :null
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100307
308 .stack (ORIGIN(DTCM) + LENGTH(DTCM) - __STACK_SIZE) (COPY) :
309 {
310 . = ALIGN(8);
311 __StackLimit = .;
312 . = . + __STACK_SIZE;
313 . = ALIGN(8);
314 __StackTop = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100315 } > DTCM :null
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100316 PROVIDE(__stack = __StackTop);
317
318 /* Check if data + heap + stack exceeds DTCM limit */
319 ASSERT(__StackLimit >= __HeapLimit, "region DTCM overflowed with stack")
320}