Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 1 | # |
| 2 | # Copyright (c) 2019-2020 Arm Limited. All rights reserved. |
| 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 | |
| 19 | cmake_minimum_required(VERSION 3.15.6) |
| 20 | |
| 21 | project(core_software VERSION 0.0.1) |
| 22 | |
| 23 | # |
| 24 | # Define build options |
| 25 | # |
| 26 | |
| 27 | # Setup paths |
| 28 | set(CMSIS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmsis" CACHE PATH "Path to CMSIS.") |
| 29 | 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] | 30 | set(LINUX_DRIVER_STACK_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../linux_driver_stack" CACHE PATH "Path to Linux driver stack for Arm Ethos-U.") |
Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 31 | set(TENSORFLOW_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tensorflow" CACHE PATH "Path to Tensorflow.") |
| 32 | |
Per Åstrand | 94ca355 | 2020-06-30 10:33:58 +0200 | [diff] [blame] | 33 | # Select accelerator for tensorflow |
Kristofer Jonsson | 641c091 | 2020-08-31 11:34:14 +0200 | [diff] [blame] | 34 | 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] | 35 | set_property(CACHE CORE_SOFTWARE_ACCELERATOR PROPERTY STRINGS CPU CMSIS-NN NPU) |
Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 36 | |
| 37 | # Define build options |
| 38 | 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] | 39 | string(TOLOWER ${CORE_SOFTWARE_RTOS} CORE_SOFTWARE_RTOS_LOWER) |
Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 40 | |
Per Åstrand | 19a22ae | 2020-11-27 19:47:58 +0100 | [diff] [blame] | 41 | # Set trustzone options |
| 42 | set(TRUSTZONE_BUILD OFF CACHE BOOL "Enable TrustZone build") |
| 43 | if (TRUSTZONE_BUILD) |
| 44 | set(TRUSTZONE_SIDE "secure" CACHE STRING "Select secure or nonsecure") |
| 45 | set_property(CACHE TRUSTZONE_SIDE PROPERTY STRINGS secure nonsecure) |
| 46 | set(TRUSTZONE_PARTITION_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" CACHE |
| 47 | FILEPATH "Path to CMSIS partion header for device") |
| 48 | endif() |
| 49 | |
Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 50 | # |
| 51 | # Build |
| 52 | # |
Per Åstrand | 94ca355 | 2020-06-30 10:33:58 +0200 | [diff] [blame] | 53 | add_library(ethosu_core INTERFACE) |
Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 54 | |
| 55 | # Build CMSIS |
| 56 | include(cmsis.cmake) |
Per Åstrand | 19a22ae | 2020-11-27 19:47:58 +0100 | [diff] [blame] | 57 | target_link_libraries(ethosu_core INTERFACE cmsis_core cmsis_device) |
Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 58 | |
| 59 | # Build core driver |
Per Åstrand | 94ca355 | 2020-06-30 10:33:58 +0200 | [diff] [blame] | 60 | if (CORE_SOFTWARE_ACCELERATOR STREQUAL "NPU") |
| 61 | set(ETHOSU_PMU_INTERACTIVE OFF) |
| 62 | add_subdirectory(${CORE_DRIVER_PATH} core_driver) |
| 63 | target_link_libraries(ethosu_core INTERFACE ethosu_core_driver) |
| 64 | endif() |
Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 65 | |
| 66 | # Build Tensorflow library |
| 67 | include(tensorflow.cmake) |
| 68 | |
Bhavik Patel | 68c1f1b | 2020-07-29 12:28:18 +0200 | [diff] [blame] | 69 | # Build RTOS |
| 70 | add_subdirectory(rtos) |
Bhavik Patel | 68c1f1b | 2020-07-29 12:28:18 +0200 | [diff] [blame] | 71 | |
Kristofer Jonsson | 641c091 | 2020-08-31 11:34:14 +0200 | [diff] [blame] | 72 | # Build applications |
| 73 | add_subdirectory(applications) |
| 74 | |
Jonny Svärd | 44398c8 | 2020-10-06 14:18:28 +0200 | [diff] [blame] | 75 | # Build drivers |
| 76 | add_subdirectory(drivers) |
| 77 | |
Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 78 | # Merge libraries into static library |
Per Åstrand | d9afc08 | 2020-10-06 13:25:08 +0200 | [diff] [blame] | 79 | target_link_libraries(ethosu_core INTERFACE tflu cmsis_core ethosu_applications ethosu_drivers) |