Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 1 | # |
Kristofer Jonsson | 1efcc3f | 2021-02-16 17:40:25 +0100 | [diff] [blame] | 2 | # Copyright (c) 2019-2021 Arm Limited. All rights reserved. |
Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 3 | # |
| 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 Ohlsson | 7f3c1c9 | 2021-05-05 10:48:03 +0200 | [diff] [blame] | 19 | # 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 Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 21 | cmake_minimum_required(VERSION 3.15.6) |
| 22 | |
| 23 | project(core_software VERSION 0.0.1) |
| 24 | |
| 25 | # |
| 26 | # Define build options |
| 27 | # |
| 28 | |
| 29 | # Setup paths |
| 30 | set(CMSIS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmsis" CACHE PATH "Path to CMSIS.") |
Jens Elofsson | a9817a1 | 2021-05-18 11:30:35 +0200 | [diff] [blame] | 31 | set(CMSIS_VIEW_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmsis-view" CACHE PATH "Path to cmsis-view.") |
Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 32 | set(CORE_DRIVER_PATH "${CMAKE_CURRENT_SOURCE_DIR}/core_driver" CACHE PATH "Path to core driver.") |
Kristofer Jonsson | 641c091 | 2020-08-31 11:34:14 +0200 | [diff] [blame] | 33 | set(LINUX_DRIVER_STACK_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../linux_driver_stack" CACHE PATH "Path to Linux driver stack for Arm Ethos-U.") |
Jens Elofsson | a5e90fd | 2021-06-01 19:06:30 +0200 | [diff] [blame] | 34 | set(TENSORFLOW_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tflite_micro" CACHE PATH "Path to Tensorflow Lite Micro.") |
Jonas Ohlsson | 7f3c1c9 | 2021-05-05 10:48:03 +0200 | [diff] [blame] | 35 | set(TFLU_PREBUILT_LIBRARY_PATH "" CACHE PATH "Path to a prebuilt TensorFlow Lite for Microcontrollers library.") |
Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 36 | |
Per Åstrand | 94ca355 | 2020-06-30 10:33:58 +0200 | [diff] [blame] | 37 | # Select accelerator for tensorflow |
Kristofer Jonsson | 641c091 | 2020-08-31 11:34:14 +0200 | [diff] [blame] | 38 | set(CORE_SOFTWARE_ACCELERATOR "NPU" CACHE STRING "Set NPU backend for Tensorflow Lite for microcontrollers") |
Per Åstrand | 94ca355 | 2020-06-30 10:33:58 +0200 | [diff] [blame] | 39 | set_property(CACHE CORE_SOFTWARE_ACCELERATOR PROPERTY STRINGS CPU CMSIS-NN NPU) |
Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 40 | |
| 41 | # Define build options |
| 42 | set(CORE_SOFTWARE_RTOS "None" CACHE STRING "Select RTOS to include. (None, MbedOS, FreeRTOS, Zephyr)") |
Bhavik Patel | 68c1f1b | 2020-07-29 12:28:18 +0200 | [diff] [blame] | 43 | string(TOLOWER ${CORE_SOFTWARE_RTOS} CORE_SOFTWARE_RTOS_LOWER) |
Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 44 | |
Anton Moberg | 07cf70b | 2021-07-07 11:08:17 +0200 | [diff] [blame] | 45 | set(LOG_NAMES err warning info debug) |
| 46 | set(ETHOSU_LOG_SEVERITY "warning" CACHE STRING "Driver log severity level ${LOG_NAMES} (Defaults to warning)") |
| 47 | set_property(CACHE ETHOSU_LOG_SEVERITY PROPERTY STRINGS ${LOG_NAMES}) |
| 48 | |
| 49 | # Check that ETHOSU_LOG_SEVERITY has one of the supported levels |
| 50 | list(FIND LOG_NAMES ${ETHOSU_LOG_SEVERITY} LOG_SEVERITY) |
| 51 | if (${LOG_SEVERITY} EQUAL -1) |
| 52 | message(FATAL_ERROR "Unsupported log level ${ETHOSU_LOG_SEVERITY}") |
| 53 | endif() |
| 54 | |
Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 55 | # |
| 56 | # Build |
| 57 | # |
Per Åstrand | 94ca355 | 2020-06-30 10:33:58 +0200 | [diff] [blame] | 58 | add_library(ethosu_core INTERFACE) |
Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 59 | |
| 60 | # Build CMSIS |
| 61 | include(cmsis.cmake) |
Per Åstrand | 19a22ae | 2020-11-27 19:47:58 +0100 | [diff] [blame] | 62 | target_link_libraries(ethosu_core INTERFACE cmsis_core cmsis_device) |
Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 63 | |
| 64 | # Build core driver |
Per Åstrand | 94ca355 | 2020-06-30 10:33:58 +0200 | [diff] [blame] | 65 | if (CORE_SOFTWARE_ACCELERATOR STREQUAL "NPU") |
| 66 | set(ETHOSU_PMU_INTERACTIVE OFF) |
| 67 | add_subdirectory(${CORE_DRIVER_PATH} core_driver) |
| 68 | target_link_libraries(ethosu_core INTERFACE ethosu_core_driver) |
| 69 | endif() |
Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 70 | |
Jens Elofsson | a5e90fd | 2021-06-01 19:06:30 +0200 | [diff] [blame] | 71 | # Build Tensorflow Lite Micro library |
| 72 | include(tflite_micro.cmake) |
Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 73 | |
Bhavik Patel | 68c1f1b | 2020-07-29 12:28:18 +0200 | [diff] [blame] | 74 | # Build RTOS |
| 75 | add_subdirectory(rtos) |
Bhavik Patel | 68c1f1b | 2020-07-29 12:28:18 +0200 | [diff] [blame] | 76 | |
Jens Elofsson | a9817a1 | 2021-05-18 11:30:35 +0200 | [diff] [blame] | 77 | # Build EventRecorder |
| 78 | include(event_recorder.cmake) |
| 79 | |
Jens Elofsson | 955288a | 2021-04-22 20:57:15 +0200 | [diff] [blame] | 80 | # Build libs |
| 81 | add_subdirectory(lib) |
| 82 | |
Kristofer Jonsson | 641c091 | 2020-08-31 11:34:14 +0200 | [diff] [blame] | 83 | # Build applications |
| 84 | add_subdirectory(applications) |
| 85 | |
Jonny Svärd | 44398c8 | 2020-10-06 14:18:28 +0200 | [diff] [blame] | 86 | |
Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 87 | # Merge libraries into static library |
Yulia Garbovich | 05244b7 | 2021-11-23 20:10:26 +0200 | [diff] [blame] | 88 | target_link_libraries(ethosu_core INTERFACE tflu ethosu_applications) |
Anton Moberg | 07cf70b | 2021-07-07 11:08:17 +0200 | [diff] [blame] | 89 | |
| 90 | message(STATUS "*******************************************************") |
| 91 | message(STATUS "PROJECT_NAME : ${PROJECT_NAME}") |
| 92 | message(STATUS "CORE_SOFTWARE_RTOS : ${CORE_SOFTWARE_RTOS}") |
| 93 | message(STATUS "CORE_SOFTWARE_ACCELERATOR : ${CORE_SOFTWARE_ACCELERATOR}") |
| 94 | message(STATUS "ETHOSU_LOG_SEVERITY : ${ETHOSU_LOG_SEVERITY}") |
Yulia Garbovich | 05244b7 | 2021-11-23 20:10:26 +0200 | [diff] [blame] | 95 | message(STATUS "*******************************************************") |