blob: bc91603e7a32e9c989bfe459157023b502732920 [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
Jonny Svärd503b7352024-06-24 13:00:13 +020081 ETHOSU_HAS_TA
82
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010083 # Configure PMU events
Nir Ekhauz4756bf12021-06-27 11:20:24 +030084 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}
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010087 ETHOSU_PMU_EVENT_3=${ETHOSU_PMU_EVENT_3}
Nir Ekhauz4756bf12021-06-27 11:20:24 +030088
Kristofer Jonssonf7edeb72022-01-17 09:40:09 +010089 # Placement or TLFu model and area. 0 = SRAM, 1 = DRAM
90 ETHOSU_MODEL=$<STREQUAL:${MEMORY_MODEL},dram>
91 ETHOSU_ARENA=$<STREQUAL:${MEMORY_ARENA},dram>)
Nir Ekhauz3c505ca2021-06-06 14:57:50 +030092
Nir Ekhauza58edd82021-10-04 12:21:17 +030093# AXI Timing adaptors
94set(registers MAXR MAXW MAXRW RLATENCY WLATENCY PULSE_ON PULSE_OFF BWCAP PERFCTRL PERFCNT MODE HISTBIN HISTCNT)
95
96foreach(register ${registers})
97 foreach(index RANGE 0 1)
98 set(name ETHOSU_TA_${register}_${index})
99 set(${name} -1 CACHE STRING "${name}")
Kristofer Jonsson64f37cd2021-10-19 10:54:47 +0200100
101 if (${name} GREATER_EQUAL 0)
102 target_compile_definitions(ethosu_target_common INTERFACE ${name}=${${name}})
103 endif()
Nir Ekhauza58edd82021-10-04 12:21:17 +0300104 endforeach()
105endforeach()
106
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100107# Linker script
Kristofer Jonssonec451552021-06-04 18:02:59 +0200108set(LINK_FILE platform CACHE STRING "Link file")
109
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100110ethosu_target_link_options(ethosu_target_link INTERFACE
Kristofer Jonssonec451552021-06-04 18:02:59 +0200111 LINK_FILE ${LINK_FILE}
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100112 ENTRY Reset_Handler)
113
114# Add drivers
115target_sources(ethosu_target_startup INTERFACE
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100116 retarget.c
Yulia Garboviche9cdc632021-11-23 20:00:04 +0200117 target.cpp)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100118
Kristofer Jonsson3b137322021-06-28 20:17:04 +0200119target_link_libraries(ethosu_target_startup INTERFACE
Kristofer Jonsson7b8fa5e2021-12-16 14:02:56 +0100120 $<$<TARGET_EXISTS:ethosu_core_driver>:ethosu_core_driver;timing_adapter>
Yulia Garboviche9cdc632021-11-23 20:00:04 +0200121 mpu
Yulia Garboviche9cdc632021-11-23 20:00:04 +0200122 ethosu_mhu_dummy
123 ethosu_uart_cmsdk_apb)
Kristofer Jonsson3b137322021-06-28 20:17:04 +0200124
Kristofer Jonssone56b6e42022-09-29 11:52:22 +0200125if (TARGET event_recorder)
126 target_include_directories(event_recorder BEFORE INTERFACE
127 event_recorder)
128endif()
129
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100130###############################################################################
131# Applications
132###############################################################################
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100133
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100134# Add all applications
135add_subdirectory(../../applications applications)