blob: 06a749a67746417abcf44f7c2a234017527f8850 [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
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010068#ifndef STACK_SIZE
69#define STACK_SIZE 0x8000
70#endif
71
72#ifndef HEAP_SIZE
73#define HEAP_SIZE 0x8000
74#endif
75
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +010076#if defined(TRUSTZONE_BUILD) && !defined(ETHOSU_TEST)
77/*
78 * Include trustzone.h with common addresses and sizes.
79 * The build configuration sets whether TRUSTZONE_SECURE is set or
80 * TRUSTZONE_NONSECURE which sets the memory start addresses and sizes.
81 */
82
83#include "trustzone.h"
84#define USE_TRUSTZONE
85
86#else //TRUSTZONE_BUILD
87
88#define LR_START 0x10000000
Per Åstrand79929ff2021-01-26 14:42:43 +010089#define LR_SIZE 0x00080000
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +010090
91#define ITCM_START 0x10000000
92#define ITCM_SIZE 0x00080000
93
94#define BRAM_START 0x11000000
95#define BRAM_SIZE 0x00200000
96
97#define DTCM_START 0x30000000
98#define DTCM_SIZE 0x00080000
99
100#define SRAM_START 0x31000000
101#define SRAM_SIZE 0x00200000
102
103#define DDR_START 0x70000000
104#define DDR_SIZE 0x02000000
105
106#define STACK_HEAP 0x30080000
107
108#endif //TRUSTZONE_BUILD
109
110/* ----------------------------------------------------------------------------
111 Stack seal size definition
112 *----------------------------------------------------------------------------*/
113#if defined(USE_TRUSTZONE) && defined(TRUSTZONE_SECURE)
114#define __STACKSEAL_SIZE ( 8 )
115#else
116#define __STACKSEAL_SIZE ( 0 )
117#endif
118
119APP_IMAGE LR_START LR_SIZE
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100120{
121 ; ITCM 512kB
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100122 rom_exec ITCM_START ITCM_SIZE
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100123 {
124 *.o (RESET, +First)
125 *(InRoot$$Sections)
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100126 ; Make sure reset_handler ends up in root segment, when split across
127 ; ITCM and DTCM
128 startup_ARMCM55.o
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100129 .ANY (+RO)
130 }
131
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100132#if defined(USE_TRUSTZONE) && defined(TRUSTZONE_SECURE)
133 ; MPS3 BRAM
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100134 ; Shared between Cortex-M and the NPU
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100135 BRAM BRAM_START (BRAM_SIZE - TZ_NSC_SIZE)
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100136 {
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100137 * (.sram.data)
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100138 }
139
140 ROM_NSC TZ_NSC_START TZ_NSC_SIZE
141 {
142 *(Veneer$$CMSE)
143 }
144#else
145 ; MPS3 BRAM
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100146 BRAM BRAM_START BRAM_SIZE
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100147 {
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100148 * (.sram.data)
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100149 }
150#endif
151
152 ; DTCM 512kB
153 ; Only accessible from the Cortex-M
154 DTCM DTCM_START (DTCM_SIZE - STACK_SIZE - HEAP_SIZE - __STACKSEAL_SIZE)
155 {
156 .ANY1 (+RW +ZI)
157 }
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100158
Nir Ekhauz3adfbc12021-05-24 13:16:52 +0300159 ; 2MB SSE-300 SRAM (3 cycles read latency) from M55/U55
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100160 SRAM SRAM_START UNINIT SRAM_SIZE
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100161 {
162#ifndef ETHOSU_FAST_MEMORY_SIZE
163 ; Place tensor arena in SRAM if we do not have a fast memory area
Jonny Svärdf521be92021-03-01 14:35:49 +0100164 * (.bss.tensor_arena)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100165#else
166 * (.bss.ethosu_scratch)
167#endif
168 }
169
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100170 ARM_LIB_HEAP (STACK_HEAP - STACK_SIZE - __STACKSEAL_SIZE - HEAP_SIZE) EMPTY ALIGN 8 HEAP_SIZE {}
171 ARM_LIB_STACK (STACK_HEAP - STACK_SIZE - __STACKSEAL_SIZE) EMPTY ALIGN 8 STACK_SIZE {}
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100172
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100173#if defined(USE_TRUSTZONE) && defined(TRUSTZONE_SECURE)
174 STACKSEAL +0 EMPTY __STACKSEAL_SIZE {
175 ; Reserve empty region for stack seal immediately after stack
176 }
177#endif
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100178}
179
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100180LOAD_REGION_1 DDR_START DDR_SIZE
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100181{
182 ; 2GB DDR4 available
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100183 rom_dram DDR_START
184#if defined(USE_TRUSTZONE) && defined(TRUSTZONE_NONSECURE)
185 {
186 }
187#else //trustzone secure or non-trustzone
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100188 {
189 * (network_model_sec)
190 * (input_data_sec)
191 * (expected_output_data_sec)
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100192 * (output_data_sec)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100193 }
194
195#ifdef ETHOSU_FAST_MEMORY_SIZE
196 ; Place tensor arena in DRAM if we have a fast memory area
197 ARENA +0 UNINIT ALIGN 16
198 {
Jonny Svärdf521be92021-03-01 14:35:49 +0100199 * (.bss.tensor_arena)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100200 }
201#endif
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100202#endif
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100203}