Skip to content

Commit 8d0053c

Browse files
Arm backend: Add arm-baremetal CMake preset (#13042)
- Executorch may be cross compiled for arm-baremetal targets using 'cmake --preset arm-baremetal' - Adds a new flag EXECUTORCH_BUILD_ARM_ETDUMP used in the preset to easy enabling of ET_DUMP. - backend/arm/scripts/build_executorch.sh is updated to use the new preset with same behaviour as before. Signed-off-by: Adrian Lundell <[email protected]>
1 parent f8b4835 commit 8d0053c

File tree

3 files changed

+44
-38
lines changed

3 files changed

+44
-38
lines changed

CMakePresets.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,15 @@
128128
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/zephyr.cmake",
129129
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/examples/zephyr/x86_64-linux-arm-zephyr-eabi-gcc.cmake"
130130
}
131+
},
132+
{
133+
"name": "arm-baremetal",
134+
"displayName": "Build ExecuTorch for Arm baremetal",
135+
"inherits": ["common"],
136+
"cacheVariables": {
137+
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/arm_baremetal.cmake",
138+
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake"
139+
}
131140
}
132141
]
133142
}

backends/arm/scripts/build_executorch.sh

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ _setup_msg="please refer to ${et_root_dir}/examples/arm/setup.sh to properly ins
1919

2020
et_build_root="${et_root_dir}/arm_test"
2121
build_type="Release"
22-
build_devtools=false
23-
build_with_etdump=false
22+
build_devtools=OFF
23+
build_with_etdump=OFF
2424

2525
help() {
2626
echo "Usage: $(basename $0) [options]"
@@ -38,8 +38,8 @@ for arg in "$@"; do
3838
-h|--help) help ;;
3939
--et_build_root=*) et_build_root="${arg#*=}";;
4040
--build_type=*) build_type="${arg#*=}";;
41-
--devtools) build_devtools=true ;;
42-
--etdump) build_with_etdump=true ;;
41+
--devtools) build_devtools=ON ;;
42+
--etdump) build_with_etdump=ON ;;
4343
--toolchain=*) toolchain="${arg#*=}";;
4444
*)
4545
;;
@@ -48,7 +48,7 @@ done
4848

4949
if [[ ${toolchain} == "arm-none-eabi-gcc" ]]; then
5050
toolchain_cmake=${et_root_dir}/examples/arm/ethos-u-setup/${toolchain}.cmake
51-
elif [[ ${toolchain} == "arm-zephyr-eabi-gcc" ]]; then
51+
elif [[ ${toolchain} == "arm-zephyr-eabi-gcc" ]]; then
5252
toolchain_cmake=${et_root_dir}/examples/zephyr/x86_64-linux-arm-zephyr-eabi-gcc.cmake
5353
else
5454
echo "Error: Invalid toolchain selection, provided: ${tolchain}"
@@ -74,40 +74,12 @@ cd "${et_root_dir}"
7474
echo "Build ExecuTorch target libs ${build_type} into '${et_build_dir}'" ;
7575
echo "--------------------------------------------------------------------------------" )
7676

77-
build_devtools_flags=" -DEXECUTORCH_BUILD_DEVTOOLS=OFF "
78-
if [ "$build_devtools" = true ] ; then
79-
build_devtools_flags=" -DEXECUTORCH_BUILD_DEVTOOLS=ON "
80-
fi
81-
82-
build_with_etdump_flags=" -DEXECUTORCH_ENABLE_EVENT_TRACER=OFF "
83-
if [ "$build_with_etdump" = true ] ; then
84-
# Add DevTools flags use in the Target build below
85-
build_with_etdump_flags="-DEXECUTORCH_BUILD_DEVTOOLS=ON \
86-
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
87-
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=OFF \
88-
-DFLATCC_ALLOW_WERROR=OFF "
89-
fi
90-
91-
echo "Building with Devtools: ${build_devtools_flags} ${build_with_etdump_flags}"
92-
93-
9477
# Build
95-
cmake \
96-
-DCMAKE_INSTALL_PREFIX=${et_build_dir} \
97-
-DCMAKE_BUILD_TYPE=${build_type} \
98-
-DCMAKE_TOOLCHAIN_FILE="${toolchain_cmake}" \
99-
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \
100-
-DEXECUTORCH_BUILD_ARM_BAREMETAL=ON \
101-
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
102-
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
103-
-DEXECUTORCH_BUILD_CORTEX_M=ON \
104-
-DEXECUTORCH_ENABLE_LOGGING=ON \
105-
${build_devtools_flags} \
106-
${build_with_etdump_flags} \
107-
-B"${et_build_dir}" \
108-
"${et_root_dir}"
109-
110-
echo "[$(basename $0)] Configured CMAKE"
78+
cmake -DCMAKE_TOOLCHAIN_FILE=${toolchain_cmake} \
79+
-DCMAKE_BUILD_TYPE=Release \
80+
-DEXECUTORCH_BUILD_DEVTOOLS=$build_devtools \
81+
-DEXECUTORCH_BUILD_ARM_ETDUMP=$build_with_etdump \
82+
--preset arm-baremetal -B${et_build_dir}
11183

11284
cmake --build ${et_build_dir} -j$(nproc) --target install --config ${build_type} --
11385

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2025 Arm Limited and/or its affiliates.
2+
#
3+
# This source code is licensed under the BSD-style license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}")
7+
set_overridable_option(EXECUTORCH_BUILD_EXECUTOR_RUNNER OFF)
8+
set_overridable_option(EXECUTORCH_BUILD_ARM_BAREMETAL ON)
9+
set_overridable_option(EXECUTORCH_BUILD_KERNELS_QUANTIZED ON)
10+
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL ON)
11+
set_overridable_option(EXECUTORCH_BUILD_CORTEX_M ON)
12+
set_overridable_option(EXECUTORCH_ENABLE_LOGGING ON)
13+
14+
define_overridable_option(
15+
EXECUTORCH_BUILD_ARM_ETDUMP "Build etdump support for Arm" BOOL OFF
16+
)
17+
18+
if("${EXECUTORCH_BUILD_ARM_ETDUMP}")
19+
set(EXECUTORCH_BUILD_DEVTOOLS ON)
20+
set(EXECUTORCH_ENABLE_EVENT_TRACER ON)
21+
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER OFF)
22+
set(FLATCC_ALLOW_WERROR OFF)
23+
else()
24+
set(EXECUTORCH_ENABLE_EVENT_TRACER OFF)
25+
endif()

0 commit comments

Comments
 (0)