blob: fab12d103eaf63bea9ae2530efb06fbb695dcb86 [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 |
51 * | FPGA Data SRAM; BRAM | 0x0100_0000 | 0x0020_0000 | NS | 0x0100_0000; 2 MiB |
52 * | FPGA data SRAM; BRAM | 0x1100_0000 | 0x0020_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 |
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 |
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +010057 * | 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#ifndef STACK_SIZE
79#define STACK_SIZE 0x8000
80#endif
81
82#ifndef HEAP_SIZE
Kristofer Jonsson99f19422021-07-01 22:15:02 +020083#define HEAP_SIZE 0x10000
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010084#endif
85
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +010086#if defined(TRUSTZONE_BUILD) && !defined(ETHOSU_TEST)
87/*
88 * Include trustzone.h with common addresses and sizes.
89 * The build configuration sets whether TRUSTZONE_SECURE is set or
90 * TRUSTZONE_NONSECURE which sets the memory start addresses and sizes.
91 */
92
93#include "trustzone.h"
94#define USE_TRUSTZONE
95
96#else //TRUSTZONE_BUILD
97
98#define LR_START 0x10000000
Per Åstrand79929ff2021-01-26 14:42:43 +010099#define LR_SIZE 0x00080000
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100100
101#define ITCM_START 0x10000000
102#define ITCM_SIZE 0x00080000
103
104#define BRAM_START 0x11000000
105#define BRAM_SIZE 0x00200000
106
107#define DTCM_START 0x30000000
108#define DTCM_SIZE 0x00080000
109
110#define SRAM_START 0x31000000
111#define SRAM_SIZE 0x00200000
112
113#define DDR_START 0x70000000
114#define DDR_SIZE 0x02000000
115
116#define STACK_HEAP 0x30080000
117
118#endif //TRUSTZONE_BUILD
119
120/* ----------------------------------------------------------------------------
121 Stack seal size definition
122 *----------------------------------------------------------------------------*/
123#if defined(USE_TRUSTZONE) && defined(TRUSTZONE_SECURE)
124#define __STACKSEAL_SIZE ( 8 )
125#else
126#define __STACKSEAL_SIZE ( 0 )
127#endif
128
129APP_IMAGE LR_START LR_SIZE
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100130{
131 ; ITCM 512kB
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100132 rom_exec ITCM_START ITCM_SIZE
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100133 {
134 *.o (RESET, +First)
135 *(InRoot$$Sections)
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100136 ; Make sure reset_handler ends up in root segment, when split across
137 ; ITCM and DTCM
138 startup_ARMCM55.o
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100139 .ANY (+RO)
140 }
141
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100142#if defined(USE_TRUSTZONE) && defined(TRUSTZONE_SECURE)
143 ; MPS3 BRAM
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100144 ; Shared between Cortex-M and the NPU
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100145 BRAM BRAM_START (BRAM_SIZE - TZ_NSC_SIZE)
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100146 {
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100147 * (.sram.data)
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100148 }
149
150 ROM_NSC TZ_NSC_START TZ_NSC_SIZE
151 {
152 *(Veneer$$CMSE)
153 }
154#else
155 ; MPS3 BRAM
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100156 BRAM BRAM_START BRAM_SIZE
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100157 {
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100158 * (.sram.data)
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100159 }
160#endif
161
162 ; DTCM 512kB
163 ; Only accessible from the Cortex-M
164 DTCM DTCM_START (DTCM_SIZE - STACK_SIZE - HEAP_SIZE - __STACKSEAL_SIZE)
165 {
166 .ANY1 (+RW +ZI)
167 }
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100168
Nir Ekhauz3adfbc12021-05-24 13:16:52 +0300169 ; 2MB SSE-300 SRAM (3 cycles read latency) from M55/U55
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300170 SRAM SRAM_START SRAM_SIZE
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100171 {
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300172 #if (ETHOSU_MODEL == 0)
173 ; Place network model in SRAM
174 * (network_model_sec)
175 #endif
176
177 #if (ETHOSU_ARENA == 0)
178 ; Place tensor arena in SRAM
Jonny Svärdf521be92021-03-01 14:35:49 +0100179 * (.bss.tensor_arena)
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300180 #endif
181
182 ; Place scratch buffer in SRAM
183 * (.bss.ethosu_scratch)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100184 }
185
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100186 ARM_LIB_HEAP (STACK_HEAP - STACK_SIZE - __STACKSEAL_SIZE - HEAP_SIZE) EMPTY ALIGN 8 HEAP_SIZE {}
187 ARM_LIB_STACK (STACK_HEAP - STACK_SIZE - __STACKSEAL_SIZE) EMPTY ALIGN 8 STACK_SIZE {}
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100188
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100189#if defined(USE_TRUSTZONE) && defined(TRUSTZONE_SECURE)
190 STACKSEAL +0 EMPTY __STACKSEAL_SIZE {
191 ; Reserve empty region for stack seal immediately after stack
192 }
193#endif
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100194}
195
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100196LOAD_REGION_1 DDR_START DDR_SIZE
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100197{
198 ; 2GB DDR4 available
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100199 rom_dram DDR_START
200#if defined(USE_TRUSTZONE) && defined(TRUSTZONE_NONSECURE)
201 {
202 }
203#else //trustzone secure or non-trustzone
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300204 ; Place model and its affiliates in DRAM
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100205 {
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300206 #if (ETHOSU_MODEL == 1)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100207 * (network_model_sec)
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300208 #endif
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100209 * (input_data_sec)
210 * (expected_output_data_sec)
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100211 * (output_data_sec)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100212 }
213
Nir Ekhauz3c505ca2021-06-06 14:57:50 +0300214 #if (ETHOSU_ARENA == 1)
215 ; Place tensor arena in DRAM if we have a fast memory area
216 ARENA +0 UNINIT ALIGN 16
217 {
218 * (.bss.tensor_arena)
219 }
220 #endif
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100221#endif
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100222}