blob: dc8f57ba938079cefca62e5144c5970d3531c4be [file] [log] [blame]
Kristofer Jonsson43ce4912020-11-20 09:42:53 +01001#! cpp
2
3/*
Jonny Svärdf521be92021-03-01 14:35:49 +01004 * Copyright (c) 2019-2021 Arm Limited. All rights reserved.
Kristofer Jonsson43ce4912020-11-20 09:42:53 +01005 *
6 * SPDX-License-Identifier: Apache-2.0
7 *
8 * Licensed under the Apache License, Version 2.0 (the License); you may
9 * not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20
21#ifndef STACK_SIZE
22#define STACK_SIZE 0x8000
23#endif
24
25#ifndef HEAP_SIZE
26#define HEAP_SIZE 0x8000
27#endif
28
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +010029#if defined(TRUSTZONE_BUILD) && !defined(ETHOSU_TEST)
30/*
31 * Include trustzone.h with common addresses and sizes.
32 * The build configuration sets whether TRUSTZONE_SECURE is set or
33 * TRUSTZONE_NONSECURE which sets the memory start addresses and sizes.
34 */
35
36#include "trustzone.h"
37#define USE_TRUSTZONE
38
39#else //TRUSTZONE_BUILD
40
41#define LR_START 0x10000000
Per Åstrand79929ff2021-01-26 14:42:43 +010042#define LR_SIZE 0x00080000
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +010043
44#define ITCM_START 0x10000000
45#define ITCM_SIZE 0x00080000
46
47#define BRAM_START 0x11000000
48#define BRAM_SIZE 0x00200000
49
50#define DTCM_START 0x30000000
51#define DTCM_SIZE 0x00080000
52
53#define SRAM_START 0x31000000
54#define SRAM_SIZE 0x00200000
55
56#define DDR_START 0x70000000
57#define DDR_SIZE 0x02000000
58
59#define STACK_HEAP 0x30080000
60
61#endif //TRUSTZONE_BUILD
62
63/* ----------------------------------------------------------------------------
64 Stack seal size definition
65 *----------------------------------------------------------------------------*/
66#if defined(USE_TRUSTZONE) && defined(TRUSTZONE_SECURE)
67#define __STACKSEAL_SIZE ( 8 )
68#else
69#define __STACKSEAL_SIZE ( 0 )
70#endif
71
72APP_IMAGE LR_START LR_SIZE
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010073{
74 ; ITCM 512kB
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +010075 rom_exec ITCM_START ITCM_SIZE
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010076 {
77 *.o (RESET, +First)
78 *(InRoot$$Sections)
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +010079 ; Make sure reset_handler ends up in root segment, when split across
80 ; ITCM and DTCM
81 startup_ARMCM55.o
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010082 .ANY (+RO)
83 }
84
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +010085#if defined(USE_TRUSTZONE) && defined(TRUSTZONE_SECURE)
86 ; MPS3 BRAM
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010087 ; Shared between Cortex-M and the NPU
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +010088 BRAM BRAM_START UNINIT (BRAM_SIZE - TZ_NSC_SIZE)
89 {
90 }
91
92 ROM_NSC TZ_NSC_START TZ_NSC_SIZE
93 {
94 *(Veneer$$CMSE)
95 }
96#else
97 ; MPS3 BRAM
98 BRAM BRAM_START UNINIT BRAM_SIZE
99 {
100 }
101#endif
102
103 ; DTCM 512kB
104 ; Only accessible from the Cortex-M
105 DTCM DTCM_START (DTCM_SIZE - STACK_SIZE - HEAP_SIZE - __STACKSEAL_SIZE)
106 {
107 .ANY1 (+RW +ZI)
108 }
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100109
110 ; SSE-300 SRAM (3 cycles read latency) from M55/U55
111 ; 2x2MB - only first part mapped
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100112 SRAM SRAM_START UNINIT SRAM_SIZE
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100113 {
114#ifndef ETHOSU_FAST_MEMORY_SIZE
115 ; Place tensor arena in SRAM if we do not have a fast memory area
Jonny Svärdf521be92021-03-01 14:35:49 +0100116 * (.bss.tensor_arena)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100117#else
118 * (.bss.ethosu_scratch)
119#endif
120 }
121
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100122 ARM_LIB_HEAP (STACK_HEAP - STACK_SIZE - __STACKSEAL_SIZE - HEAP_SIZE) EMPTY ALIGN 8 HEAP_SIZE {}
123 ARM_LIB_STACK (STACK_HEAP - STACK_SIZE - __STACKSEAL_SIZE) EMPTY ALIGN 8 STACK_SIZE {}
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100124
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100125#if defined(USE_TRUSTZONE) && defined(TRUSTZONE_SECURE)
126 STACKSEAL +0 EMPTY __STACKSEAL_SIZE {
127 ; Reserve empty region for stack seal immediately after stack
128 }
129#endif
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100130}
131
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100132LOAD_REGION_1 DDR_START DDR_SIZE
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100133{
134 ; 2GB DDR4 available
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100135 rom_dram DDR_START
136#if defined(USE_TRUSTZONE) && defined(TRUSTZONE_NONSECURE)
137 {
138 }
139#else //trustzone secure or non-trustzone
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100140 {
141 * (network_model_sec)
142 * (input_data_sec)
143 * (expected_output_data_sec)
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100144 * (output_data_sec)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100145 }
146
147#ifdef ETHOSU_FAST_MEMORY_SIZE
148 ; Place tensor arena in DRAM if we have a fast memory area
149 ARENA +0 UNINIT ALIGN 16
150 {
Jonny Svärdf521be92021-03-01 14:35:49 +0100151 * (.bss.tensor_arena)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100152 }
153#endif
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100154#endif
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100155}