summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKshitij Sisodia <kshitij.sisodia@arm.com>2024-04-12 11:30:02 +0100
committerKshitij Sisodia <kshitij.sisodia@arm.com>2024-05-07 09:41:06 +0100
commit774c7caaaccacfa07b2ba144f1602e640a5edd86 (patch)
treed247ef17b453ad055a7f4bc4de794c132e8cb9a1
parent4cef9acc2624a31111b47c25b8b1a2f37f7e0cb9 (diff)
downloadml-embedded-evaluation-kit-774c7caaaccacfa07b2ba144f1602e640a5edd86.tar.gz
MLECO-4935: Refactoring user options
Refactoring for CMake configuration options to allow target platform to drive their own defaults for certain dependent options. For example, the MPS3 target platform defaults to SSE-300 sub-system while native target doesn't need to worry about sub-system and CMSIS options which it will never use. This allows MPS4 target to default to SSE-315 and set the NPU arch to Arm Ethos-U65 as it should, which otherwise would have had to be explictly specified by the user. A welcome by-product of this is also that the options summary at the end of a successful CMake configuration stage would only include the settings that are actually used by the given target. Change-Id: Ibb7f8233d427cd33f39eeb4c71d88193aa998ebd Signed-off-by: Kshitij Sisodia <kshitij.sisodia@arm.com> Tested-by: mlecosys <mlecosys@arm.com> Reviewed-by: Alex Tawse <alex.tawse@arm.com> Reviewed-by: Conor Kennedy <conor.kennedy@arm.com> Signed-off-by: Kshitij Sisodia <kshitij.sisodia@arm.com>
-rw-r--r--CMakeLists.txt19
-rw-r--r--CMakePresets.json2
-rw-r--r--docs/sections/customizing.md10
-rw-r--r--scripts/cmake/common_user_options.cmake169
-rw-r--r--scripts/cmake/configuration_options/cmsis_opts.cmake41
-rw-r--r--scripts/cmake/configuration_options/common_opts.cmake65
-rw-r--r--scripts/cmake/configuration_options/fvp_test_opts.cmake36
-rw-r--r--scripts/cmake/configuration_options/npu_opts.cmake91
-rw-r--r--scripts/cmake/configuration_options/options-preset.json (renamed from scripts/cmake/options-preset.json)0
-rw-r--r--scripts/cmake/platforms/mps3/build_configuration.cmake28
-rw-r--r--scripts/cmake/platforms/mps4/build_configuration.cmake28
-rw-r--r--scripts/cmake/platforms/simple_platform/build_configuration.cmake14
-rw-r--r--scripts/cmake/source_gen_utils.cmake5
-rw-r--r--scripts/cmake/tensorflow_lite_micro.cmake (renamed from scripts/cmake/tensorflow.cmake)9
-rw-r--r--scripts/cmake/util_functions.cmake7
-rw-r--r--source/hal/source/components/npu_ta/CMakeLists.txt2
-rw-r--r--source/math/CMakeLists.txt9
17 files changed, 324 insertions, 211 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c458eb9..65119fd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,6 @@
#----------------------------------------------------------------------------
-# SPDX-FileCopyrightText: Copyright 2021-2024 Arm Limited and/or its affiliates <open-source-office@arm.com>
+# SPDX-FileCopyrightText: Copyright 2021-2024 Arm Limited and/or its
+# affiliates <open-source-office@arm.com>
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -37,8 +38,7 @@ set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_CXX_EXTENSIONS OFF)
set(SCRIPTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/scripts)
-set(CMAKE_SCRIPTS_DIR ${SCRIPTS_DIR}/cmake)
-set(CMAKE_TOOLCHAIN_DIR ${CMAKE_SCRIPTS_DIR}/toolchains)
+set(CMAKE_TOOLCHAIN_DIR ${SCRIPTS_DIR}/cmake/toolchains)
set(DOWNLOAD_DEP_DIR ${CMAKE_BINARY_DIR}/dependencies)
set(DEPENDENCY_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/dependencies)
set(CORE_PLATFORM_DIR ${DEPENDENCY_ROOT_DIR}/core-platform)
@@ -46,8 +46,12 @@ set(CORE_PLATFORM_DIR ${DEPENDENCY_ROOT_DIR}/core-platform)
set(RESOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources_downloaded
CACHE PATH "Resources directory")
set(HAL_PLATFORM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source/hal/source/platform)
+list(APPEND CMAKE_MODULE_PATH
+ "${SCRIPTS_DIR}/cmake"
+ "${SCRIPTS_DIR}/cmake/configuration_options"
+ "${SCRIPTS_DIR}/cmake/timing_adapter")
-include(${CMAKE_SCRIPTS_DIR}/source_gen_utils.cmake)
+include(source_gen_utils)
enable_testing()
@@ -58,7 +62,8 @@ else()
message(STATUS "Binary directory: ${CMAKE_BINARY_DIR}")
endif()
-include(${CMAKE_SCRIPTS_DIR}/common_user_options.cmake)
+# Include common configuration options
+include(common_opts)
# Check if the resources_downloaded needs update
check_update_public_resources(${RESOURCES_DIR})
@@ -73,8 +78,6 @@ message(STATUS "Using CMAKE_TOOLCHAIN_FILE: ${CMAKE_TOOLCHAIN_FILE}")
assert_defined(LOG_LEVEL)
assert_defined(TENSORFLOW_SRC_PATH)
assert_defined(TARGET_PLATFORM)
-assert_defined(TARGET_SUBSYSTEM)
-assert_defined(ETHOS_U_NPU_ENABLED)
assert_defined(USE_CASE_BUILD)
assert_defined(CPU_PROFILE_ENABLED)
assert_defined(CMAKE_TOOLCHAIN_FILE)
@@ -114,7 +117,7 @@ endif ()
add_subdirectory(${PROFILER_DIR} ${CMAKE_BINARY_DIR}/profiler)
# Include the tensorflow build target
-include(${CMAKE_SCRIPTS_DIR}/tensorflow.cmake)
+include(tensorflow_lite_micro)
# Add the common API library target (tensorflow-lite-micro target is needed)
add_subdirectory(${SRC_PATH}/application/api/common ${CMAKE_BINARY_DIR}/api/common)
diff --git a/CMakePresets.json b/CMakePresets.json
index 0385b04..6c2d053 100644
--- a/CMakePresets.json
+++ b/CMakePresets.json
@@ -6,7 +6,7 @@
"patch": 0
},
"include": [
- "scripts/cmake/options-preset.json",
+ "scripts/cmake/configuration_options/options-preset.json",
"scripts/cmake/platforms/platforms-preset.json",
"scripts/cmake/toolchains/toolchain-preset.json",
"source/use_case/usecase-preset.json"
diff --git a/docs/sections/customizing.md b/docs/sections/customizing.md
index 42be12a..2a946aa 100644
--- a/docs/sections/customizing.md
+++ b/docs/sections/customizing.md
@@ -536,8 +536,8 @@ However, for clarity, here is the full list of available functions:
## Reading user input from console
-The platform package under HAL must provide an implementation for a function `GetLine`. This is then wrapped by HAL to
-expose a function called `hal_get_user_input`.
+The platform package under HAL must provide an implementation for a function `GetLine`. This is then wrapped by HAL to
+expose a function called `hal_get_user_input`.
```C++
char ch_input[128];
@@ -774,9 +774,9 @@ function like this:
```cmake
add_linker_script(
- ${PARSED_TARGET_NAME} # Target
- ${CMAKE_SCRIPTS_DIR}/platforms/mps3 # linker scripts directory path
- ${LINKER_SCRIPT_NAME}) # Name of the file without suffix
+ ${PARSED_TARGET_NAME} # Target
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${TARGET_SUBSYSTEM} # Linker scripts directory path
+ ${LINKER_SCRIPT_NAME}) # Name of the file without suffix
```
Please see existing platforms sources and build scripts for more details.
diff --git a/scripts/cmake/common_user_options.cmake b/scripts/cmake/common_user_options.cmake
deleted file mode 100644
index 97e9b40..0000000
--- a/scripts/cmake/common_user_options.cmake
+++ /dev/null
@@ -1,169 +0,0 @@
-#----------------------------------------------------------------------------
-# SPDX-FileCopyrightText: Copyright 2021-2022 Arm Limited and/or its affiliates <open-source-office@arm.com>
-# SPDX-License-Identifier: Apache-2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#----------------------------------------------------------------------------
-
-#----------------------------------------------------------------------------
-# This file should contain all the common user options for the application
-# For use case specific options, see individual usecase.cmake files under
-# each example use case.
-#----------------------------------------------------------------------------
-
-if (NOT DEFINED USER_OPTIONS_INCLUDED)
- set(USER_OPTIONS_INCLUDED ON)
-else()
- return()
-endif()
-
-message(STATUS "Assessing common user options...")
-
-include(${CMAKE_CURRENT_LIST_DIR}/util_functions.cmake)
-
-USER_OPTION(LOG_LEVEL "Log level for the application"
- LOG_LEVEL_INFO
- STRING)
-
-USER_OPTION(TENSORFLOW_SRC_PATH "Path to the root of the tensor flow directory"
- "${DEPENDENCY_ROOT_DIR}/tensorflow"
- PATH)
-
-USER_OPTION(TARGET_PLATFORM "Target platform to execute evaluation application: mps3, simple_platform, native"
- mps3
- STRING)
-
-USER_OPTION(TARGET_SUBSYSTEM "Specify platform target subsystem: sse-300, sse-310 or none"
- sse-300
- STRING)
-
-if (TARGET_PLATFORM STREQUAL native)
- set(NPU_AVAILABLE OFF)
-else()
- set(NPU_AVAILABLE ON)
-endif()
-
-USER_OPTION(ETHOS_U_NPU_ENABLED "If Arm Ethos-U NPU is enabled in the target system."
- ${NPU_AVAILABLE}
- BOOL)
-
-USER_OPTION(USE_CASE_BUILD "Optional. Defines the use-case to build from the available sources. By default, all use-cases are built."
- all
- STRING)
-
-USER_OPTION(CPU_PROFILE_ENABLED "Output CPU performance profiling information. Should be used only for MPS3 board."
- OFF
- BOOL)
-
-USER_OPTION(TENSORFLOW_LITE_MICRO_BUILD_TYPE "TensorFlow Lite Mirco build type (release/debug etc.)"
- $<IF:$<CONFIG:RELEASE>,release_with_logs,debug>
- STRING)
-
-USER_OPTION(TENSORFLOW_LITE_MICRO_CLEAN_DOWNLOADS "Select if TPIP downloads should be cleaned before each build."
- OFF
- BOOL)
-
-USER_OPTION(TENSORFLOW_LITE_MICRO_CLEAN_BUILD "Select if clean target should be added to a list of targets"
- ON
- BOOL)
-
-USER_OPTION(USE_SINGLE_INPUT "Select if a use case should execute using a default known input file"
- OFF
- BOOL)
-
-if (NOT TARGET_PLATFORM STREQUAL native)
-
- USER_OPTION(CMSIS_SRC_PATH
- "Path to CMSIS-5 sources"
- "${DEPENDENCY_ROOT_DIR}/cmsis"
- PATH)
- USER_OPTION(CMSIS_DSP_SRC_PATH
- "Path to CMSIS-5 DSP sources"
- "${DEPENDENCY_ROOT_DIR}/cmsis-dsp"
- PATH)
- USER_OPTION(CMSIS_NN_SRC_PATH
- "Path to CMSIS-5 NN sources"
- "${DEPENDENCY_ROOT_DIR}/cmsis-nn"
- PATH)
-
- # If we need NPU libraries:
- if (ETHOS_U_NPU_ENABLED)
- USER_OPTION(ETHOS_U_NPU_TIMING_ADAPTER_SRC_PATH
- "Path to Ethos-U NPU timing adapter sources"
- "${DEPENDENCY_ROOT_DIR}/core-platform/drivers/timing_adapter"
- PATH
- )
-
- USER_OPTION(ETHOS_U_NPU_DRIVER_SRC_PATH
- "Path to Ethos-U NPU core driver sources"
- "${DEPENDENCY_ROOT_DIR}/core-driver"
- PATH
- )
-
- USER_OPTION(ETHOS_U_NPU_ID "Arm Ethos-U NPU IP (U55 or U65)"
- "U55"
- STRING)
-
- if ((ETHOS_U_NPU_ID STREQUAL U55) OR (ETHOS_U_NPU_ID STREQUAL U65))
- if (ETHOS_U_NPU_ID STREQUAL U55)
- set(DEFAULT_NPU_MEM_MODE "Shared_Sram")
- set(DEFAULT_NPU_CONFIG_ID "H128")
- elseif(ETHOS_U_NPU_ID STREQUAL U65)
- set(DEFAULT_NPU_MEM_MODE "Dedicated_Sram")
- set(DEFAULT_NPU_CONFIG_ID "Y256")
- set(DEFAULT_NPU_CACHE_SIZE "393216")
-
- USER_OPTION(ETHOS_U_NPU_CACHE_SIZE "Arm Ethos-U65 NPU Cache Size"
- "${DEFAULT_NPU_CACHE_SIZE}"
- STRING)
- endif()
- else ()
- message(FATAL_ERROR "Non compatible Ethos-U NPU processor ${ETHOS_U_NPU_ID}")
- endif ()
-
- USER_OPTION(ETHOS_U_NPU_MEMORY_MODE "Specifies the memory mode used in the Vela command."
- "${DEFAULT_NPU_MEM_MODE}"
- STRING)
-
- USER_OPTION(ETHOS_U_NPU_CONFIG_ID "Specifies the configuration ID for the NPU."
- "${DEFAULT_NPU_CONFIG_ID}"
- STRING)
-
- if (ETHOS_U_NPU_ID STREQUAL U55)
- set(DEFAULT_TA_CONFIG_FILE_PATH "${CMAKE_CURRENT_LIST_DIR}/timing_adapter/ta_config_u55_high_end.cmake")
- else ()
- set(DEFAULT_TA_CONFIG_FILE_PATH "${CMAKE_CURRENT_LIST_DIR}/timing_adapter/ta_config_u65_high_end.cmake")
- endif ()
-
- USER_OPTION(ETHOS_U_NPU_TIMING_ADAPTER_ENABLED "Specifies if the Ethos-U timing adapter is enabled"
- ON
- BOOL)
-
- if (ETHOS_U_NPU_TIMING_ADAPTER_ENABLED)
- USER_OPTION(TA_CONFIG_FILE "Path to the timing adapter configuration file"
- ${DEFAULT_TA_CONFIG_FILE_PATH}
- FILEPATH)
- endif()
-
- USER_OPTION(BUILD_FVP_TESTS "Build tests for CTest driven FVP runs for built applications"
- OFF
- BOOL)
-
- if (BUILD_FVP_TESTS)
- USER_OPTION(FVP_PATH "Path to FVP for verifying execution"
- ""
- FILEPATH)
- endif()
-
- endif()
-endif()
diff --git a/scripts/cmake/configuration_options/cmsis_opts.cmake b/scripts/cmake/configuration_options/cmsis_opts.cmake
new file mode 100644
index 0000000..86eedbc
--- /dev/null
+++ b/scripts/cmake/configuration_options/cmsis_opts.cmake
@@ -0,0 +1,41 @@
+#----------------------------------------------------------------------------
+# SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its
+# affiliates <open-source-office@arm.com>
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# CMSIS configuration options
+#----------------------------------------------------------------------------
+include_guard()
+
+include(util_functions)
+
+message(STATUS "Assessing CMSIS configuration options...")
+
+USER_OPTION(CMSIS_SRC_PATH
+ "Path to CMSIS-5 sources"
+ "${DEPENDENCY_ROOT_DIR}/cmsis"
+ PATH)
+
+USER_OPTION(CMSIS_DSP_SRC_PATH
+ "Path to CMSIS-5 DSP sources"
+ "${DEPENDENCY_ROOT_DIR}/cmsis-dsp"
+ PATH)
+
+USER_OPTION(CMSIS_NN_SRC_PATH
+ "Path to CMSIS-5 NN sources"
+ "${DEPENDENCY_ROOT_DIR}/cmsis-nn"
+ PATH)
diff --git a/scripts/cmake/configuration_options/common_opts.cmake b/scripts/cmake/configuration_options/common_opts.cmake
new file mode 100644
index 0000000..52c254e
--- /dev/null
+++ b/scripts/cmake/configuration_options/common_opts.cmake
@@ -0,0 +1,65 @@
+#----------------------------------------------------------------------------
+# SPDX-FileCopyrightText: Copyright 2021-2022, 2024 Arm Limited and/or its
+# affiliates <open-source-office@arm.com>
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# This file should contain all the common user options for the application
+# For use case specific options, see individual usecase.cmake files under
+# each example use case.
+#----------------------------------------------------------------------------
+include_guard()
+
+message(STATUS "Assessing common user options...")
+
+include(util_functions)
+
+USER_OPTION(LOG_LEVEL "Log level for the application"
+ LOG_LEVEL_INFO
+ STRING)
+
+## TensorFlow options
+USER_OPTION(TENSORFLOW_SRC_PATH "Path to the root of the TensorFlow Lite Micro sources"
+ "${DEPENDENCY_ROOT_DIR}/tensorflow"
+ PATH)
+
+USER_OPTION(TENSORFLOW_LITE_MICRO_BUILD_TYPE "TensorFlow Lite Mirco build type (release/debug etc.)"
+ $<IF:$<CONFIG:RELEASE>,release_with_logs,debug>
+ STRING)
+
+USER_OPTION(TENSORFLOW_LITE_MICRO_CLEAN_DOWNLOADS "Select if TPIP downloads should be cleaned before each build."
+ OFF
+ BOOL)
+
+USER_OPTION(TENSORFLOW_LITE_MICRO_CLEAN_BUILD "Select if clean target should be added to a list of targets"
+ ON
+ BOOL)
+
+USER_OPTION(TARGET_PLATFORM "Target platform to build for: mps3, mps4, simple_platform and native"
+ mps3
+ STRING)
+
+USER_OPTION(USE_CASE_BUILD "Optional. Defines the use-case to build from the available sources. By default, all use-cases are built."
+ all
+ STRING)
+
+USER_OPTION(CPU_PROFILE_ENABLED "Output CPU performance profiling information. Should be used only for MPS3 board."
+ OFF
+ BOOL)
+
+USER_OPTION(USE_SINGLE_INPUT "Select if a use case should execute using a default known input file"
+ OFF
+ BOOL)
diff --git a/scripts/cmake/configuration_options/fvp_test_opts.cmake b/scripts/cmake/configuration_options/fvp_test_opts.cmake
new file mode 100644
index 0000000..91e8588
--- /dev/null
+++ b/scripts/cmake/configuration_options/fvp_test_opts.cmake
@@ -0,0 +1,36 @@
+#----------------------------------------------------------------------------
+# SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its
+# affiliates <open-source-office@arm.com>
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# FVP test configuration options
+#----------------------------------------------------------------------------
+include_guard()
+
+include(util_functions)
+
+message(STATUS "Assessing FVP test configuration options...")
+
+USER_OPTION(BUILD_FVP_TESTS "Build tests for CTest driven FVP runs for built applications"
+ OFF
+ BOOL)
+
+if (BUILD_FVP_TESTS)
+ USER_OPTION(FVP_PATH "Path to FVP for verifying execution"
+ ""
+ FILEPATH)
+endif() \ No newline at end of file
diff --git a/scripts/cmake/configuration_options/npu_opts.cmake b/scripts/cmake/configuration_options/npu_opts.cmake
new file mode 100644
index 0000000..dc0123b
--- /dev/null
+++ b/scripts/cmake/configuration_options/npu_opts.cmake
@@ -0,0 +1,91 @@
+#----------------------------------------------------------------------------
+# SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its
+# affiliates <open-source-office@arm.com>
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# NPU configuration user options
+#----------------------------------------------------------------------------
+include_guard()
+
+include(util_functions)
+
+USER_OPTION(ETHOS_U_NPU_ENABLED "If Arm Ethos-U NPU is enabled in the target system."
+ ON
+ BOOL)
+
+if (NOT ETHOS_U_NPU_ENABLED)
+ return()
+endif()
+
+message(STATUS "Assessing NPU configuration options...")
+
+USER_OPTION(ETHOS_U_NPU_TIMING_ADAPTER_SRC_PATH
+ "Path to Ethos-U NPU timing adapter sources"
+ "${DEPENDENCY_ROOT_DIR}/core-platform/drivers/timing_adapter"
+ PATH
+)
+
+USER_OPTION(ETHOS_U_NPU_DRIVER_SRC_PATH
+ "Path to Ethos-U NPU core driver sources"
+ "${DEPENDENCY_ROOT_DIR}/core-driver"
+ PATH
+)
+
+USER_OPTION(ETHOS_U_NPU_ID "Arm Ethos-U NPU IP (U55 or U65)"
+ "U55"
+ STRING)
+
+if ((ETHOS_U_NPU_ID STREQUAL U55) OR (ETHOS_U_NPU_ID STREQUAL U65))
+ if (ETHOS_U_NPU_ID STREQUAL U55)
+ set(DEFAULT_NPU_MEM_MODE "Shared_Sram")
+ set(DEFAULT_NPU_CONFIG_ID "H128")
+ elseif(ETHOS_U_NPU_ID STREQUAL U65)
+ set(DEFAULT_NPU_MEM_MODE "Dedicated_Sram")
+ set(DEFAULT_NPU_CONFIG_ID "Y256")
+ set(DEFAULT_NPU_CACHE_SIZE "393216")
+
+ USER_OPTION(ETHOS_U_NPU_CACHE_SIZE "Arm Ethos-U65 NPU Cache Size"
+ "${DEFAULT_NPU_CACHE_SIZE}"
+ STRING)
+ endif()
+else ()
+ message(FATAL_ERROR "Non compatible Ethos-U NPU processor ${ETHOS_U_NPU_ID}")
+endif ()
+
+USER_OPTION(ETHOS_U_NPU_MEMORY_MODE "Specifies the memory mode used in the Vela command."
+ "${DEFAULT_NPU_MEM_MODE}"
+ STRING)
+
+USER_OPTION(ETHOS_U_NPU_CONFIG_ID "Specifies the configuration ID for the NPU."
+ "${DEFAULT_NPU_CONFIG_ID}"
+ STRING)
+
+if (ETHOS_U_NPU_ID STREQUAL U55)
+ set(DEFAULT_TA_CONFIG_FILE "ta_config_u55_high_end")
+else ()
+ set(DEFAULT_TA_CONFIG_FILE "ta_config_u65_high_end")
+endif ()
+
+USER_OPTION(ETHOS_U_NPU_TIMING_ADAPTER_ENABLED "Specifies if the Ethos-U timing adapter is enabled"
+ ON
+ BOOL)
+
+if (ETHOS_U_NPU_TIMING_ADAPTER_ENABLED)
+ USER_OPTION(TA_CONFIG_FILE "Path to the timing adapter configuration file"
+ ${DEFAULT_TA_CONFIG_FILE}
+ STRING)
+endif()
diff --git a/scripts/cmake/options-preset.json b/scripts/cmake/configuration_options/options-preset.json
index 57b7a7d..57b7a7d 100644
--- a/scripts/cmake/options-preset.json
+++ b/scripts/cmake/configuration_options/options-preset.json
diff --git a/scripts/cmake/platforms/mps3/build_configuration.cmake b/scripts/cmake/platforms/mps3/build_configuration.cmake
index 1743253..101abdd 100644
--- a/scripts/cmake/platforms/mps3/build_configuration.cmake
+++ b/scripts/cmake/platforms/mps3/build_configuration.cmake
@@ -1,5 +1,6 @@
#----------------------------------------------------------------------------
-# SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
+# SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its
+# affiliates <open-source-office@arm.com>
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,6 +19,21 @@
function(set_platform_global_defaults)
message(STATUS "Platform: MPS3 FPGA Prototyping Board or FVP")
+ # Set default subsystem for MPS3:
+ USER_OPTION(TARGET_SUBSYSTEM "Specify platform target subsystem: sse-300 or sse-310"
+ sse-300
+ STRING)
+
+ # Default NPU for SSE-300 target:
+ USER_OPTION(ETHOS_U_NPU_ID "Arm Ethos-U NPU IP (U55 or U65)"
+ "U55"
+ STRING)
+
+ # Include NPU, FVP tests and CMSIS configuration options
+ include(npu_opts)
+ include(fvp_test_opts)
+ include(cmsis_opts)
+
if (NOT DEFINED CMAKE_SYSTEM_PROCESSOR)
if (TARGET_SUBSYSTEM STREQUAL sse-300)
set(CMAKE_SYSTEM_PROCESSOR cortex-m55 CACHE STRING "Cortex-M CPU to use")
@@ -61,13 +77,13 @@ function(platform_custom_post_build)
# Add link options for the linker script to be used:
add_linker_script(
- ${PARSED_TARGET_NAME} # Target
- ${CMAKE_SCRIPTS_DIR}/platforms/mps3/${TARGET_SUBSYSTEM} # Directory path
- ${LINKER_SCRIPT_NAME}) # Name of the file without suffix
+ ${PARSED_TARGET_NAME} # Target
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${TARGET_SUBSYSTEM} # Directory path
+ ${LINKER_SCRIPT_NAME}) # Name of the file without suffix
add_target_map_file(
- ${PARSED_TARGET_NAME}
- ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PARSED_TARGET_NAME}.map)
+ ${PARSED_TARGET_NAME}
+ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PARSED_TARGET_NAME}.map)
set(SECTORS_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sectors)
set(SECTORS_BIN_DIR ${SECTORS_DIR}/${use_case})
diff --git a/scripts/cmake/platforms/mps4/build_configuration.cmake b/scripts/cmake/platforms/mps4/build_configuration.cmake
index 3a3966d..918091a 100644
--- a/scripts/cmake/platforms/mps4/build_configuration.cmake
+++ b/scripts/cmake/platforms/mps4/build_configuration.cmake
@@ -1,5 +1,6 @@
#----------------------------------------------------------------------------
-# SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its affiliates <open-source-office@arm.com>
+# SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its
+# affiliates <open-source-office@arm.com>
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,6 +19,21 @@
function(set_platform_global_defaults)
message(STATUS "Platform: Arm MPS4 FPGA Prototyping Board or FVP")
+ # Default sub-system for MPS4
+ USER_OPTION(TARGET_SUBSYSTEM "Specify platform target subsystem: sse-315"
+ sse-315
+ STRING)
+
+ # Default NPU for SSE-315 target:
+ USER_OPTION(ETHOS_U_NPU_ID "Arm Ethos-U NPU IP (U55 or U65)"
+ "U65"
+ STRING)
+
+ # Include NPU, FVP tests and CMSIS configuration options
+ include(npu_opts)
+ include(fvp_test_opts)
+ include(cmsis_opts)
+
if (NOT DEFINED CMAKE_SYSTEM_PROCESSOR)
if(TARGET_SUBSYSTEM STREQUAL sse-315)
set(CMAKE_SYSTEM_PROCESSOR cortex-m85 CACHE STRING "Cortex-M CPU to use")
@@ -52,13 +68,13 @@ function(platform_custom_post_build)
# Add link options for the linker script to be used:
add_linker_script(
- ${PARSED_TARGET_NAME} # Target
- ${CMAKE_SCRIPTS_DIR}/platforms/mps4/${TARGET_SUBSYSTEM} # Directory path
- ${LINKER_SCRIPT_NAME}) # Name of the file without suffix
+ ${PARSED_TARGET_NAME} # Target
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${TARGET_SUBSYSTEM} # Directory path
+ ${LINKER_SCRIPT_NAME}) # Name of the file without suffix
add_target_map_file(
- ${PARSED_TARGET_NAME}
- ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PARSED_TARGET_NAME}.map)
+ ${PARSED_TARGET_NAME}
+ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PARSED_TARGET_NAME}.map)
set(SECTORS_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sectors)
set(SECTORS_BIN_DIR ${SECTORS_DIR}/${use_case})
diff --git a/scripts/cmake/platforms/simple_platform/build_configuration.cmake b/scripts/cmake/platforms/simple_platform/build_configuration.cmake
index 3536c5b..07c9e05 100644
--- a/scripts/cmake/platforms/simple_platform/build_configuration.cmake
+++ b/scripts/cmake/platforms/simple_platform/build_configuration.cmake
@@ -1,5 +1,6 @@
#----------------------------------------------------------------------------
-# SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
+# SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its
+# affiliates <open-source-office@arm.com>
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,6 +18,11 @@
function(set_platform_global_defaults)
message(STATUS "Platform: Simple platform with minimal peripherals")
+
+ # Include NPU and CMSIS configuration options
+ include(npu_opts)
+ include(cmsis_opts)
+
if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_DIR}/bare-metal-gcc.cmake
CACHE FILEPATH "Toolchain file")
@@ -41,9 +47,9 @@ function(platform_custom_post_build)
# Add link options for the linker script to be used:
add_linker_script(
- ${PARSED_TARGET_NAME} # Target
- ${CMAKE_SCRIPTS_DIR}/platforms/simple_platform # Directory path
- ${LINKER_SCRIPT_NAME}) # Name of the file without suffix
+ ${PARSED_TARGET_NAME} # Target
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR} # Directory path
+ ${LINKER_SCRIPT_NAME}) # Name of the file without suffix
add_target_map_file(
${PARSED_TARGET_NAME}
diff --git a/scripts/cmake/source_gen_utils.cmake b/scripts/cmake/source_gen_utils.cmake
index 6287cb6..3406615 100644
--- a/scripts/cmake/source_gen_utils.cmake
+++ b/scripts/cmake/source_gen_utils.cmake
@@ -1,5 +1,6 @@
#----------------------------------------------------------------------------
-# SPDX-FileCopyrightText: Copyright 2021 Arm Limited and/or its affiliates <open-source-office@arm.com>
+# SPDX-FileCopyrightText: Copyright 2021, 2024 Arm Limited and/or its
+# affiliates <open-source-office@arm.com>
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#----------------------------------------------------------------------------
+include_guard()
+
set(SCRIPTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/scripts)
##############################################################################
diff --git a/scripts/cmake/tensorflow.cmake b/scripts/cmake/tensorflow_lite_micro.cmake
index 0fa0f8c..cb45274 100644
--- a/scripts/cmake/tensorflow.cmake
+++ b/scripts/cmake/tensorflow_lite_micro.cmake
@@ -1,5 +1,6 @@
#----------------------------------------------------------------------------
-# SPDX-FileCopyrightText: Copyright 2021-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
+# SPDX-FileCopyrightText: Copyright 2021-2024 Arm Limited and/or its
+# affiliates <open-source-office@arm.com>
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -69,8 +70,8 @@ else()
if(ETHOS_U_NPU_ENABLED)
# Arm Ethos-U55 NPU is the co-processor for ML workload:
- set(TENSORFLOW_LITE_MICRO_CO_PROCESSOR "ethos_u")
- set(ETHOS_U_NPU_ID "u55") # Currently only u55 is supported by TFLite Micro.
+ set(TENSORFLOW_LITE_MICRO_CO_PROCESSOR "ethos_u")
+ set(TENSORFLOW_LITE_MICRO_CO_PROCESSOR_ARCH "u55") # Currently only u55 is supported by TFLite Micro.
endif()
set(TENSORFLOW_LITE_MICRO_OPTIMIZED_KERNEL "cmsis_nn")
@@ -114,7 +115,7 @@ add_custom_target(tensorflow_build ALL
CMSIS_PATH=${CMSIS_SRC_PATH}
CMSIS_NN_PATH=${CMSIS_NN_SRC_PATH}
# Conditional arguments
- $<$<BOOL:${ETHOS_U_NPU_ENABLED}>:ETHOSU_ARCH=${ETHOS_U_NPU_ID}>
+ $<$<BOOL:${ETHOS_U_NPU_ENABLED}>:ETHOSU_ARCH=${TENSORFLOW_LITE_MICRO_CO_PROCESSOR_ARCH}>
$<$<BOOL:${ETHOS_U_NPU_ENABLED}>:ETHOSU_DRIVER_PATH=${ETHOS_U_NPU_DRIVER_SRC_PATH}>
$<$<BOOL:${ETHOS_U_NPU_ENABLED}>:ETHOSU_DRIVER_LIBS=$<TARGET_FILE:ethosu_core_driver>>
diff --git a/scripts/cmake/util_functions.cmake b/scripts/cmake/util_functions.cmake
index 0567ee0..6966963 100644
--- a/scripts/cmake/util_functions.cmake
+++ b/scripts/cmake/util_functions.cmake
@@ -1,5 +1,6 @@
#----------------------------------------------------------------------------
-# SPDX-FileCopyrightText: Copyright 2021-2022 Arm Limited and/or its affiliates <open-source-office@arm.com>
+# SPDX-FileCopyrightText: Copyright 2021-2022, 2024 Arm Limited and/or its
+# affiliates <open-source-office@arm.com>
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,6 +19,8 @@
##############################################################################
# Helper function to provide user option and corresponding default value
##############################################################################
+include_guard()
+
function(USER_OPTION name description default type)
if (${type} STREQUAL PATH_OR_FILE)
@@ -180,7 +183,7 @@ function(add_platform_build_configuration)
set(oneValueArgs TARGET_PLATFORM)
cmake_parse_arguments(PARSED "" "${oneValueArgs}" "" ${ARGN} )
message(STATUS "Searching for ${PARSED_TARGET_PLATFORM} build configuration")
- list(APPEND PLATFORM_BUILD_CONFIG_DIRS ${CMAKE_SCRIPTS_DIR}/platforms)
+ list(APPEND PLATFORM_BUILD_CONFIG_DIRS ${SCRIPTS_DIR}/cmake/platforms)
FIND_PATH(PLATFORM_BUILD_CONFIG
NAMES build_configuration.cmake
diff --git a/source/hal/source/components/npu_ta/CMakeLists.txt b/source/hal/source/components/npu_ta/CMakeLists.txt
index 9956384..2030849 100644
--- a/source/hal/source/components/npu_ta/CMakeLists.txt
+++ b/source/hal/source/components/npu_ta/CMakeLists.txt
@@ -90,5 +90,5 @@ target_link_libraries(${ETHOS_U_NPU_TA_COMPONENT} PUBLIC
# Display status
message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR})
message(STATUS "*******************************************************")
-message(STATUS "Library : " ${ETHOS_U_NPU_TA_COMPONENT})
+message(STATUS "Library : " ${ETHOS_U_NPU_TA_COMPONENT})
message(STATUS "*******************************************************")
diff --git a/source/math/CMakeLists.txt b/source/math/CMakeLists.txt
index 9b61905..2cd7989 100644
--- a/source/math/CMakeLists.txt
+++ b/source/math/CMakeLists.txt
@@ -1,5 +1,6 @@
#----------------------------------------------------------------------------
-# SPDX-FileCopyrightText: Copyright 2022 Arm Limited and/or its affiliates <open-source-office@arm.com>
+# SPDX-FileCopyrightText: Copyright 2022, 2024 Arm Limited and/or its
+# affiliates <open-source-office@arm.com>
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -34,11 +35,11 @@ target_include_directories(arm_math PUBLIC include)
target_link_libraries(arm_math PRIVATE log)
if (${CMAKE_CROSSCOMPILING})
- include(${CMAKE_SCRIPTS_DIR}/cmsis-dsp.cmake)
+ include(cmsis-dsp)
target_link_libraries(arm_math PUBLIC cmsis-dsp)
endif ()
message(STATUS "*******************************************************")
-message(STATUS "Library : " arm_math)
-message(STATUS "CMAKE_SYSTEM_PROCESSOR : " ${CMAKE_SYSTEM_PROCESSOR})
+message(STATUS "Library : " arm_math)
+message(STATUS "CMAKE_SYSTEM_PROCESSOR : " ${CMAKE_SYSTEM_PROCESSOR})
message(STATUS "*******************************************************")