aboutsummaryrefslogtreecommitdiff
path: root/targets/corstone-300/CMakeLists.txt
blob: bd73481142aa71b9089562172ae6c1ffdb276bc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#
# Copyright (c) 2020-2021 Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the License); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an AS IS BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#############################################################################
# Default parameters
#############################################################################

set(TARGET_CPU "cortex-m55" CACHE INTERNAL "")

if (NOT CMAKE_TOOLCHAIN_FILE)
    set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/toolchain/armclang.cmake")
endif()

set(ETHOSU_COMMAND_DEFAULT python3 ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/run_ctest.py -t corstone-300 CACHE INTERNAL "Default test command")

#############################################################################
# Project
#############################################################################

# Note: On Windows systems CMake 3.20.0 might cause issues with errouneous dependency make files.
#       Issues solved with CMake 3.20.1.
cmake_minimum_required(VERSION 3.15.6)

project(ethos-u-corstone-300 VERSION 0.0.1)

include(CTest)

include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/helpers.cmake)

#############################################################################
# Corstone-300
#############################################################################

get_filename_component(ETHOSU_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME)
message("Configuring target ${ETHOSU_TARGET}")

# Enable trustzone support in core_software
set(TRUSTZONE_BUILD ON)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../common target)

set(ETHOSU_TARGET_NPU_CONFIG "ethos-u55-128" CACHE STRING "NPU configuration")
set(ETHOSU_TARGET_NPU_COUNT 1 CACHE INTERNAL "Number of NPUs")
set(ETHOSU_TARGET_NPU_TA_COUNT 2 CACHE INTERNAL "Number of timing adapters per NPU")

set(ETHOSU_PMU_EVENT_0 -1 CACHE STRING "PMU Event #0")
set(ETHOSU_PMU_EVENT_1 -1 CACHE STRING "PMU Event #1")
set(ETHOSU_PMU_EVENT_2 -1 CACHE STRING "PMU Event #2")
set(ETHOSU_PMU_EVENT_3 -1 CACHE STRING "PMU Event #3")

target_compile_definitions(ethosu_target_common INTERFACE
    ETHOSU_PMU_EVENT_0=${ETHOSU_PMU_EVENT_0}
    ETHOSU_PMU_EVENT_1=${ETHOSU_PMU_EVENT_1}
    ETHOSU_PMU_EVENT_2=${ETHOSU_PMU_EVENT_2}
    ETHOSU_PMU_EVENT_3=${ETHOSU_PMU_EVENT_3})

set(MEMORY_MODEL "dram" CACHE STRING "Memory config for model")
set(MEMORY_ARENA "dram" CACHE STRING "Memory config for arena")

target_compile_definitions(ethosu_target_common INTERFACE
    ETHOSU_NPU_TA_COUNT=${ETHOSU_TARGET_NPU_TA_COUNT}
    ETHOSU_NPU_COUNT=${ETHOSU_TARGET_NPU_COUNT})

# Model memory configuration
# For ETHOSU_MODEL: 0 - SRAM, 1 - DRAM
if (MEMORY_MODEL STREQUAL "dram")
    target_compile_definitions(ethosu_target_common INTERFACE
    ETHOSU_MODEL=1)
else()
    target_compile_definitions(ethosu_target_common INTERFACE
    ETHOSU_MODEL=0)
endif()

# Arena memory configuration
# For ETHOSU_ARENA: 0 - SRAM, 1 - DRAM
if (MEMORY_ARENA STREQUAL "dram")
    target_compile_definitions(ethosu_target_common INTERFACE
    ETHOSU_ARENA=1)
else()
    target_compile_definitions(ethosu_target_common INTERFACE
    ETHOSU_ARENA=0)
endif()

# Linker script
set(LINK_FILE platform CACHE STRING "Link file")

ethosu_target_link_options(ethosu_target_link INTERFACE
    LINK_FILE ${LINK_FILE}
    ENTRY Reset_Handler)

# Add drivers
target_sources(ethosu_target_startup INTERFACE
    retarget.c
    uart.c
    target.cpp
    mpu.cpp)

target_link_libraries(ethosu_target_startup INTERFACE
    $<$<TARGET_EXISTS:ethosu_core_driver>:ethosu_core_driver;timing_adapter>)

if (TARGET ethosu_core_driver)
    target_compile_definitions(ethosu_core_driver PUBLIC
        ETHOSU)
endif()

###############################################################################
# Applications
###############################################################################

# Add all applications
add_subdirectory(../../applications applications)