blob: 5dc38040fc91df04f9b78428a69279b8d89d14a0 [file] [log] [blame]
Kristofer Jonsson43ce4912020-11-20 09:42:53 +01001#
Anton Mobergfa3e51b2021-03-31 11:05:02 +02002# Copyright (c) 2020-2021 Arm Limited. All rights reserved.
Kristofer Jonsson43ce4912020-11-20 09:42:53 +01003#
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#############################################################################
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +010020# Default parameters
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010021#############################################################################
22
Kristofer Jonssonec451552021-06-04 18:02:59 +020023set(TARGET_CPU "cortex-m55" CACHE INTERNAL "")
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010024
25if (NOT CMAKE_TOOLCHAIN_FILE)
26 set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/toolchain/armclang.cmake")
27endif()
28
Kristofer Jonssond3874052021-11-25 13:07:27 +010029set(Python3_FIND_STRATEGY LOCATION)
30find_package(Python3 COMPONENTS Interpreter)
31
32set(ETHOSU_COMMAND_DEFAULT ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/run_ctest.py -t corstone-300 CACHE INTERNAL "Default test command")
Jonny Svärd991af2b2021-04-15 17:31:01 +020033
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010034#############################################################################
35# Project
36#############################################################################
37
Kristofer Jonssone07dda62021-11-22 12:34:25 +010038cmake_minimum_required(VERSION 3.20)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010039
40project(ethos-u-corstone-300 VERSION 0.0.1)
41
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +010042include(CTest)
43
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010044include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/helpers.cmake)
45
46#############################################################################
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010047# Corstone-300
48#############################################################################
49
Per Åstrand79929ff2021-01-26 14:42:43 +010050get_filename_component(ETHOSU_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME)
51message("Configuring target ${ETHOSU_TARGET}")
52
Per Åstranddfcc0172021-01-29 10:27:40 +010053# Enable trustzone support in core_software
54set(TRUSTZONE_BUILD ON)
55
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +010056add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../common target)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010057
Kristofer Jonssonec451552021-06-04 18:02:59 +020058set(ETHOSU_TARGET_NPU_CONFIG "ethos-u55-128" CACHE STRING "NPU configuration")
Jonny Svärdd6670902021-03-18 15:49:27 +010059set(ETHOSU_TARGET_NPU_COUNT 1 CACHE INTERNAL "Number of NPUs")
60set(ETHOSU_TARGET_NPU_TA_COUNT 2 CACHE INTERNAL "Number of timing adapters per NPU")
61
Nir Ekhauz1af67f72021-09-13 16:56:39 +030062set(ETHOSU_PMU_EVENT_0 -1 CACHE STRING "PMU Event #0")
63set(ETHOSU_PMU_EVENT_1 -1 CACHE STRING "PMU Event #1")
64set(ETHOSU_PMU_EVENT_2 -1 CACHE STRING "PMU Event #2")
65set(ETHOSU_PMU_EVENT_3 -1 CACHE STRING "PMU Event #3")
Nir Ekhauz4756bf12021-06-27 11:20:24 +030066
67target_compile_definitions(ethosu_target_common INTERFACE
68 ETHOSU_PMU_EVENT_0=${ETHOSU_PMU_EVENT_0}
69 ETHOSU_PMU_EVENT_1=${ETHOSU_PMU_EVENT_1}
70 ETHOSU_PMU_EVENT_2=${ETHOSU_PMU_EVENT_2}
71 ETHOSU_PMU_EVENT_3=${ETHOSU_PMU_EVENT_3})
72
Nir Ekhauz3c505ca2021-06-06 14:57:50 +030073set(MEMORY_MODEL "dram" CACHE STRING "Memory config for model")
74set(MEMORY_ARENA "dram" CACHE STRING "Memory config for arena")
75
Jonny Svärdd6670902021-03-18 15:49:27 +010076target_compile_definitions(ethosu_target_common INTERFACE
77 ETHOSU_NPU_TA_COUNT=${ETHOSU_TARGET_NPU_TA_COUNT}
78 ETHOSU_NPU_COUNT=${ETHOSU_TARGET_NPU_COUNT})
79
Nir Ekhauz3c505ca2021-06-06 14:57:50 +030080# Model memory configuration
81# For ETHOSU_MODEL: 0 - SRAM, 1 - DRAM
82if (MEMORY_MODEL STREQUAL "dram")
83 target_compile_definitions(ethosu_target_common INTERFACE
84 ETHOSU_MODEL=1)
85else()
86 target_compile_definitions(ethosu_target_common INTERFACE
87 ETHOSU_MODEL=0)
88endif()
89
90# Arena memory configuration
91# For ETHOSU_ARENA: 0 - SRAM, 1 - DRAM
92if (MEMORY_ARENA STREQUAL "dram")
93 target_compile_definitions(ethosu_target_common INTERFACE
94 ETHOSU_ARENA=1)
95else()
96 target_compile_definitions(ethosu_target_common INTERFACE
97 ETHOSU_ARENA=0)
98endif()
99
Nir Ekhauza58edd82021-10-04 12:21:17 +0300100# AXI Timing adaptors
101set(registers MAXR MAXW MAXRW RLATENCY WLATENCY PULSE_ON PULSE_OFF BWCAP PERFCTRL PERFCNT MODE HISTBIN HISTCNT)
102
103foreach(register ${registers})
104 foreach(index RANGE 0 1)
105 set(name ETHOSU_TA_${register}_${index})
106 set(${name} -1 CACHE STRING "${name}")
Kristofer Jonsson64f37cd2021-10-19 10:54:47 +0200107
108 if (${name} GREATER_EQUAL 0)
109 target_compile_definitions(ethosu_target_common INTERFACE ${name}=${${name}})
110 endif()
Nir Ekhauza58edd82021-10-04 12:21:17 +0300111 endforeach()
112endforeach()
113
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100114# Linker script
Kristofer Jonssonec451552021-06-04 18:02:59 +0200115set(LINK_FILE platform CACHE STRING "Link file")
116
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100117ethosu_target_link_options(ethosu_target_link INTERFACE
Kristofer Jonssonec451552021-06-04 18:02:59 +0200118 LINK_FILE ${LINK_FILE}
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100119 ENTRY Reset_Handler)
120
121# Add drivers
122target_sources(ethosu_target_startup INTERFACE
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100123 retarget.c
Yulia Garboviche9cdc632021-11-23 20:00:04 +0200124 target.cpp)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100125
Kristofer Jonsson3b137322021-06-28 20:17:04 +0200126target_link_libraries(ethosu_target_startup INTERFACE
Yulia Garboviche9cdc632021-11-23 20:00:04 +0200127 $<$<TARGET_EXISTS:ethosu_core_driver>:ethosu_core_driver>
128 mpu
129 timing_adapter
130 ethosu_mhu_dummy
131 ethosu_uart_cmsdk_apb)
Kristofer Jonsson3b137322021-06-28 20:17:04 +0200132
133if (TARGET ethosu_core_driver)
134 target_compile_definitions(ethosu_core_driver PUBLIC
135 ETHOSU)
136endif()
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100137
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100138###############################################################################
139# Applications
140###############################################################################
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100141
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100142# Add all applications
143add_subdirectory(../../applications applications)