blob: 2044c0cd571627151b83914bd7e48f6d9bf66285 [file] [log] [blame]
Kristofer Jonsson93175812022-04-21 19:27:11 +02001#
Jonny Svärd36293102024-06-17 13:16:38 +02002# SPDX-FileCopyrightText: Copyright 2020-2024 Arm Limited and/or its affiliates <open-source-office@arm.com>
Kristofer Jonsson93175812022-04-21 19:27:11 +02003# SPDX-License-Identifier: Apache-2.0
4#
5# Licensed under the Apache License, Version 2.0 (the License); you may
6# not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an AS IS BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17
18#############################################################################
19# Default parameters
20#############################################################################
21
Davide Grohmanna8832cc2022-05-06 16:35:16 +020022set(TARGET_CPU "cortex-m85" CACHE INTERNAL "")
Kristofer Jonsson93175812022-04-21 19:27:11 +020023
24if (NOT CMAKE_TOOLCHAIN_FILE)
25 set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/toolchain/armclang.cmake")
26endif()
27
Davide Grohmann7275f502022-08-09 14:32:52 +020028set(ETHOSU_TARGET_NPU_CONFIG "ethos-u55-256" CACHE STRING "NPU configuration")
Kristofer Jonsson93175812022-04-21 19:27:11 +020029
30set(ETHOSU_PMU_EVENT_0 -1 CACHE STRING "PMU Event #0")
31set(ETHOSU_PMU_EVENT_1 -1 CACHE STRING "PMU Event #1")
32set(ETHOSU_PMU_EVENT_2 -1 CACHE STRING "PMU Event #2")
33set(ETHOSU_PMU_EVENT_3 -1 CACHE STRING "PMU Event #3")
34
35set(FAST_MEMORY_SIZE 0 CACHE STRING "Size of relocated fast memory scratch tensor")
36
37if (${FAST_MEMORY_SIZE} EQUAL 0)
38 set(MEMORY_DEFAULT "sram")
39else()
40 set(MEMORY_DEFAULT "dram")
41endif()
42
43set(MEMORY_MODEL ${MEMORY_DEFAULT} CACHE STRING "Memory config for model")
44set(MEMORY_ARENA ${MEMORY_DEFAULT} CACHE STRING "Memory config for arena")
45
46set(SYSTEM_CORE_CLOCK "25000000" CACHE INTERNAL "System core clock (Hz)")
47
48#############################################################################
49# Project
50#############################################################################
51
52cmake_minimum_required(VERSION 3.21)
53
Kristofer Jonssonde1a9f62022-08-03 15:51:08 +020054project(ethos-u-corstone-310 VERSION 0.0.1)
Kristofer Jonsson93175812022-04-21 19:27:11 +020055
56include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/helpers.cmake)
57
58#############################################################################
Ledion Daja204210b2023-08-15 13:32:07 +020059# Corstone-310
Kristofer Jonsson93175812022-04-21 19:27:11 +020060#############################################################################
61
62get_filename_component(ETHOSU_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME)
63message("Configuring target ${ETHOSU_TARGET}")
64
65# Enable CTest
66include(CTest)
67set(Python3_FIND_STRATEGY LOCATION)
68find_package(Python3 COMPONENTS Interpreter)
69ethosu_get_architecture(${ETHOSU_TARGET_NPU_CONFIG})
70set(ETHOSU_COMMAND_DEFAULT ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/run_ctest.py
71 -t corstone-310
72 -a ethos-${ETHOSU_ARCH}
73 -m ${ETHOSU_NUM_MACS}
74 CACHE INTERNAL "Default test command")
75
76# Enable trustzone support in core_software
77set(TRUSTZONE_BUILD OFF)
78
79# Include common targets
80add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../common target)
81
82target_compile_definitions(ethosu_target_common INTERFACE
Kristofer Jonsson93175812022-04-21 19:27:11 +020083 # Configure PMU events
84 ETHOSU_PMU_EVENT_0=${ETHOSU_PMU_EVENT_0}
85 ETHOSU_PMU_EVENT_1=${ETHOSU_PMU_EVENT_1}
86 ETHOSU_PMU_EVENT_2=${ETHOSU_PMU_EVENT_2}
87 ETHOSU_PMU_EVENT_3=${ETHOSU_PMU_EVENT_3}
88
89 # Placement or TLFu model and area. 0 = SRAM, 1 = DRAM
90 ETHOSU_FAST_MEMORY_SIZE=${FAST_MEMORY_SIZE}
91 ETHOSU_MODEL=$<STREQUAL:${MEMORY_MODEL},dram>
92 ETHOSU_ARENA=$<STREQUAL:${MEMORY_ARENA},dram>)
93
Kristofer Jonsson93175812022-04-21 19:27:11 +020094# Linker script
95set(LINK_FILE platform CACHE STRING "Link file")
96
97ethosu_target_link_options(ethosu_target_link INTERFACE
98 LINK_FILE ${LINK_FILE}
99 ENTRY Reset_Handler)
100
101# Add drivers
102target_sources(ethosu_target_startup INTERFACE
103 retarget.c
104 target.cpp)
105
106target_link_libraries(ethosu_target_startup INTERFACE
107 $<$<TARGET_EXISTS:ethosu_core_driver>:ethosu_core_driver;timing_adapter>
108 mpu
109 ethosu_mhu_dummy
110 ethosu_uart_cmsdk_apb)
111
Kristofer Jonsson93175812022-04-21 19:27:11 +0200112###############################################################################
113# Applications
114###############################################################################
115
116# Add all applications
117add_subdirectory(../../applications applications)