blob: 9f8ed364e744a219b7c4b7e40cc38813de0d8b3e [file] [log] [blame]
Kristofer Jonsson43ce4912020-11-20 09:42:53 +01001#
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 Jonsson43ce4912020-11-20 09:42:53 +01003# 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#############################################################################
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +010019# Default parameters
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010020#############################################################################
21
Kristofer Jonssonec451552021-06-04 18:02:59 +020022set(TARGET_CPU "cortex-m55" CACHE INTERNAL "")
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010023
24if (NOT CMAKE_TOOLCHAIN_FILE)
25 set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/toolchain/armclang.cmake")
26endif()
27
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010028set(ETHOSU_TARGET_NPU_CONFIG "ethos-u55-128" CACHE STRING "NPU configuration")
Kristofer Jonssond3874052021-11-25 13:07:27 +010029
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010030set(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(MEMORY_MODEL "dram" CACHE STRING "Memory config for model")
36set(MEMORY_ARENA "dram" CACHE STRING "Memory config for arena")
Jonny Svärd991af2b2021-04-15 17:31:01 +020037
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010038#############################################################################
39# Project
40#############################################################################
41
Nir Ekhauz6110f412022-01-18 12:45:20 +020042cmake_minimum_required(VERSION 3.21)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010043
44project(ethos-u-corstone-300 VERSION 0.0.1)
45
46include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/helpers.cmake)
47
48#############################################################################
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010049# Corstone-300
50#############################################################################
51
Per Åstrand79929ff2021-01-26 14:42:43 +010052get_filename_component(ETHOSU_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME)
53message("Configuring target ${ETHOSU_TARGET}")
54
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010055# Enable CTest
56include(CTest)
57set(Python3_FIND_STRATEGY LOCATION)
58find_package(Python3 COMPONENTS Interpreter)
59ethosu_get_architecture(${ETHOSU_TARGET_NPU_CONFIG})
Jonny Svärdd798c6e2022-05-24 13:23:00 +020060set(ETHOSU_COMMAND_OPTIONS
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010061 -t corstone-300
62 -a ethos-${ETHOSU_ARCH}
63 -m ${ETHOSU_NUM_MACS}
Jonny Svärdd798c6e2022-05-24 13:23:00 +020064 CACHE INTERNAL "Default test command options")
65
66if (ETHOSU_CTEST_TARMAC_TRACE)
67 list(APPEND ETHOSU_COMMAND_OPTIONS "--tarmac")
68endif()
69
70set(ETHOSU_COMMAND_DEFAULT ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/run_ctest.py
71 ${ETHOSU_COMMAND_OPTIONS}
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010072 CACHE INTERNAL "Default test command")
73
Per Åstranddfcc0172021-01-29 10:27:40 +010074# Enable trustzone support in core_software
75set(TRUSTZONE_BUILD ON)
76
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010077# Include common targets
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +010078add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../common target)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010079
Nir Ekhauz4756bf12021-06-27 11:20:24 +030080target_compile_definitions(ethosu_target_common INTERFACE
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010081 # Configure PMU events
Nir Ekhauz4756bf12021-06-27 11:20:24 +030082 ETHOSU_PMU_EVENT_0=${ETHOSU_PMU_EVENT_0}
83 ETHOSU_PMU_EVENT_1=${ETHOSU_PMU_EVENT_1}
84 ETHOSU_PMU_EVENT_2=${ETHOSU_PMU_EVENT_2}
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010085 ETHOSU_PMU_EVENT_3=${ETHOSU_PMU_EVENT_3}
Nir Ekhauz4756bf12021-06-27 11:20:24 +030086
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010087 # Placement or TLFu model and area. 0 = SRAM, 1 = DRAM
88 ETHOSU_MODEL=$<STREQUAL:${MEMORY_MODEL},dram>
89 ETHOSU_ARENA=$<STREQUAL:${MEMORY_ARENA},dram>)
Nir Ekhauz3c505ca2021-06-06 14:57:50 +030090
Nir Ekhauza58edd82021-10-04 12:21:17 +030091# AXI Timing adaptors
92set(registers MAXR MAXW MAXRW RLATENCY WLATENCY PULSE_ON PULSE_OFF BWCAP PERFCTRL PERFCNT MODE HISTBIN HISTCNT)
93
94foreach(register ${registers})
95 foreach(index RANGE 0 1)
96 set(name ETHOSU_TA_${register}_${index})
97 set(${name} -1 CACHE STRING "${name}")
Kristofer Jonsson64f37cd2021-10-19 10:54:47 +020098
99 if (${name} GREATER_EQUAL 0)
100 target_compile_definitions(ethosu_target_common INTERFACE ${name}=${${name}})
101 endif()
Nir Ekhauza58edd82021-10-04 12:21:17 +0300102 endforeach()
103endforeach()
104
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100105# Linker script
Kristofer Jonssonec451552021-06-04 18:02:59 +0200106set(LINK_FILE platform CACHE STRING "Link file")
107
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100108ethosu_target_link_options(ethosu_target_link INTERFACE
Kristofer Jonssonec451552021-06-04 18:02:59 +0200109 LINK_FILE ${LINK_FILE}
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100110 ENTRY Reset_Handler)
111
112# Add drivers
113target_sources(ethosu_target_startup INTERFACE
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100114 retarget.c
Yulia Garboviche9cdc632021-11-23 20:00:04 +0200115 target.cpp)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100116
Kristofer Jonsson3b137322021-06-28 20:17:04 +0200117target_link_libraries(ethosu_target_startup INTERFACE
Kristofer Jonsson7b8fa5e2021-12-16 14:02:56 +0100118 $<$<TARGET_EXISTS:ethosu_core_driver>:ethosu_core_driver;timing_adapter>
Yulia Garboviche9cdc632021-11-23 20:00:04 +0200119 mpu
Yulia Garboviche9cdc632021-11-23 20:00:04 +0200120 ethosu_mhu_dummy
121 ethosu_uart_cmsdk_apb)
Kristofer Jonsson3b137322021-06-28 20:17:04 +0200122
Kristofer Jonssone56b6e42022-09-29 11:52:22 +0200123if (TARGET event_recorder)
124 target_include_directories(event_recorder BEFORE INTERFACE
125 event_recorder)
126endif()
127
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100128###############################################################################
129# Applications
130###############################################################################
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100131
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100132# Add all applications
133add_subdirectory(../../applications applications)