Skip to content

Commit 9a3672d

Browse files
authored
Arm backend: Get ethos-u dependency using FetchContent (#7882)
Signed-off-by: Erik Lundell <[email protected]>
1 parent 639c6d8 commit 9a3672d

File tree

3 files changed

+33
-27
lines changed

3 files changed

+33
-27
lines changed

examples/arm/executor_runner/CMakeLists.txt

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023-2024 Arm Limited and/or its affiliates.
1+
# Copyright 2023-2025 Arm Limited and/or its affiliates.
22
#
33
# This source code is licensed under the BSD-style license found in the
44
# LICENSE file in the root directory of this source tree.
@@ -44,6 +44,37 @@ set(PYTHON_EXECUTABLE
4444
CACHE PATH "Define to override python executable used"
4545
)
4646

47+
# Download ethos_u dependency if needed.
48+
include(FetchContent)
49+
set(ethos_u_base_rev "24.08")
50+
FetchContent_Declare(
51+
ethos_u
52+
GIT_REPOSITORY https://git.gitlab.arm.com/artificial-intelligence/ethos-u/ethos-u.git
53+
GIT_TAG ${ethos_u_base_rev}
54+
SOURCE_DIR ${ETHOS_SDK_PATH}
55+
BINARY_DIR ${ETHOS_SDK_PATH}
56+
SUBBUILD_DIR ${ETHOS_SDK_PATH}/../ethos_u-subbuild
57+
SOURCE_SUBDIR none
58+
)
59+
60+
FetchContent_MakeAvailable(ethos_u)
61+
62+
# Get ethos_u externals only if core_platform folder does not already exist.
63+
if(NOT EXISTS "${ETHOS_SDK_PATH}/core_platform")
64+
execute_process(COMMAND ${PYTHON_EXECUTABLE} fetch_externals.py -c ${ethos_u_base_rev}.json fetch
65+
WORKING_DIRECTORY ${ETHOS_SDK_PATH}
66+
COMMAND_ECHO STDOUT
67+
)
68+
endif()
69+
70+
# Always patch the core_platform repo since this is fast enough.
71+
set(core_platform_base_rev "b728c774158248ba2cad8e78a515809e1eb9b77f")
72+
set(patch_dir "examples/arm/ethos-u-setup")
73+
execute_process(COMMAND bash -c "pwd && source backends/arm/scripts/utils.sh && patch_repo ${ETHOS_SDK_PATH}/core_platform ${core_platform_base_rev} ${patch_dir}"
74+
WORKING_DIRECTORY ${ET_DIR_PATH}
75+
COMMAND_ECHO STDOUT
76+
)
77+
4778
# Selects timing adapter values matching system_config.
4879
# Default is Ethos_U55_High_End_Embedded, simulating optimal hardware for the Corestone-300.
4980
set(SYSTEM_CONFIG "Ethos_U55_High_End_Embedded" CACHE STRING "System config")

examples/arm/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ else
8181
fi
8282
executor_runner_path=$(realpath ${executor_runner_path})
8383

84+
mkdir -p ${root_dir}/ethos-u
8485
ethos_u_root_dir="$(cd ${root_dir}/ethos-u && pwd)"
85-
ethos_u_build_dir=${ethos_u_root_dir}/core_platform/build
8686
setup_path_script=${root_dir}/setup_path.sh
8787

8888
# Executorch

examples/arm/setup.sh

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -179,23 +179,7 @@ function setup_toolchain() {
179179
echo "export PATH=\${PATH}:${toolchain_bin_path}" >> ${setup_path_script}
180180
}
181181

182-
function setup_ethos_u() {
183-
# This is the main dir which will pull more repos to do baremetal software dev for cs300
184-
echo "[${FUNCNAME[0]}] Setting up the repo"
185-
cd "${root_dir}"
186-
[[ ! -d ethos-u ]] && \
187-
git clone ${ethos_u_repo_url}
188-
cd ethos-u
189-
git reset --hard ${ethos_u_base_rev}
190-
python3 ./fetch_externals.py -c ${ethos_u_base_rev}.json fetch
191-
192-
pip install pyelftools
193-
echo "[${FUNCNAME[0]}] Done @ $(git describe --all --long 3> /dev/null) in ${root_dir}/ethos-u dir."
194-
}
195-
196-
197182
function setup_tosa_reference_model() {
198-
199183
# reference_model flatbuffers version clashes with Vela.
200184
# go with Vela's since it newer.
201185
# Vela's flatbuffer requirement is expected to loosen, then remove this. MLETORCH-565
@@ -236,15 +220,6 @@ source $et_dir/backends/arm/scripts/utils.sh
236220
# Setup toolchain
237221
setup_toolchain
238222

239-
# Setup the ethos-u dev environment
240-
setup_ethos_u
241-
242-
# Patch the ethos-u dev environment to include executorch application
243-
repo_dir="${root_dir}/ethos-u/core_platform"
244-
base_rev=b728c774158248ba2cad8e78a515809e1eb9b77f
245-
patch_dir=${script_dir}/ethos-u-setup/
246-
patch_repo $repo_dir $base_rev $patch_dir
247-
248223
# Setup the tosa_reference_model
249224
setup_tosa_reference_model
250225

0 commit comments

Comments
 (0)