Skip to content

Commit 7963bbb

Browse files
authored
Arm backend: Enable semihosting in build_executor_runner.sh (#13325)
Additionally, - Use build_executor_runner in setup_testing - Avoid hard coding runner build path ending with cmake-out Signed-off-by: Erik Lundell <[email protected]>
1 parent 584fa71 commit 7963bbb

File tree

3 files changed

+23
-59
lines changed

3 files changed

+23
-59
lines changed

backends/arm/scripts/build_executor_runner.sh

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ build_with_etdump_flags=" -DEXECUTORCH_ENABLE_EVENT_TRACER=OFF "
3333
help() {
3434
echo "Usage: $(basename $0) [options]"
3535
echo "Options:"
36-
echo " --pte=<PTE_FILE> pte file (genrated by the aot_arm_compier from the model to include in the elf"
36+
echo " --pte=<PTE_FILE>|semihosting pte file (generated by the aot_arm_compier from the model to include in the elf), or semihosting to supply pte at runtime."
3737
echo " --target=<TARGET> Target to build and run for Default: ${target}"
3838
echo " --build_type=<TYPE> Build with Release, Debug or RelWithDebInfo, default is ${build_type}"
3939
echo " --bundleio Support both pte and Bundle IO bpte using Devtools BundelIO with Input/RefOutput included"
@@ -93,18 +93,24 @@ toolchain_cmake=$(realpath ${toolchain_cmake})
9393

9494
source ${setup_path_script}
9595

96-
pte_file=$(realpath ${pte_file})
96+
if [[ ${pte_file} == "semihosting" ]]; then
97+
extra_build_flags="${extra_build_flags} -DSEMIHOSTING=ON"
98+
else
99+
pte_file=$(realpath ${pte_file})
100+
extra_build_flags="${extra_build_flags} -DET_PTE_FILE_PATH:PATH='${pte_file}'"
101+
fi
97102
ethosu_tools_dir=$(realpath ${ethosu_tools_dir})
98103
ethos_u_root_dir="$ethosu_tools_dir/ethos-u"
99104
mkdir -p "${ethos_u_root_dir}"
100105
ethosu_tools_dir=$(realpath ${ethos_u_root_dir})
101106

102107
et_build_dir=${et_build_root}/cmake-out
108+
mkdir -p ${et_build_dir}
103109
et_build_dir=$(realpath ${et_build_dir})
104110

105111
if [ "$output_folder_set" = false ] ; then
106112
# remove file ending
107-
output_folder=${pte_file%.*}
113+
output_folder=${pte_file%.*}/cmake-out
108114
fi
109115

110116
if [[ ${system_config} == "" ]]
@@ -134,7 +140,7 @@ else
134140
target_cpu=cortex-m85
135141
fi
136142
echo "--------------------------------------------------------------------------------"
137-
echo "Build Arm ${toolchain/-gcc/} executor_runner for ${target} with ${pte_file} using ${system_config} ${memory_mode} ${extra_build_flags} to '${output_folder}/cmake-out'"
143+
echo "Build Arm ${toolchain/-gcc/} executor_runner for ${target} with ${pte_file} using ${system_config} ${memory_mode} ${extra_build_flags} to '${output_folder}'"
138144
echo "--------------------------------------------------------------------------------"
139145

140146
cd ${et_root_dir}/examples/arm/executor_runner
@@ -154,7 +160,6 @@ cmake \
154160
-DTARGET_CPU=${target_cpu} \
155161
-DET_DIR_PATH:PATH=${et_root_dir} \
156162
-DET_BUILD_DIR_PATH:PATH=${et_build_dir} \
157-
-DET_PTE_FILE_PATH:PATH="${pte_file}" \
158163
-DETHOS_SDK_PATH:PATH=${ethos_u_root_dir} \
159164
-DETHOSU_TARGET_NPU_CONFIG=${target} \
160165
${build_bundleio_flags} \
@@ -164,14 +169,14 @@ cmake \
164169
-DMEMORY_MODE=${memory_mode} \
165170
-DEXECUTORCH_SELECT_OPS_LIST="${select_ops_list}" \
166171
${extra_build_flags} \
167-
-B ${output_folder}/cmake-out
172+
-B ${output_folder}
168173

169174
echo "[${BASH_SOURCE[0]}] Configured CMAKE"
170175

171-
cmake --build ${output_folder}/cmake-out -j$(nproc) -- arm_executor_runner
176+
cmake --build ${output_folder} -j$(nproc) -- arm_executor_runner
172177

173178
echo "[${BASH_SOURCE[0]}] Generated ${toolchain} elf file:"
174-
find ${output_folder}/cmake-out -name "arm_executor_runner"
175-
echo "executable_text: $(find ${output_folder}/cmake-out -name arm_executor_runner -exec ${toolchain/-gcc/-size} {} \; | grep -v filename | awk '{print $1}') bytes"
176-
echo "executable_data: $(find ${output_folder}/cmake-out -name arm_executor_runner -exec ${toolchain/-gcc/-size} {} \; | grep -v filename | awk '{print $2}') bytes"
177-
echo "executable_bss: $(find ${output_folder}/cmake-out -name arm_executor_runner -exec ${toolchain/-gcc/-size} {} \; | grep -v filename | awk '{print $3}') bytes"
179+
find ${output_folder} -name "arm_executor_runner"
180+
echo "executable_text: $(find ${output_folder} -name arm_executor_runner -exec ${toolchain/-gcc/-size} {} \; | grep -v filename | awk '{print $1}') bytes"
181+
echo "executable_data: $(find ${output_folder} -name arm_executor_runner -exec ${toolchain/-gcc/-size} {} \; | grep -v filename | awk '{print $2}') bytes"
182+
echo "executable_bss: $(find ${output_folder} -name arm_executor_runner -exec ${toolchain/-gcc/-size} {} \; | grep -v filename | awk '{print $3}') bytes"

backends/arm/test/setup_testing.sh

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,52 +7,10 @@
77

88
set -eu
99

10-
script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
11-
et_root_dir=$(cd ${script_dir}/../../.. && pwd)
12-
ethos_u_root_dir=${et_root_dir}/examples/arm/ethos-u-scratch/ethos-u
13-
14-
toolchain_cmake=${et_root_dir}/examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake
15-
et_build_dir=${et_root_dir}/arm_test/cmake-out
10+
script_dir=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
11+
et_root_dir=$(realpath "${script_dir}/../../..")
12+
build_executor_runner=${et_root_dir}/backends/arm/scripts/build_executor_runner.sh
1613
build_root_test_dir=${et_root_dir}/arm_test/arm_semihosting_executor_runner
1714

18-
# Build Arm Baremetal executor_runner in semihosting mode.
19-
# Put in backends/arm/test/res to be used by unit tests.
20-
function build_semihosting_executorch_runner() {
21-
target_board=$1
22-
system_config=$2
23-
build_test_dir=${build_root_test_dir}_${target_board}
24-
echo "[${FUNCNAME[0]}] Configuring ${target_board} with system config ${system_config}"
25-
if [[ ${target_board} == "corstone-300" ]]; then
26-
local target_cpu=cortex-m55
27-
elif [[ ${target_board} == "corstone-320" ]]; then
28-
local target_cpu=cortex-m85
29-
else
30-
echo "[${FUNCNAME[0]}] ERROR: Invalid target_board specified!"
31-
exit 1
32-
fi
33-
cd ${et_root_dir}/examples/arm/executor_runner
34-
pwd
35-
mkdir -p ${build_test_dir}
36-
cmake -DCMAKE_TOOLCHAIN_FILE=${toolchain_cmake} \
37-
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
38-
-DTARGET_CPU=${target_cpu} \
39-
-DSEMIHOSTING=ON \
40-
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${build_test_dir} \
41-
-DETHOS_SDK_PATH:PATH=${ethos_u_root_dir} \
42-
-DET_DIR_PATH:PATH=${et_root_dir} \
43-
-DET_BUILD_DIR_PATH:PATH=${et_build_dir} \
44-
-DPYTHON_EXECUTABLE=$(which python3) \
45-
-DSYSTEM_CONFIG=${system_config} \
46-
-B ${build_test_dir}
47-
echo "[${FUNCNAME[0]}] Configured CMAKE"
48-
49-
n=$(nproc)
50-
cmake --build ${build_test_dir} -j"$((n - 5))" -- arm_executor_runner
51-
echo "[${FUNCNAME[0]}] Generated baremetal elf file: with semihosting enabled"
52-
find ${build_test_dir} -name "arm_executor_runner"
53-
}
54-
55-
# Use most optimal system_configs for testing
56-
build_semihosting_executorch_runner corstone-300 Ethos_U55_High_End_Embedded
57-
58-
build_semihosting_executorch_runner corstone-320 Ethos_U85_SYS_DRAM_Mid
15+
${build_executor_runner} --pte=semihosting --target=ethos-u55-128 --output="${build_root_test_dir}_corstone-300"
16+
${build_executor_runner} --pte=semihosting --target=ethos-u85-128 --output="${build_root_test_dir}_corstone-320"

backends/arm/test/test_model.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ def build_ethosu_runtime(
157157
extra_flags: str,
158158
elf_build_path: str,
159159
):
160+
elf_build_path = os.path.join(elf_build_path, "cmake-out")
160161
run_external_cmd(
161162
[
162163
"bash",
@@ -174,7 +175,7 @@ def build_ethosu_runtime(
174175
]
175176
)
176177

177-
elf_file = os.path.join(elf_build_path, "cmake-out", "arm_executor_runner")
178+
elf_file = os.path.join(elf_build_path, "arm_executor_runner")
178179
return elf_file
179180

180181

0 commit comments

Comments
 (0)