Skip to content

Commit 184af9a

Browse files
committed
Adding in support for CI flow, required allowing setup script to take url for user specified toolchain download
1 parent d1c0c93 commit 184af9a

File tree

3 files changed

+117
-7
lines changed

3 files changed

+117
-7
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
# Copyright 2025 Arm Limited and/or its affiliates.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# NB: This function could be used to install Arm dependencies
8+
# Setup arm example environment (including TOSA tools)
9+
git config --global user.email "[email protected]"
10+
git config --global user.name "Github Executorch"
11+
bash examples/arm/setup.sh --i-agree-to-the-contained-eula --user-toolchain-url "https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.2/toolchain_linux-x86_64_arm-zephyr-eabi.tar.xz" --user-toolchain-dir "arm-zephyr-eabi"

.github/workflows/trunk.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,61 @@ jobs:
271271
exit 1
272272
fi
273273
274+
test-arm-cortex-m-zephyr-size-test:
275+
name: test-arm-cortex-m-zephyr-size-test
276+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
277+
permissions:
278+
id-token: write
279+
contents: read
280+
with:
281+
runner: linux.2xlarge
282+
docker-image: executorch-ubuntu-22.04-arm-sdk
283+
submodules: 'recursive'
284+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
285+
timeout: 90
286+
script: |
287+
# The generic Linux job chooses to use base env, not the one setup by the image
288+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
289+
conda activate "${CONDA_ENV}"
290+
291+
source .ci/scripts/utils.sh
292+
install_executorch "--use-pt-pinned-commit"
293+
.ci/scripts/setup-arm-zephyr-tools.sh
294+
source examples/arm/ethos-u-scratch/setup_path.sh
295+
296+
# User baremetal toolchain
297+
arm-zephyr-eabi-c++ --version
298+
toolchain_cmake=examples/arm/ethos-u-setup/arm-zephyr-eabi-gcc.cmake
299+
toolchain_cmake=$(realpath ${toolchain_cmake})
300+
301+
# Build and test size test
302+
cmake --preset zephyr
303+
bash test/build_size_test.sh "-DCMAKE_TOOLCHAIN_FILE=${toolchain_cmake}"
304+
elf="cmake-out/test/size_test"
305+
306+
# Dump basic info
307+
ls -al ${elf}
308+
arm-zephyr-eabi-size ${elf}
309+
310+
# Dump symbols
311+
python .github/scripts/run_nm.py -e ${elf}
312+
python .github/scripts/run_nm.py -e ${elf} -f "executorch" -p "arm-zephyr-eabi-"
313+
python .github/scripts/run_nm.py -e ${elf} -f "executorch_text" -p "arm-zephyr-eabi-"
314+
315+
# Add basic guard - TODO: refine this!
316+
arm-zephyr-eabi-strip ${elf}
317+
output=$(ls -la ${elf})
318+
arr=($output)
319+
size=${arr[4]}
320+
threshold="103268" # ~100KiB
321+
echo "size: $size, threshold: $threshold"
322+
if [[ "$size" -le "$threshold" ]]; then
323+
echo "Success $size <= $threshold"
324+
else
325+
echo "Fail $size > $threshold"
326+
exit 1
327+
fi
328+
274329
test-coreml-delegate:
275330
name: test-coreml-delegate
276331
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main

examples/arm/setup.sh

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ et_dir=$(realpath $script_dir/../..)
1717
ARCH="$(uname -m)"
1818
OS="$(uname -s)"
1919
root_dir="${script_dir}/ethos-u-scratch"
20+
user_toolchain_url=""
21+
user_toolchain_dir=""
2022
eula_acceptance=0
2123
skip_toolchain_setup=0
2224
skip_fvp_setup=0
@@ -73,7 +75,7 @@ vela_rev="8cac2b9a7204b57125a8718049519b091a98846c"
7375
########
7476

7577
function print_usage() {
76-
echo "Usage: $(basename $0) <--i-agree-to-the-contained-eula> [--root-dir path-to-a-scratch-dir] [--skip-fvp-setup] [--skip-toolchain-setup] [--skip-vela-setup]"
78+
echo "Usage: $(basename $0) <--i-agree-to-the-contained-eula> [--root-dir path-to-a-scratch-dir] [--user-toolchain-url toolchain-url] [--user-toolchain-dir toolchain-dir] [--skip-fvp-setup] [--skip-toolchain-setup] [--skip-vela-setup]"
7779
echo "Supplied args: $*"
7880
}
7981

@@ -90,6 +92,30 @@ function check_options() {
9092
root_dir=${2:-"${root_dir}"}
9193
fi
9294

95+
if [[ $# -ge 2 ]]; then
96+
shift 2
97+
else
98+
print_usage "$@"
99+
exit 1
100+
fi
101+
;;
102+
--user-toolchain-url)
103+
if [[ $is_script_sourced -eq 0 ]]; then
104+
user_toolchain_url=${2:-"${user_toolchain_url}"}
105+
fi
106+
107+
if [[ $# -ge 2 ]]; then
108+
shift 2
109+
else
110+
print_usage "$@"
111+
exit 1
112+
fi
113+
;;
114+
--user-toolchain-dir)
115+
if [[ $is_script_sourced -eq 0 ]]; then
116+
user_toolchain_dir=${2:-"${user_toolchain_dir}"}
117+
fi
118+
93119
if [[ $# -ge 2 ]]; then
94120
shift 2
95121
else
@@ -200,15 +226,27 @@ function setup_fvp() {
200226
function setup_toolchain() {
201227
# Download and install the arm-none-eabi toolchain
202228
cd "${root_dir}"
203-
if [[ ! -e "${toolchain_dir}.tar.xz" ]]; then
229+
local selected_toolchain_url="${toolchain_url}"
230+
local selected_toolchain_dir="${toolchain_dir}"
231+
local selected_toolchain_md5="${toolchain_md5_checksum}"
232+
local skip_md5_verify=0
233+
if [[ -n "${user_toolchain_url}" ]]; then
234+
selected_toolchain_url="${user_toolchain_url}"
235+
selected_toolchain_dir="${user_toolchain_dir}"
236+
selected_toolchain_md5=""
237+
skip_md5_verify=1
238+
fi
239+
if [[ ! -e "${selected_toolchain_dir}.tar.xz" ]]; then
204240
echo "[${FUNCNAME[0]}] Downloading toolchain ..."
205-
curl --output "${toolchain_dir}.tar.xz" "${toolchain_url}"
206-
verify_md5 ${toolchain_md5_checksum} "${toolchain_dir}.tar.xz" || exit 1
241+
curl --output "${selected_toolchain_dir}.tar.xz" -L "${selected_toolchain_url}"
242+
if [[ ${skip_md5_verify} -eq 0 ]]; then
243+
verify_md5 ${selected_toolchain_md5} "${selected_toolchain_dir}.tar.xz" || exit 1
244+
fi
207245
fi
208246

209247
echo "[${FUNCNAME[0]}] Installing toolchain ..."
210-
rm -rf "${toolchain_dir}"
211-
tar xf "${toolchain_dir}.tar.xz"
248+
rm -rf "${selected_toolchain_dir}"
249+
tar xf "${selected_toolchain_dir}.tar.xz"
212250
}
213251

214252
function setup_vela() {
@@ -237,8 +275,12 @@ function create_setup_path(){
237275
echo "hash FVP_Corstone_SSE-320" >> ${setup_path_script}
238276
fi
239277

278+
local selected_toolchain_dir="${toolchain_dir}"
279+
if [[ -n "${user_toolchain_url}" && -n "${user_toolchain_dir}" ]]; then
280+
selected_toolchain_dir="${user_toolchain_dir}"
281+
fi
240282
if [[ "${skip_toolchain_setup}" -eq 0 ]]; then
241-
toolchain_bin_path="$(cd ${toolchain_dir}/bin && pwd)"
283+
toolchain_bin_path="$(cd ${selected_toolchain_dir}/bin && pwd)"
242284
echo "export PATH=\${PATH}:${toolchain_bin_path}" >> ${setup_path_script}
243285
fi
244286
}
@@ -271,6 +313,8 @@ if [[ $is_script_sourced -eq 0 ]]; then
271313
setup_root_dir
272314
cd "${root_dir}"
273315
echo "[main] Using root dir ${root_dir} and options:"
316+
echo "user_toolchain_url=${user_toolchain_url}"
317+
echo "user_toolchain_dir=${user_toolchain_dir}"
274318
echo "skip-fvp-setup=${skip_fvp_setup}"
275319
echo "skip-toolchain-setup=${skip_toolchain_setup}"
276320
echo "skip-vela-setup=${skip_vela_setup}"

0 commit comments

Comments
 (0)