From f4f240b13feff77cb85d184c98694388540400f5 Mon Sep 17 00:00:00 2001 From: Richard Burton Date: Fri, 4 Mar 2022 14:16:49 +0000 Subject: MLECO-2978: Update to 22.02 dependencies * Add missing CMake setting used for building driver Signed-off-by: Richard Burton Change-Id: I2aae67d6780f88e661f9a54177943553b0f0dd4c --- .../hal/components/ethosu_npu_init/CMakeLists.txt | 54 ++++++++++++---------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/source/hal/components/ethosu_npu_init/CMakeLists.txt b/source/hal/components/ethosu_npu_init/CMakeLists.txt index 57eef61..59f32bd 100644 --- a/source/hal/components/ethosu_npu_init/CMakeLists.txt +++ b/source/hal/components/ethosu_npu_init/CMakeLists.txt @@ -32,27 +32,15 @@ endif() # For the driver, we need to provide the CMSIS_PATH variable set(CMSIS_PATH ${CMSIS_SRC_PATH} CACHE PATH "Path to CMSIS directory") -add_subdirectory(${ETHOS_U_NPU_DRIVER_SRC_PATH} ${CMAKE_BINARY_DIR}/ethos-u-driver) - -# Create static library -add_library(${ETHOS_U_NPU_INIT_COMPONENT} STATIC) - -## Include directories - public -target_include_directories(${ETHOS_U_NPU_INIT_COMPONENT} - PUBLIC - include - ${SOURCE_GEN_DIR}) - -## Component sources -target_sources(${ETHOS_U_NPU_INIT_COMPONENT} - PRIVATE - ethosu_npu_init.c) -## Add dependencies: -target_link_libraries(${ETHOS_U_NPU_INIT_COMPONENT} PUBLIC - cmsis_device - ethosu_core_driver - log) +# Driver needs to know what MAC configuration to build for. +if(ETHOS_U_NPU_CONFIG_ID MATCHES "^[A-Z]([0-9]+$)") + set(ETHOSU_MACS ${CMAKE_MATCH_1}) +else() + message(FATAL_ERROR "Couldn't work out Ethos-U number of MACS from ${ETHOS_U_NPU_CONFIG_ID}") +endif() +set(ETHOSU_TARGET_NPU_CONFIG + "ethos-${ETHOS_U_NPU_ID}-${ETHOSU_MACS}" CACHE STRING "Target Ethos-U configuration for driver.") ## Memory mode target definition if (NOT DEFINED ETHOS_U_NPU_ID) @@ -69,11 +57,9 @@ if (ETHOS_U_NPU_MEMORY_MODE STREQUAL Sram_Only) else () message(FATAL_ERROR "Non compatible Ethos-U NPU memory mode and processor ${ETHOS_U_NPU_MEMORY_MODE} - ${ETHOS_U_NPU_ID}. `sram_only` can be used only for Ethos-U55.") endif () - elseif (ETHOS_U_NPU_MEMORY_MODE STREQUAL Shared_Sram) # Shared Sram can be used for Ethos-U55 and Ethos-U65 set(ETHOS_U_NPU_MEMORY_MODE_FLAG "-DETHOS_U_NPU_MEMORY_MODE=ETHOS_U_NPU_MEMORY_MODE_SHARED_SRAM") - elseif (ETHOS_U_NPU_MEMORY_MODE STREQUAL Dedicated_Sram) # Dedicated Sram is used only for Ethos-U65 if (ETHOS_U_NPU_ID STREQUAL U65) @@ -81,12 +67,32 @@ elseif (ETHOS_U_NPU_MEMORY_MODE STREQUAL Dedicated_Sram) else () message(FATAL_ERROR "Non compatible Ethos-U NPU memory mode and processor ${ETHOS_U_NPU_MEMORY_MODE} - ${ETHOS_U_NPU_ID}. `dedicated_sram` can be used only for Ethos-U65.") endif () - else () message(FATAL_ERROR "Non compatible Ethos-U NPU memory mode ${ETHOS_U_NPU_MEMORY_MODE}") - endif () +add_subdirectory(${ETHOS_U_NPU_DRIVER_SRC_PATH} ${CMAKE_BINARY_DIR}/ethos-u-driver) + +# Create static library +add_library(${ETHOS_U_NPU_INIT_COMPONENT} STATIC) + +## Include directories - public +target_include_directories(${ETHOS_U_NPU_INIT_COMPONENT} + PUBLIC + include + ${SOURCE_GEN_DIR}) + +## Component sources +target_sources(${ETHOS_U_NPU_INIT_COMPONENT} + PRIVATE + ethosu_npu_init.c) + +## Add dependencies: +target_link_libraries(${ETHOS_U_NPU_INIT_COMPONENT} PUBLIC + cmsis_device + ethosu_core_driver + log) + target_compile_definitions(${ETHOS_U_NPU_INIT_COMPONENT} PUBLIC ${ETHOS_U_NPU_MEMORY_MODE_FLAG}) -- cgit v1.2.1