Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 1 | # |
Jonny Svärd | a830f17 | 2021-06-07 16:57:00 +0200 | [diff] [blame] | 2 | # Copyright (c) 2019-2021 Arm Limited. All rights reserved. |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +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 | |
| 19 | cmake_minimum_required(VERSION 3.15.6) |
| 20 | |
| 21 | project(ethosu_core_driver VERSION 0.0.1) |
| 22 | |
| 23 | # |
| 24 | # Build options |
| 25 | # |
| 26 | |
Kristofer Jonsson | 537c71c | 2020-05-05 14:17:22 +0200 | [diff] [blame] | 27 | option(DRIVER_PMU_AUTOINIT "Enable PMU boot auto-initialization" OFF) |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 28 | |
Kristofer Jonsson | 537c71c | 2020-05-05 14:17:22 +0200 | [diff] [blame] | 29 | set(CMSIS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmsis" CACHE PATH "Path to CMSIS.") |
Kristofer Jonsson | c05c988 | 2020-08-05 11:46:52 +0200 | [diff] [blame] | 30 | |
Jonny Svärd | a830f17 | 2021-06-07 16:57:00 +0200 | [diff] [blame] | 31 | set(LOG_NAMES err warning info debug) |
Anton Moberg | 6eab40b | 2021-07-07 11:43:51 +0200 | [diff] [blame] | 32 | set(ETHOSU_LOG_SEVERITY "warning" CACHE STRING "Driver log severity level ${LOG_NAMES} (Defaults to 'warning')") |
Jonny Svärd | 136810f | 2021-10-13 16:04:26 +0200 | [diff] [blame] | 33 | set(ETHOSU_TARGET_NPU_CONFIG "ethos-u55-128" CACHE STRING "Default NPU configuration") |
Kristofer Jonsson | c05c988 | 2020-08-05 11:46:52 +0200 | [diff] [blame] | 34 | set_property(CACHE ETHOSU_LOG_SEVERITY PROPERTY STRINGS ${LOG_NAMES}) |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 35 | |
| 36 | # |
| 37 | # Global settings |
| 38 | # |
| 39 | |
Kristofer Jonsson | c05c988 | 2020-08-05 11:46:52 +0200 | [diff] [blame] | 40 | # Check that ETHOSU_LOG_SEVERITY has one of the supported levels |
| 41 | list(FIND LOG_NAMES ${ETHOSU_LOG_SEVERITY} LOG_SEVERITY) |
| 42 | if (${LOG_SEVERITY} EQUAL -1) |
| 43 | message(FATAL_ERROR "Unsupported log level ${ETHOSU_LOG_SEVERITY}") |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 44 | endif() |
| 45 | |
| 46 | # Make include directories available for current- and sub projects |
| 47 | include_directories(include src) |
| 48 | include_directories(${CMSIS_PATH}/CMSIS/Core/Include) |
| 49 | |
| 50 | # |
| 51 | # Build libraries |
| 52 | # |
| 53 | |
| 54 | # Build driver library |
| 55 | add_library(ethosu_core_driver STATIC) |
Kristofer Jonsson | 537c71c | 2020-05-05 14:17:22 +0200 | [diff] [blame] | 56 | target_include_directories(ethosu_core_driver PUBLIC include) |
Jonny Svärd | 136810f | 2021-10-13 16:04:26 +0200 | [diff] [blame] | 57 | target_sources(ethosu_core_driver PRIVATE src/ethosu_driver.c src/ethosu_pmu.c) |
| 58 | |
| 59 | string(TOLOWER ${ETHOSU_TARGET_NPU_CONFIG} ETHOSU_TARGET_NPU_CONFIG) |
| 60 | if(ETHOSU_TARGET_NPU_CONFIG MATCHES "^ethos-(u[0-9]+|uz)-([0-9]+$)") |
| 61 | set(ETHOSU_ARCH ${CMAKE_MATCH_1}) |
| 62 | set(ETHOSU_MACS ${CMAKE_MATCH_2}) |
| 63 | else() |
| 64 | message(FATAL_ERROR "Invalid Ethos-U target configuration '${ETHOSU_TARGET_NPU_CONFIG}") |
| 65 | endif() |
| 66 | |
| 67 | target_compile_definitions(ethosu_core_driver PRIVATE |
| 68 | ETHOSU_ARCH=${ETHOSU_ARCH} |
| 69 | ETHOS$<UPPER_CASE:${ETHOSU_ARCH}>) |
| 70 | |
| 71 | if (ETHOSU_ARCH STREQUAL "u55" OR ETHOSU_ARCH STREQUAL "u65") |
| 72 | target_sources(ethosu_core_driver PRIVATE src/ethosu_device_u55_u65.c) |
| 73 | else() |
| 74 | message(FATAL_ERROR "Invalid NPU configuration") |
| 75 | endif() |
| 76 | |
| 77 | |
| 78 | # Set the log level for the target |
Kristofer Jonsson | c05c988 | 2020-08-05 11:46:52 +0200 | [diff] [blame] | 79 | target_compile_definitions(ethosu_core_driver PRIVATE ETHOSU_LOG_SEVERITY=${LOG_SEVERITY}) |
Bhavik Patel | f505781 | 2020-07-16 22:36:02 +0200 | [diff] [blame] | 80 | |
Bhavik Patel | 747c873 | 2020-07-27 17:22:44 +0200 | [diff] [blame] | 81 | # Install library and include files |
| 82 | install(TARGETS ethosu_core_driver LIBRARY DESTINATION "lib") |
| 83 | install(FILES include/ethosu_device.h include/ethosu_driver.h include/pmu_ethosu.h |
| 84 | DESTINATION "include") |
| 85 | |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 86 | # |
| 87 | # Print build status |
| 88 | # |
| 89 | |
| 90 | message(STATUS "*******************************************************") |
| 91 | message(STATUS "PROJECT_NAME : ${PROJECT_NAME}") |
Jonny Svärd | 136810f | 2021-10-13 16:04:26 +0200 | [diff] [blame] | 92 | message(STATUS "ETHOSU_TARGET_NPU_CONFIG : ${ETHOSU_TARGET_NPU_CONFIG}") |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 93 | message(STATUS "CMAKE_SYSTEM_PROCESSOR : ${CMAKE_SYSTEM_PROCESSOR}") |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 94 | message(STATUS "CMSIS_PATH : ${CMSIS_PATH}") |
Kristofer Jonsson | c05c988 | 2020-08-05 11:46:52 +0200 | [diff] [blame] | 95 | message(STATUS "ETHOSU_LOG_SEVERITY : ${ETHOSU_LOG_SEVERITY}") |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 96 | message(STATUS "*******************************************************") |