blob: 6558e0d5df19b5fd7b5ad8519e53200e03947276 [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 Jonssonec451552021-06-04 18:02:59 +020029set(ETHOSU_COMMAND_DEFAULT python3 ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/run_ctest.py -t corstone-300 CACHE INTERNAL "Default test command")
Jonny Svärd991af2b2021-04-15 17:31:01 +020030
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010031#############################################################################
32# Project
33#############################################################################
34
Jonas Ohlssone0da7e02021-05-04 12:38:27 +020035# Note: On Windows systems CMake 3.20.0 might cause issues with errouneous dependency make files.
36# Issues solved with CMake 3.20.1.
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010037cmake_minimum_required(VERSION 3.15.6)
38
39project(ethos-u-corstone-300 VERSION 0.0.1)
40
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +010041include(CTest)
42
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010043include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/helpers.cmake)
44
45#############################################################################
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010046# Corstone-300
47#############################################################################
48
Per Åstrand79929ff2021-01-26 14:42:43 +010049get_filename_component(ETHOSU_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME)
50message("Configuring target ${ETHOSU_TARGET}")
51
Per Åstranddfcc0172021-01-29 10:27:40 +010052# Enable trustzone support in core_software
53set(TRUSTZONE_BUILD ON)
54
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +010055add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../common target)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010056
Kristofer Jonssonec451552021-06-04 18:02:59 +020057set(ETHOSU_TARGET_NPU_CONFIG "ethos-u55-128" CACHE STRING "NPU configuration")
Jonny Svärdd6670902021-03-18 15:49:27 +010058set(ETHOSU_TARGET_NPU_COUNT 1 CACHE INTERNAL "Number of NPUs")
59set(ETHOSU_TARGET_NPU_TA_COUNT 2 CACHE INTERNAL "Number of timing adapters per NPU")
60
Nir Ekhauz1af67f72021-09-13 16:56:39 +030061set(ETHOSU_PMU_EVENT_0 -1 CACHE STRING "PMU Event #0")
62set(ETHOSU_PMU_EVENT_1 -1 CACHE STRING "PMU Event #1")
63set(ETHOSU_PMU_EVENT_2 -1 CACHE STRING "PMU Event #2")
64set(ETHOSU_PMU_EVENT_3 -1 CACHE STRING "PMU Event #3")
Nir Ekhauz4756bf12021-06-27 11:20:24 +030065
66target_compile_definitions(ethosu_target_common INTERFACE
67 ETHOSU_PMU_EVENT_0=${ETHOSU_PMU_EVENT_0}
68 ETHOSU_PMU_EVENT_1=${ETHOSU_PMU_EVENT_1}
69 ETHOSU_PMU_EVENT_2=${ETHOSU_PMU_EVENT_2}
70 ETHOSU_PMU_EVENT_3=${ETHOSU_PMU_EVENT_3})
71
Nir Ekhauz3c505ca2021-06-06 14:57:50 +030072set(MEMORY_MODEL "dram" CACHE STRING "Memory config for model")
73set(MEMORY_ARENA "dram" CACHE STRING "Memory config for arena")
74
Jonny Svärdd6670902021-03-18 15:49:27 +010075target_compile_definitions(ethosu_target_common INTERFACE
76 ETHOSU_NPU_TA_COUNT=${ETHOSU_TARGET_NPU_TA_COUNT}
77 ETHOSU_NPU_COUNT=${ETHOSU_TARGET_NPU_COUNT})
78
Nir Ekhauz3c505ca2021-06-06 14:57:50 +030079# Model memory configuration
80# For ETHOSU_MODEL: 0 - SRAM, 1 - DRAM
81if (MEMORY_MODEL STREQUAL "dram")
82 target_compile_definitions(ethosu_target_common INTERFACE
83 ETHOSU_MODEL=1)
84else()
85 target_compile_definitions(ethosu_target_common INTERFACE
86 ETHOSU_MODEL=0)
87endif()
88
89# Arena memory configuration
90# For ETHOSU_ARENA: 0 - SRAM, 1 - DRAM
91if (MEMORY_ARENA STREQUAL "dram")
92 target_compile_definitions(ethosu_target_common INTERFACE
93 ETHOSU_ARENA=1)
94else()
95 target_compile_definitions(ethosu_target_common INTERFACE
96 ETHOSU_ARENA=0)
97endif()
98
Nir Ekhauza58edd82021-10-04 12:21:17 +030099# AXI Timing adaptors
100set(registers MAXR MAXW MAXRW RLATENCY WLATENCY PULSE_ON PULSE_OFF BWCAP PERFCTRL PERFCNT MODE HISTBIN HISTCNT)
101
102foreach(register ${registers})
103 foreach(index RANGE 0 1)
104 set(name ETHOSU_TA_${register}_${index})
105 set(${name} -1 CACHE STRING "${name}")
Kristofer Jonsson64f37cd2021-10-19 10:54:47 +0200106
107 if (${name} GREATER_EQUAL 0)
108 target_compile_definitions(ethosu_target_common INTERFACE ${name}=${${name}})
109 endif()
Nir Ekhauza58edd82021-10-04 12:21:17 +0300110 endforeach()
111endforeach()
112
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100113# Linker script
Kristofer Jonssonec451552021-06-04 18:02:59 +0200114set(LINK_FILE platform CACHE STRING "Link file")
115
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100116ethosu_target_link_options(ethosu_target_link INTERFACE
Kristofer Jonssonec451552021-06-04 18:02:59 +0200117 LINK_FILE ${LINK_FILE}
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100118 ENTRY Reset_Handler)
119
120# Add drivers
121target_sources(ethosu_target_startup INTERFACE
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100122 retarget.c
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100123 uart.c
Jonny Svärd991af2b2021-04-15 17:31:01 +0200124 target.cpp
125 mpu.cpp)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100126
Kristofer Jonsson3b137322021-06-28 20:17:04 +0200127target_link_libraries(ethosu_target_startup INTERFACE
128 $<$<TARGET_EXISTS:ethosu_core_driver>:ethosu_core_driver;timing_adapter>)
129
130if (TARGET ethosu_core_driver)
131 target_compile_definitions(ethosu_core_driver PUBLIC
132 ETHOSU)
133endif()
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100134
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100135###############################################################################
136# Applications
137###############################################################################
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100138
Kristofer Jonssonf62c3d72021-01-21 17:39:03 +0100139# Add all applications
140add_subdirectory(../../applications applications)