summaryrefslogtreecommitdiff
path: root/source/hal/platform/mps3/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'source/hal/platform/mps3/CMakeLists.txt')
-rw-r--r--source/hal/platform/mps3/CMakeLists.txt84
1 files changed, 82 insertions, 2 deletions
diff --git a/source/hal/platform/mps3/CMakeLists.txt b/source/hal/platform/mps3/CMakeLists.txt
index cd95d6c..75e70a2 100644
--- a/source/hal/platform/mps3/CMakeLists.txt
+++ b/source/hal/platform/mps3/CMakeLists.txt
@@ -82,7 +82,7 @@ target_sources(${PLATFORM_DRIVERS_TARGET}
source/timer_mps3.c
source/platform_drivers.c)
-## Directory for additional compnents required by MPS3:
+## Directory for additional components required by MPS3:
if (NOT DEFINED COMPONENTS_DIR)
set(COMPONENTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../components)
endif()
@@ -115,7 +115,87 @@ target_compile_definitions(${PLATFORM_DRIVERS_TARGET}
target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC
log cmsis_device)
-# Display status:
+# If Ethos-U is enabled, we need the driver library too
+if (ETHOS_U_NPU_ENABLED)
+
+
+ ## Platform component: Ethos-U initialization
+ target_sources(${PLATFORM_DRIVERS_TARGET}
+ PRIVATE
+ ${COMPONENTS_DIR}/ethosu_npu_init/ethosu_npu_init.c)
+ target_include_directories(${PLATFORM_DRIVERS_TARGET}
+ PUBLIC
+ ${COMPONENTS_DIR}/ethosu_npu_init/include)
+
+ ## Platform component: Ethos-U timing apadpter initialization
+ target_sources(${PLATFORM_DRIVERS_TARGET}
+ PRIVATE
+ ${COMPONENTS_DIR}/ethosu_ta_init/ethosu_ta_init.c)
+ target_include_directories(${PLATFORM_DRIVERS_TARGET}
+ PUBLIC
+ ${COMPONENTS_DIR}/ethosu_ta_init/include)
+
+ if (NOT DEFINED ETHOS_U_NPU_DRIVER_SRC_PATH)
+ message(FATAL_ERROR "ETHOS_U_NPU_DRIVER_SRC_PATH should"
+ " be defined when ETHOS_U_NPU_ENABLED=${ETHOS_U_NPU_ENABLED}")
+ endif()
+
+ # Timing adapter
+ if (NOT DEFINED ETHOS_U_NPU_TIMING_ADAPTER_SRC_PATH)
+ message(FATAL_ERROR "ETHOS_U_NPU_TIMING_ADAPTER_SRC_PATH should"
+ " be defined when ETHOS_U_NPU_ENABLED=${ETHOS_U_NPU_ENABLED}")
+ endif()
+
+ target_compile_definitions(${PLATFORM_DRIVERS_TARGET}
+ PUBLIC
+ ARM_NPU)
+
+ # 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)
+ add_subdirectory(${ETHOS_U_NPU_TIMING_ADAPTER_SRC_PATH} ${CMAKE_BINARY_DIR}/timing-adapter)
+
+ target_link_libraries(${PLATFORM_DRIVERS_TARGET}
+ PUBLIC
+ ethosu_core_driver
+ timing_adapter)
+
+ if (NOT DEFINED ETHOS_U_NPU_ID)
+ set(ETHOS_U_NPU_ID U55)
+ endif()
+
+ if (NOT DEFINED ETHOS_U_NPU_MEMORY_MODE)
+ set(ETHOS_U_NPU_MEMORY_MODE Shared_Sram)
+ endif()
+
+ if (ETHOS_U_NPU_MEMORY_MODE STREQUAL Sram_Only)
+ if (ETHOS_U_NPU_ID STREQUAL U55)
+ set(ETHOS_U_NPU_MEMORY_MODE_FLAG "-DETHOS_U_NPU_MEMORY_MODE=ETHOS_U_NPU_MEM_MODE_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)
+ list(APPEND ETHOS_U_NPU_MEMORY_MODE_FLAG "-DETHOS_U_NPU_MEMORY_MODE=ETHOS_U_NPU_MEMORY_MODE_DEDICATED_SRAM" "-DETHOS_U_NPU_CACHE_SIZE=${ETHOS_U_NPU_CACHE_SIZE}")
+ 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 ()
+
+ target_compile_definitions(${PLATFORM_DRIVERS_TARGET}
+ PUBLIC
+ ${ETHOS_U_NPU_MEMORY_MODE_FLAG})
+endif()
+
+# 5. Display status:
message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR})
message(STATUS "*******************************************************")
message(STATUS "Library : " ${PLATFORM_DRIVERS_TARGET})