blob: e115c0fede164de8384c4d631c4f1ece1373aadc [file] [log] [blame]
Kristofer Jonsson43ce4912020-11-20 09:42:53 +01001/*
Jonny Svärdf521be92021-03-01 14:35:49 +01002 * Copyright (c) 2019-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
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +010019/*
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 |
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +010053 * | 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 |
Nir Ekhauz3adfbc12021-05-24 13:16:52 +030055 * | 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 |
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +010059 * | 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#ifndef STACK_SIZE
81#define STACK_SIZE 0x8000
82#endif
83
84#ifndef HEAP_SIZE
Kristofer Jonsson99f19422021-07-01 22:15:02 +020085#define HEAP_SIZE 0x10000
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010086#endif
87
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +010088#if defined(TRUSTZONE_BUILD) && !defined(ETHOSU_TEST)
89/*
90 * Include trustzone.h with common addresses and sizes.
91 * The build configuration sets whether TRUSTZONE_SECURE is set or
92 * TRUSTZONE_NONSECURE which sets the memory start addresses and sizes.
93 */
94
95#include "trustzone.h"
96#define USE_TRUSTZONE
97
98#else //TRUSTZONE_BUILD
99
100#define LR_START 0x10000000
Per Åstrand79929ff2021-01-26 14:42:43 +0100101#define LR_SIZE 0x00080000
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100102
103#define ITCM_START 0x10000000
104#define ITCM_SIZE 0x00080000
105
106#define BRAM_START 0x11000000
Nir Ekhauz1a969392021-10-21 15:42:22 +0300107#define BRAM_SIZE 0x00100000
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100108
109#define DTCM_START 0x30000000
110#define DTCM_SIZE 0x00080000
111
112#define SRAM_START 0x31000000
113#define SRAM_SIZE 0x00200000
114
Nir Ekhauz1a969392021-10-21 15:42:22 +0300115#define QSPI_START 0x38000000
116#define QSPI_SIZE 0x00800000
117
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100118#define DDR_START 0x70000000
119#define DDR_SIZE 0x02000000
120
121#define STACK_HEAP 0x30080000
122
123#endif //TRUSTZONE_BUILD
124
125/* ----------------------------------------------------------------------------
126 Stack seal size definition
127 *----------------------------------------------------------------------------*/
128#if defined(USE_TRUSTZONE) && defined(TRUSTZONE_SECURE)
129#define __STACKSEAL_SIZE ( 8 )
130#else
131#define __STACKSEAL_SIZE ( 0 )
132#endif
133
134APP_IMAGE LR_START LR_SIZE
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100135{
136 ; ITCM 512kB
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100137 rom_exec ITCM_START ITCM_SIZE
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100138 {
139 *.o (RESET, +First)
140 *(InRoot$$Sections)
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100141 ; Make sure reset_handler ends up in root segment, when split across
142 ; ITCM and DTCM
143 startup_ARMCM55.o
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100144 .ANY (+RO)
145 }
146
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100147#if defined(USE_TRUSTZONE) && defined(TRUSTZONE_SECURE)
148 ; MPS3 BRAM
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100149 ; Shared between Cortex-M and the NPU
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100150 BRAM BRAM_START (BRAM_SIZE - TZ_NSC_SIZE)
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100151 {
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100152 * (.sram.data)
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100153 }
154
155 ROM_NSC TZ_NSC_START TZ_NSC_SIZE
156 {
157 *(Veneer$$CMSE)
158 }
159#else
160 ; MPS3 BRAM
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100161 BRAM BRAM_START BRAM_SIZE
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100162 {
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100163 * (.sram.data)
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100164 }
165#endif
166
167 ; DTCM 512kB
168 ; Only accessible from the Cortex-M
169 DTCM DTCM_START (DTCM_SIZE - STACK_SIZE - HEAP_SIZE - __STACKSEAL_SIZE)
170 {
171 .ANY1 (+RW +ZI)
172 }
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100173
Nir Ekhauz3adfbc12021-05-24 13:16:52 +0300174 ; 2MB SSE-300 SRAM (3 cycles read latency) from M55/U55
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300175 SRAM SRAM_START SRAM_SIZE
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100176 {
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300177 #if (ETHOSU_MODEL == 0)
178 ; Place network model in SRAM
179 * (network_model_sec)
180 #endif
181
182 #if (ETHOSU_ARENA == 0)
183 ; Place tensor arena in SRAM
Jonny Svärdf521be92021-03-01 14:35:49 +0100184 * (.bss.tensor_arena)
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300185 #endif
186
187 ; Place scratch buffer in SRAM
188 * (.bss.ethosu_scratch)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100189 }
190
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100191 ARM_LIB_HEAP (STACK_HEAP - STACK_SIZE - __STACKSEAL_SIZE - HEAP_SIZE) EMPTY ALIGN 8 HEAP_SIZE {}
192 ARM_LIB_STACK (STACK_HEAP - STACK_SIZE - __STACKSEAL_SIZE) EMPTY ALIGN 8 STACK_SIZE {}
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100193
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100194#if defined(USE_TRUSTZONE) && defined(TRUSTZONE_SECURE)
195 STACKSEAL +0 EMPTY __STACKSEAL_SIZE {
196 ; Reserve empty region for stack seal immediately after stack
197 }
198#endif
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100199}
200
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100201LOAD_REGION_1 DDR_START DDR_SIZE
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100202{
203 ; 2GB DDR4 available
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100204 rom_dram DDR_START
205#if defined(USE_TRUSTZONE) && defined(TRUSTZONE_NONSECURE)
206 {
207 }
208#else //trustzone secure or non-trustzone
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300209 ; Place model and its affiliates in DRAM
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100210 {
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300211 #if (ETHOSU_MODEL == 1)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100212 * (network_model_sec)
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300213 #endif
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100214 * (input_data_sec)
215 * (expected_output_data_sec)
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100216 * (output_data_sec)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100217 }
218
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300219 #if (ETHOSU_ARENA == 1)
220 ; Place tensor arena in DRAM if we have a fast memory area
221 ARENA +0 UNINIT ALIGN 16
222 {
223 * (.bss.tensor_arena)
224 }
225 #endif
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100226#endif
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100227}