blob: 75ffc9794b307f80d5888fba34ba76a655ddc85f [file] [log] [blame]
Kristofer Jonsson18239302020-04-17 08:45:38 +02001#
Rajasekaran Kalidossf922fd12024-04-24 12:55:29 +02002# SPDX-FileCopyrightText: Copyright 2019-2024 Arm Limited and/or its affiliates <open-source-office@arm.com>
Kristofer Jonsson18239302020-04-17 08:45:38 +02003# 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
Jonas Ohlsson7f3c1c92021-05-05 10:48:03 +020018# Note: On Windows systems CMake 3.20.0 might cause issues with errouneous dependency make files.
19# Issues solved with CMake 3.20.1.
Kristofer Jonsson18239302020-04-17 08:45:38 +020020cmake_minimum_required(VERSION 3.15.6)
21
22project(core_software VERSION 0.0.1)
23
24#
25# Define build options
26#
27
Rajasekaran Kalidossf922fd12024-04-24 12:55:29 +020028SET(CMSIS_VER "5" CACHE STRING "CMSIS Version")
29
Kristofer Jonsson18239302020-04-17 08:45:38 +020030# Setup paths
Rajasekaran Kalidossf922fd12024-04-24 12:55:29 +020031if (${CMSIS_VER} EQUAL 5)
32 set(CMSIS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmsis" CACHE PATH "Path to CMSIS.")
33elseif(${CMSIS_VER} EQUAL 6)
34 set(CMSIS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmsis_6" CACHE PATH "Path to CMSIS.")
35else()
36 message(FATAL_ERROR "CMSIS_VER '${CMSIS_VER}' not supported. Should be 5 or 6.")
37endif()
Kristofer Jonssond0a08822022-10-10 12:36:03 +020038set(CMSIS_NN_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmsis-nn" CACHE PATH "Path to CMSIS-NN.")
Jens Elofssona9817a12021-05-18 11:30:35 +020039set(CMSIS_VIEW_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmsis-view" CACHE PATH "Path to cmsis-view.")
Kristofer Jonsson18239302020-04-17 08:45:38 +020040set(CORE_DRIVER_PATH "${CMAKE_CURRENT_SOURCE_DIR}/core_driver" CACHE PATH "Path to core driver.")
Kristofer Jonsson641c0912020-08-31 11:34:14 +020041set(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 +020042set(TENSORFLOW_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tflite_micro" CACHE PATH "Path to Tensorflow Lite Micro.")
Jonas Ohlsson7f3c1c92021-05-05 10:48:03 +020043set(TFLU_PREBUILT_LIBRARY_PATH "" CACHE PATH "Path to a prebuilt TensorFlow Lite for Microcontrollers library.")
Kristofer Jonsson18239302020-04-17 08:45:38 +020044
Per Åstrand94ca3552020-06-30 10:33:58 +020045# Select accelerator for tensorflow
Kristofer Jonsson641c0912020-08-31 11:34:14 +020046set(CORE_SOFTWARE_ACCELERATOR "NPU" CACHE STRING "Set NPU backend for Tensorflow Lite for microcontrollers")
Per Åstrand94ca3552020-06-30 10:33:58 +020047set_property(CACHE CORE_SOFTWARE_ACCELERATOR PROPERTY STRINGS CPU CMSIS-NN NPU)
Kristofer Jonsson18239302020-04-17 08:45:38 +020048
49# Define build options
50set(CORE_SOFTWARE_RTOS "None" CACHE STRING "Select RTOS to include. (None, MbedOS, FreeRTOS, Zephyr)")
Bhavik Patel68c1f1b2020-07-29 12:28:18 +020051string(TOLOWER ${CORE_SOFTWARE_RTOS} CORE_SOFTWARE_RTOS_LOWER)
Kristofer Jonsson18239302020-04-17 08:45:38 +020052
Anton Moberg07cf70b2021-07-07 11:08:17 +020053set(LOG_NAMES err warning info debug)
54set(ETHOSU_LOG_SEVERITY "warning" CACHE STRING "Driver log severity level ${LOG_NAMES} (Defaults to warning)")
55set_property(CACHE ETHOSU_LOG_SEVERITY PROPERTY STRINGS ${LOG_NAMES})
56
57# Check that ETHOSU_LOG_SEVERITY has one of the supported levels
58list(FIND LOG_NAMES ${ETHOSU_LOG_SEVERITY} LOG_SEVERITY)
59if (${LOG_SEVERITY} EQUAL -1)
60 message(FATAL_ERROR "Unsupported log level ${ETHOSU_LOG_SEVERITY}")
61endif()
62
Kristofer Jonsson18239302020-04-17 08:45:38 +020063#
64# Build
65#
Per Åstrand94ca3552020-06-30 10:33:58 +020066add_library(ethosu_core INTERFACE)
Kristofer Jonsson18239302020-04-17 08:45:38 +020067
68# Build CMSIS
69include(cmsis.cmake)
70
71# Build core driver
Per Åstrand94ca3552020-06-30 10:33:58 +020072if (CORE_SOFTWARE_ACCELERATOR STREQUAL "NPU")
73 set(ETHOSU_PMU_INTERACTIVE OFF)
74 add_subdirectory(${CORE_DRIVER_PATH} core_driver)
Per Åstrand94ca3552020-06-30 10:33:58 +020075endif()
Kristofer Jonsson18239302020-04-17 08:45:38 +020076
Jens Elofssona5e90fd2021-06-01 19:06:30 +020077# Build Tensorflow Lite Micro library
78include(tflite_micro.cmake)
Kristofer Jonsson18239302020-04-17 08:45:38 +020079
Bhavik Patel68c1f1b2020-07-29 12:28:18 +020080# Build RTOS
81add_subdirectory(rtos)
Bhavik Patel68c1f1b2020-07-29 12:28:18 +020082
Jens Elofssona9817a12021-05-18 11:30:35 +020083# Build EventRecorder
84include(event_recorder.cmake)
85
Jens Elofsson955288a2021-04-22 20:57:15 +020086# Build libs
87add_subdirectory(lib)
88
Kristofer Jonsson02eef5b2022-09-06 14:38:10 +020089# OpenAMP
90add_subdirectory(openamp)
91
Kristofer Jonsson641c0912020-08-31 11:34:14 +020092# Build applications
93add_subdirectory(applications)
94
Anton Moberg07cf70b2021-07-07 11:08:17 +020095message(STATUS "*******************************************************")
96message(STATUS "PROJECT_NAME : ${PROJECT_NAME}")
97message(STATUS "CORE_SOFTWARE_RTOS : ${CORE_SOFTWARE_RTOS}")
98message(STATUS "CORE_SOFTWARE_ACCELERATOR : ${CORE_SOFTWARE_ACCELERATOR}")
99message(STATUS "ETHOSU_LOG_SEVERITY : ${ETHOSU_LOG_SEVERITY}")
Yulia Garbovich05244b72021-11-23 20:10:26 +0200100message(STATUS "*******************************************************")