blob: 85470f978feec7448fdd16242ce7c32877f8c1f4 [file] [log] [blame]
Kristofer Jonsson18239302020-04-17 08:45:38 +02001#
Kristofer Jonssond0a08822022-10-10 12:36:03 +02002# SPDX-FileCopyrightText: Copyright 2019-2022 Arm Limited and/or its affiliates <open-source-office@arm.com>
Kristofer Jonsson18239302020-04-17 08:45:38 +02003#
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
Jonas Ohlsson7f3c1c92021-05-05 10:48:03 +020019# Note: On Windows systems CMake 3.20.0 might cause issues with errouneous dependency make files.
20# Issues solved with CMake 3.20.1.
Kristofer Jonsson18239302020-04-17 08:45:38 +020021cmake_minimum_required(VERSION 3.15.6)
22
23project(core_software VERSION 0.0.1)
24
25#
26# Define build options
27#
28
29# Setup paths
30set(CMSIS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmsis" CACHE PATH "Path to CMSIS.")
Kristofer Jonssond0a08822022-10-10 12:36:03 +020031set(CMSIS_NN_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmsis-nn" CACHE PATH "Path to CMSIS-NN.")
Jens Elofssona9817a12021-05-18 11:30:35 +020032set(CMSIS_VIEW_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmsis-view" CACHE PATH "Path to cmsis-view.")
Kristofer Jonsson18239302020-04-17 08:45:38 +020033set(CORE_DRIVER_PATH "${CMAKE_CURRENT_SOURCE_DIR}/core_driver" CACHE PATH "Path to core driver.")
Kristofer Jonsson641c0912020-08-31 11:34:14 +020034set(LINUX_DRIVER_STACK_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../linux_driver_stack" CACHE PATH "Path to Linux driver stack for Arm Ethos-U.")
Jens Elofssona5e90fd2021-06-01 19:06:30 +020035set(TENSORFLOW_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tflite_micro" CACHE PATH "Path to Tensorflow Lite Micro.")
Jonas Ohlsson7f3c1c92021-05-05 10:48:03 +020036set(TFLU_PREBUILT_LIBRARY_PATH "" CACHE PATH "Path to a prebuilt TensorFlow Lite for Microcontrollers library.")
Kristofer Jonsson18239302020-04-17 08:45:38 +020037
Per Åstrand94ca3552020-06-30 10:33:58 +020038# Select accelerator for tensorflow
Kristofer Jonsson641c0912020-08-31 11:34:14 +020039set(CORE_SOFTWARE_ACCELERATOR "NPU" CACHE STRING "Set NPU backend for Tensorflow Lite for microcontrollers")
Per Åstrand94ca3552020-06-30 10:33:58 +020040set_property(CACHE CORE_SOFTWARE_ACCELERATOR PROPERTY STRINGS CPU CMSIS-NN NPU)
Kristofer Jonsson18239302020-04-17 08:45:38 +020041
42# Define build options
43set(CORE_SOFTWARE_RTOS "None" CACHE STRING "Select RTOS to include. (None, MbedOS, FreeRTOS, Zephyr)")
Bhavik Patel68c1f1b2020-07-29 12:28:18 +020044string(TOLOWER ${CORE_SOFTWARE_RTOS} CORE_SOFTWARE_RTOS_LOWER)
Kristofer Jonsson18239302020-04-17 08:45:38 +020045
Anton Moberg07cf70b2021-07-07 11:08:17 +020046set(LOG_NAMES err warning info debug)
47set(ETHOSU_LOG_SEVERITY "warning" CACHE STRING "Driver log severity level ${LOG_NAMES} (Defaults to warning)")
48set_property(CACHE ETHOSU_LOG_SEVERITY PROPERTY STRINGS ${LOG_NAMES})
49
50# Check that ETHOSU_LOG_SEVERITY has one of the supported levels
51list(FIND LOG_NAMES ${ETHOSU_LOG_SEVERITY} LOG_SEVERITY)
52if (${LOG_SEVERITY} EQUAL -1)
53 message(FATAL_ERROR "Unsupported log level ${ETHOSU_LOG_SEVERITY}")
54endif()
55
Kristofer Jonsson18239302020-04-17 08:45:38 +020056#
57# Build
58#
Per Åstrand94ca3552020-06-30 10:33:58 +020059add_library(ethosu_core INTERFACE)
Kristofer Jonsson18239302020-04-17 08:45:38 +020060
61# Build CMSIS
62include(cmsis.cmake)
63
64# Build core driver
Per Åstrand94ca3552020-06-30 10:33:58 +020065if (CORE_SOFTWARE_ACCELERATOR STREQUAL "NPU")
66 set(ETHOSU_PMU_INTERACTIVE OFF)
67 add_subdirectory(${CORE_DRIVER_PATH} core_driver)
Per Åstrand94ca3552020-06-30 10:33:58 +020068endif()
Kristofer Jonsson18239302020-04-17 08:45:38 +020069
Jens Elofssona5e90fd2021-06-01 19:06:30 +020070# Build Tensorflow Lite Micro library
71include(tflite_micro.cmake)
Kristofer Jonsson18239302020-04-17 08:45:38 +020072
Bhavik Patel68c1f1b2020-07-29 12:28:18 +020073# Build RTOS
74add_subdirectory(rtos)
Bhavik Patel68c1f1b2020-07-29 12:28:18 +020075
Jens Elofssona9817a12021-05-18 11:30:35 +020076# Build EventRecorder
77include(event_recorder.cmake)
78
Jens Elofsson955288a2021-04-22 20:57:15 +020079# Build libs
80add_subdirectory(lib)
81
Kristofer Jonsson641c0912020-08-31 11:34:14 +020082# Build applications
83add_subdirectory(applications)
84
Anton Moberg07cf70b2021-07-07 11:08:17 +020085message(STATUS "*******************************************************")
86message(STATUS "PROJECT_NAME : ${PROJECT_NAME}")
87message(STATUS "CORE_SOFTWARE_RTOS : ${CORE_SOFTWARE_RTOS}")
88message(STATUS "CORE_SOFTWARE_ACCELERATOR : ${CORE_SOFTWARE_ACCELERATOR}")
89message(STATUS "ETHOSU_LOG_SEVERITY : ${ETHOSU_LOG_SEVERITY}")
Yulia Garbovich05244b72021-11-23 20:10:26 +020090message(STATUS "*******************************************************")