Kristofer Jonsson | 7422610 | 2022-05-25 16:55:24 +0200 | [diff] [blame] | 1 | # |
Jonny Svärd | 229d7a0 | 2023-04-04 16:53:59 +0200 | [diff] [blame] | 2 | # SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> |
Kristofer Jonsson | 7422610 | 2022-05-25 16:55:24 +0200 | [diff] [blame] | 3 | # |
| 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 | |
| 19 | ############################################################################# |
| 20 | # Paths |
| 21 | ############################################################################# |
| 22 | |
| 23 | set(CORE_PLATFORM_PATH "${CMAKE_CURRENT_SOURCE_DIR}/<TODO>/core_platform" CACHE PATH "Path to Core Platform") |
| 24 | |
| 25 | ############################################################################# |
| 26 | # Default toolchain |
| 27 | ############################################################################# |
| 28 | |
| 29 | set(TARGET_CPU "<TODO e.g. cortex-m55>" CACHE STRING "Target CPU") |
| 30 | |
| 31 | if (NOT CMAKE_TOOLCHAIN_FILE) |
| 32 | # TODO Select default toolchain |
| 33 | # - Arm Clang: ${CORE_PLATFORM_PATH}/cmake/toolchain/armclang.cmake |
| 34 | # - GCC : ${CORE_PLATFORM_PATH}/cmake/toolchain/arm-none-eabi-gcc.cmake |
| 35 | # - Else : Implement your own toolchain file |
| 36 | set(CMAKE_TOOLCHAIN_FILE "${CORE_PLATFORM_PATH}/cmake/toolchain/armclang.cmake") |
| 37 | endif() |
| 38 | |
| 39 | ############################################################################# |
| 40 | # Default configuration |
| 41 | ############################################################################# |
| 42 | |
| 43 | get_filename_component(ETHOSU_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) |
| 44 | message("Configuring target ${ETHOSU_TARGET}") |
| 45 | |
| 46 | set(ETHOSU_TARGET_NPU_CONFIG "<TODO> e.g. ethos-u65-256" CACHE STRING "NPU configuration") |
| 47 | set(ETHOSU_TARGET_NPU_COUNT 1 CACHE INTERNAL "Number of NPUs") |
| 48 | set(ETHOSU_TARGET_NPU_TA_COUNT 0 CACHE INTERNAL "Number of timing adapters per NPU") |
| 49 | |
| 50 | # Fast memory size |
| 51 | # If the TFLM model and arena are placed in Flash/DRAM, and if the NPU is Ethos-U65, |
| 52 | # then a smaller fast memory buffer can be placed in SRAM. This is called 'spilling'. |
| 53 | set(FAST_MEMORY_SIZE 0 CACHE STRING "Size of relocated fast memory scratch tensor") |
| 54 | set(MEMORY_MODEL "sram" CACHE STRING "Memory config for model") |
| 55 | set(MEMORY_ARENA "sram" CACHE STRING "Memory config for arena") |
| 56 | |
| 57 | # UART settings |
| 58 | set(UART0_BASE "<TODO>" CACHE INTERNAL "UART base address") |
| 59 | set(UART0_BAUDRATE "<TODO e.g. 115200>" CACHE INTERNAL "UART baudrate, N/A for model and juno") |
| 60 | set(SYSTEM_CORE_CLOCK "<TODO e.g. 25000000>" CACHE INTERNAL "System core clock (Hz)") |
| 61 | |
| 62 | ############################################################################# |
| 63 | # Project |
| 64 | ############################################################################# |
| 65 | |
| 66 | cmake_minimum_required(VERSION 3.21) |
| 67 | |
| 68 | project(ethos-u-demo VERSION 0.0.1) |
| 69 | |
| 70 | include(${CORE_PLATFORM_PATH}/cmake/helpers.cmake) |
| 71 | |
| 72 | ############################################################################# |
| 73 | # Target |
| 74 | ############################################################################# |
| 75 | |
| 76 | # Include common target |
| 77 | add_subdirectory(${CORE_PLATFORM_PATH}/targets/common core_platform/target/common) |
| 78 | |
| 79 | # Include drivers |
| 80 | add_subdirectory(../../drivers drivers) |
| 81 | |
| 82 | # Common defines |
| 83 | target_compile_definitions(ethosu_target_common INTERFACE |
| 84 | # Configure NPU architecture and number of timing adapters |
| 85 | ETHOSU_NPU_COUNT=${ETHOSU_TARGET_NPU_COUNT} |
| 86 | ETHOSU_NPU_TA_COUNT=${ETHOSU_TARGET_NPU_TA_COUNT} |
| 87 | |
| 88 | # Placement or TLFu model and area. 0 = SRAM, 1 = DRAM |
| 89 | # The scatter file and linker script must be designed to switch on these defines |
| 90 | ETHOSU_FAST_MEMORY_SIZE=${FAST_MEMORY_SIZE} |
| 91 | ETHOSU_MODEL=$<STREQUAL:${MEMORY_MODEL},dram> |
| 92 | ETHOSU_ARENA=$<STREQUAL:${MEMORY_ARENA},dram>) |
| 93 | |
| 94 | # Linker script |
| 95 | set(LINK_FILE platform CACHE STRING "Link file") |
| 96 | |
| 97 | ethosu_target_link_options(ethosu_target_link INTERFACE |
| 98 | LINK_FILE ${LINK_FILE} |
| 99 | ENTRY Reset_Handler) |
| 100 | |
| 101 | target_sources(ethosu_target_startup INTERFACE |
| 102 | retarget.c |
| 103 | target.cpp) |
| 104 | |
| 105 | target_link_libraries(ethosu_target_startup INTERFACE |
| 106 | $<$<TARGET_EXISTS:ethosu_core_driver>:ethosu_core_driver> |
| 107 | # TODO customize which libraries to include |
| 108 | mpu |
| 109 | ethosu_mhu_dummy |
| 110 | ethosu_uart_cmsdk_apb) |
| 111 | |
| 112 | if (TARGET ethosu_core_driver) |
| 113 | target_compile_definitions(ethosu_core_driver PUBLIC |
Kristofer Jonsson | 7422610 | 2022-05-25 16:55:24 +0200 | [diff] [blame] | 114 | # The TFLM arena is accessed over base address 1. The region config |
| 115 | # controls if the memory transactions are routed over AXI 0 (region config |
| 116 | # 0 or 1) or AXI 1 (region config 2 or 3). |
| 117 | NPU_REGIONCFG_1=$<if:$<STREQUAL:${MEMORY_ARENA},dram>,0,2>) |
| 118 | endif() |
| 119 | |
| 120 | ############################################################################### |
| 121 | # CTest |
| 122 | ############################################################################### |
| 123 | |
| 124 | # TODO Uncomment to enable ctest |
| 125 | # include(CTest) |
| 126 | |
| 127 | # Uncomment if Python interpreter is needed |
| 128 | #set(Python3_FIND_STRATEGY LOCATION) |
| 129 | #find_package(Python3 COMPONENTS Interpreter) |
| 130 | |
| 131 | # TODO Uncomment if ETHOSU_ARCH and ETHOSU_NUM_MACS are needed |
| 132 | # ethosu_get_architecture(${ETHOSU_TARGET_NPU_CONFIG}) |
| 133 | |
| 134 | set(ETHOSU_COMMAND_DEFAULT <TODO test command> CACHE INTERNAL "Default test command") |
| 135 | |
| 136 | ############################################################################### |
| 137 | # Applications |
| 138 | ############################################################################### |
| 139 | |
| 140 | add_subdirectory(${CORE_PLATFORM_PATH}/applications core_platform/applications) |
| 141 | add_subdirectory(../../applications applications) |