Kristofer Jonsson | 43ce491 | 2020-11-20 09:42:53 +0100 | [diff] [blame] | 1 | #! cpp |
| 2 | |
| 3 | /* |
| 4 | * Copyright (c) 2019-2020 Arm Limited. All rights reserved. |
| 5 | * |
| 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 Jonsson | f62c3d7 | 2021-01-21 17:39:03 +0100 | [diff] [blame] | 29 | #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 |
| 42 | #define LR_SIZE 0x01000000 |
| 43 | |
| 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 | |
| 72 | APP_IMAGE LR_START LR_SIZE |
Kristofer Jonsson | 43ce491 | 2020-11-20 09:42:53 +0100 | [diff] [blame] | 73 | { |
| 74 | ; ITCM 512kB |
Kristofer Jonsson | f62c3d7 | 2021-01-21 17:39:03 +0100 | [diff] [blame] | 75 | rom_exec ITCM_START ITCM_SIZE |
Kristofer Jonsson | 43ce491 | 2020-11-20 09:42:53 +0100 | [diff] [blame] | 76 | { |
| 77 | *.o (RESET, +First) |
| 78 | *(InRoot$$Sections) |
Kristofer Jonsson | f62c3d7 | 2021-01-21 17:39:03 +0100 | [diff] [blame] | 79 | ; Make sure reset_handler ends up in root segment, when split across |
| 80 | ; ITCM and DTCM |
| 81 | startup_ARMCM55.o |
Kristofer Jonsson | 43ce491 | 2020-11-20 09:42:53 +0100 | [diff] [blame] | 82 | .ANY (+RO) |
| 83 | } |
| 84 | |
Kristofer Jonsson | f62c3d7 | 2021-01-21 17:39:03 +0100 | [diff] [blame] | 85 | #if defined(USE_TRUSTZONE) && defined(TRUSTZONE_SECURE) |
| 86 | ; MPS3 BRAM |
Kristofer Jonsson | 43ce491 | 2020-11-20 09:42:53 +0100 | [diff] [blame] | 87 | ; Shared between Cortex-M and the NPU |
Kristofer Jonsson | f62c3d7 | 2021-01-21 17:39:03 +0100 | [diff] [blame] | 88 | 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 Jonsson | 43ce491 | 2020-11-20 09:42:53 +0100 | [diff] [blame] | 109 | |
| 110 | ; SSE-300 SRAM (3 cycles read latency) from M55/U55 |
| 111 | ; 2x2MB - only first part mapped |
Kristofer Jonsson | f62c3d7 | 2021-01-21 17:39:03 +0100 | [diff] [blame] | 112 | SRAM SRAM_START UNINIT SRAM_SIZE |
Kristofer Jonsson | 43ce491 | 2020-11-20 09:42:53 +0100 | [diff] [blame] | 113 | { |
| 114 | #ifndef ETHOSU_FAST_MEMORY_SIZE |
| 115 | ; Place tensor arena in SRAM if we do not have a fast memory area |
| 116 | * (.bss.NoInit) ; Tensor Arena |
| 117 | #else |
| 118 | * (.bss.ethosu_scratch) |
| 119 | #endif |
| 120 | } |
| 121 | |
Kristofer Jonsson | f62c3d7 | 2021-01-21 17:39:03 +0100 | [diff] [blame] | 122 | 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 Jonsson | 43ce491 | 2020-11-20 09:42:53 +0100 | [diff] [blame] | 124 | |
Kristofer Jonsson | f62c3d7 | 2021-01-21 17:39:03 +0100 | [diff] [blame] | 125 | #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 Jonsson | 43ce491 | 2020-11-20 09:42:53 +0100 | [diff] [blame] | 130 | } |
| 131 | |
Kristofer Jonsson | f62c3d7 | 2021-01-21 17:39:03 +0100 | [diff] [blame] | 132 | LOAD_REGION_1 DDR_START DDR_SIZE |
Kristofer Jonsson | 43ce491 | 2020-11-20 09:42:53 +0100 | [diff] [blame] | 133 | { |
| 134 | ; 2GB DDR4 available |
Kristofer Jonsson | f62c3d7 | 2021-01-21 17:39:03 +0100 | [diff] [blame] | 135 | rom_dram DDR_START |
| 136 | #if defined(USE_TRUSTZONE) && defined(TRUSTZONE_NONSECURE) |
| 137 | { |
| 138 | } |
| 139 | #else //trustzone secure or non-trustzone |
Kristofer Jonsson | 43ce491 | 2020-11-20 09:42:53 +0100 | [diff] [blame] | 140 | { |
| 141 | * (network_model_sec) |
| 142 | * (input_data_sec) |
| 143 | * (expected_output_data_sec) |
Kristofer Jonsson | f62c3d7 | 2021-01-21 17:39:03 +0100 | [diff] [blame] | 144 | * (output_data_sec) |
Kristofer Jonsson | 43ce491 | 2020-11-20 09:42:53 +0100 | [diff] [blame] | 145 | } |
| 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 | { |
| 151 | * (.bss.NoInit) ; Tensor Arena |
| 152 | } |
| 153 | #endif |
Kristofer Jonsson | f62c3d7 | 2021-01-21 17:39:03 +0100 | [diff] [blame] | 154 | #endif |
Kristofer Jonsson | 43ce491 | 2020-11-20 09:42:53 +0100 | [diff] [blame] | 155 | } |