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