Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions backends/arm/scripts/build_executor_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set -eu
script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
et_root_dir=$(cd ${script_dir}/../../.. && pwd)
et_root_dir=$(realpath ${et_root_dir})
toolchain_cmake=${et_root_dir}/examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake
toolchain=arm-none-eabi-gcc
setup_path_script=${et_root_dir}/examples/arm/ethos-u-scratch/setup_path.sh
_setup_msg="please refer to ${et_root_dir}/examples/arm/setup.sh to properly install necessary tools."

Expand Down Expand Up @@ -46,6 +46,7 @@ help() {
echo " --output=<FOLDER> Output folder Default: <MODEL>/<MODEL>_<TARGET INFO>.pte"
echo " --et_build_root=<FOLDER> Build output root folder to use, defaults to ${et_build_root}"
echo " --ethosu_tools_dir=<FOLDER> Path to your Ethos-U tools dir if you not using default: ${ethosu_tools_dir}"
echo " --toolchain=<TOOLCHAIN> Toolchain can be specified (e.g. bare metal as arm-none-eabi-gcc or zephyr as arm-zephyr-eabi-gcc"
exit 0
}

Expand All @@ -63,11 +64,23 @@ for arg in "$@"; do
--output=*) output_folder="${arg#*=}" ; output_folder_set=true ;;
--et_build_root=*) et_build_root="${arg#*=}";;
--ethosu_tools_dir=*) ethosu_tools_dir="${arg#*=}";;
--toolchain=*) toolchain="${arg#*=}";;
*)
;;
esac
done

if [[ ${toolchain} == "arm-none-eabi-gcc" ]]; then
toolchain_cmake=${et_root_dir}/examples/arm/ethos-u-setup/${toolchain}.cmake
elif [[ ${toolchain} == "arm-zephyr-eabi-gcc" ]]; then
toolchain_cmake=${et_root_dir}/examples/zephyr/x86_64-linux-arm-zephyr-eabi-gcc.cmake
else
echo "Error: Invalid toolchain selection, provided: ${tolchain}"
echo " Valid options are {arm-none-eabi-gcc, arm-zephyr-eabi-gcc}"
exit 1;
fi
toolchain_cmake=$(realpath ${toolchain_cmake})

# Source the tools
# This should be prepared by the setup.sh
[[ -f ${setup_path_script} ]] \
Expand Down Expand Up @@ -116,7 +129,7 @@ else
target_cpu=cortex-m85
fi
echo "--------------------------------------------------------------------------------"
echo "Build Arm Baremetal executor_runner for ${target} with ${pte_file} using ${system_config} ${memory_mode} ${extra_build_flags} to '${output_folder}/cmake-out'"
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'"
echo "--------------------------------------------------------------------------------"

cd ${et_root_dir}/examples/arm/executor_runner
Expand All @@ -130,7 +143,6 @@ if [ "$build_with_etdump" = true ] ; then
fi

echo "Building with BundleIO/etdump/extra flags: ${build_bundleio_flags} ${build_with_etdump_flags} ${extra_build_flags}"

cmake \
-DCMAKE_BUILD_TYPE=${build_type} \
-DCMAKE_TOOLCHAIN_FILE=${toolchain_cmake} \
Expand All @@ -152,8 +164,8 @@ echo "[${BASH_SOURCE[0]}] Configured CMAKE"

cmake --build ${output_folder}/cmake-out -j$(nproc) -- arm_executor_runner

echo "[${BASH_SOURCE[0]}] Generated baremetal elf file:"
echo "[${BASH_SOURCE[0]}] Generated ${toolchain} elf file:"
find ${output_folder}/cmake-out -name "arm_executor_runner"
echo "executable_text: $(find ${output_folder}/cmake-out -name arm_executor_runner -exec arm-none-eabi-size {} \; | grep -v filename | awk '{print $1}') bytes"
echo "executable_data: $(find ${output_folder}/cmake-out -name arm_executor_runner -exec arm-none-eabi-size {} \; | grep -v filename | awk '{print $2}') bytes"
echo "executable_bss: $(find ${output_folder}/cmake-out -name arm_executor_runner -exec arm-none-eabi-size {} \; | grep -v filename | awk '{print $3}') bytes"
echo "executable_text: $(find ${output_folder}/cmake-out -name arm_executor_runner -exec ${toolchain/-gcc/-size} {} \; | grep -v filename | awk '{print $1}') bytes"
echo "executable_data: $(find ${output_folder}/cmake-out -name arm_executor_runner -exec ${toolchain/-gcc/-size} {} \; | grep -v filename | awk '{print $2}') bytes"
echo "executable_bss: $(find ${output_folder}/cmake-out -name arm_executor_runner -exec ${toolchain/-gcc/-size} {} \; | grep -v filename | awk '{print $3}') bytes"
16 changes: 14 additions & 2 deletions backends/arm/scripts/build_executorch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ set -eu
script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
et_root_dir=$(cd ${script_dir}/../../.. && pwd)
et_root_dir=$(realpath ${et_root_dir})
toolchain_cmake=${script_dir}/../../../examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake
toolchain_cmake=$(realpath ${toolchain_cmake})
toolchain=arm-none-eabi-gcc
setup_path_script=${et_root_dir}/examples/arm/ethos-u-scratch/setup_path.sh
_setup_msg="please refer to ${et_root_dir}/examples/arm/setup.sh to properly install necessary tools."

Expand All @@ -30,6 +29,7 @@ help() {
echo " --build_type=<TYPE> Build with Release, Debug or RelWithDebInfo, default is ${build_type}"
echo " --devtools Build Devtools libs"
echo " --etdump Adds Devtools etdump support to track timing, etdump area will be base64 encoded in the log"
echo " --toolchain=<TOOLCHAIN> Toolchain can be specified (e.g. bare metal as arm-none-eabi-gcc or zephyr as arm-zephyr-eabi-gcc"
exit 0
}

Expand All @@ -40,11 +40,23 @@ for arg in "$@"; do
--build_type=*) build_type="${arg#*=}";;
--devtools) build_devtools=true ;;
--etdump) build_with_etdump=true ;;
--toolchain=*) toolchain="${arg#*=}";;
*)
;;
esac
done

if [[ ${toolchain} == "arm-none-eabi-gcc" ]]; then
toolchain_cmake=${et_root_dir}/examples/arm/ethos-u-setup/${toolchain}.cmake
elif [[ ${toolchain} == "arm-zephyr-eabi-gcc" ]]; then
toolchain_cmake=${et_root_dir}/examples/zephyr/x86_64-linux-arm-zephyr-eabi-gcc.cmake
else
echo "Error: Invalid toolchain selection, provided: ${tolchain}"
echo " Valid options are {arm-none-eabi-gcc, arm-zephyr-eabi-gcc}"
exit 1;
fi
toolchain_cmake=$(realpath ${toolchain_cmake})

# Source the tools
# This should be prepared by the setup.sh
[[ -f ${setup_path_script} ]] \
Expand Down
16 changes: 14 additions & 2 deletions backends/arm/scripts/build_portable_kernels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ set -eu
script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
et_root_dir=$(cd ${script_dir}/../../.. && pwd)
et_root_dir=$(realpath ${et_root_dir})
toolchain_cmake=${script_dir}/../../../examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake
toolchain_cmake=$(realpath ${toolchain_cmake})
toolchain=arm-none-eabi-gcc
setup_path_script=${et_root_dir}/examples/arm/ethos-u-scratch/setup_path.sh
_setup_msg="please refer to ${et_root_dir}/examples/arm/setup.sh to properly install necessary tools."

Expand All @@ -29,6 +28,7 @@ help() {
echo " --et_build_root=<FOLDER> Build output root folder to use, defaults to ${et_build_root}"
echo " --build_type=<TYPE> Build with Release, Debug or RelWithDebInfo, default is ${build_type}"
echo " --portable_kernels=<OPS> Comma separated list of portable (non delagated) kernels to include Default: ${portable_kernels}"
echo " --toolchain=<TOOLCHAIN> Toolchain can be specified (e.g. bare metal as arm-none-eabi-gcc or zephyr as arm-zephyr-eabi-gcc"
exit 0
}

Expand All @@ -38,11 +38,23 @@ for arg in "$@"; do
--et_build_root=*) et_build_root="${arg#*=}";;
--build_type=*) build_type="${arg#*=}";;
--portable_kernels=*) portable_kernels="${arg#*=}";;
--toolchain=*) toolchain="${arg#*=}";;
*)
;;
esac
done

if [[ ${toolchain} == "arm-none-eabi-gcc" ]]; then
toolchain_cmake=${et_root_dir}/examples/arm/ethos-u-setup/${toolchain}.cmake
elif [[ ${toolchain} == "arm-zephyr-eabi-gcc" ]]; then
toolchain_cmake=${et_root_dir}/examples/zephyr/x86_64-linux-arm-zephyr-eabi-gcc.cmake
else
echo "Error: Invalid toolchain selection, provided: ${tolchain}"
echo " Valid options are {arm-none-eabi-gcc, arm-zephyr-eabi-gcc}"
exit 1;
fi
toolchain_cmake=$(realpath ${toolchain_cmake})

# Source the tools
# This should be prepared by the setup.sh
[[ -f ${setup_path_script} ]] \
Expand Down
23 changes: 17 additions & 6 deletions examples/arm/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ memory_mode=""
et_build_root="${et_root_dir}/arm_test"
ethos_u_scratch_dir=${script_dir}/ethos-u-scratch
scratch_dir_set=false
toolchain=arm-none-eabi-gcc

function help() {
echo "Usage: $(basename $0) [options]"
Expand Down Expand Up @@ -75,6 +76,7 @@ for arg in "$@"; do
--no_quantize) aot_arm_compiler_flag_quantize="" ;;
--portable_kernels=*) portable_kernels="${arg#*=}";;
--target=*) target="${arg#*=}";;
--toolchain=*) toolchain="${arg#*=}";;
--output=*) output_folder="${arg#*=}" ; output_folder_set=true ;;
--bundleio) bundleio=true ;;
--etdump) build_with_etdump=true ;;
Expand All @@ -94,7 +96,16 @@ done
# Default Ethos-u tool folder override with --scratch-dir=<FOLDER>
ethos_u_scratch_dir=$(realpath ${ethos_u_scratch_dir})
setup_path_script=${ethos_u_scratch_dir}/setup_path.sh
toolchain_cmake=${script_dir}/ethos-u-setup/arm-none-eabi-gcc.cmake
if [[ ${toolchain} == "arm-none-eabi-gcc" ]]; then
toolchain_cmake=${et_root_dir}/examples/arm/ethos-u-setup/${toolchain}.cmake
elif [[ ${toolchain} == "arm-zephyr-eabi-gcc" ]]; then
toolchain_cmake=${et_root_dir}/examples/zephyr/x86_64-linux-arm-zephyr-eabi-gcc.cmake
else
echo "Error: Invalid toolchain selection, provided: ${tolchain}"
echo " Valid options are {arm-none-eabi-gcc, arm-zephyr-eabi-gcc}"
exit 1;
fi
toolchain_cmake=$(realpath ${toolchain_cmake})
_setup_msg="please refer to ${script_dir}/setup.sh to properly install necessary tools."


Expand Down Expand Up @@ -134,8 +145,8 @@ function check_setup () {
fi

# If setup_path_script was correct all these checks should now pass
hash arm-none-eabi-gcc \
|| { echo "Could not find arm baremetal toolchain on PATH, ${_setup_msg}"; return 1; }
hash ${toolchain} \
|| { echo "Could not find ${toolchain} toolchain on PATH, ${_setup_msg}"; return 1; }

[[ -f ${toolchain_cmake} ]] \
|| { echo "Could not find ${toolchain_cmake} file, ${_setup_msg}"; return 1; }
Expand Down Expand Up @@ -180,8 +191,8 @@ if [ "$bundleio" = true ] ; then
et_dump_flag="--etdump"
fi

backends/arm/scripts/build_executorch.sh --et_build_root="${et_build_root}" --build_type=$build_type $devtools_flag
backends/arm/scripts/build_portable_kernels.sh --et_build_root="${et_build_root}" --build_type=$build_type --portable_kernels=$portable_kernels
backends/arm/scripts/build_executorch.sh --et_build_root="${et_build_root}" --build_type=$build_type $devtools_flag --toolchain="${toolchain}"
backends/arm/scripts/build_portable_kernels.sh --et_build_root="${et_build_root}" --build_type=$build_type --portable_kernels=$portable_kernels --toolchain="${toolchain}"

if [[ -z "$model_name" ]]; then
# the test models run, and whether to delegate
Expand Down Expand Up @@ -265,7 +276,7 @@ for i in "${!test_model[@]}"; do
else
set -x
# Rebuild the application as the pte is imported as a header/c array
backends/arm/scripts/build_executor_runner.sh --et_build_root="${et_build_root}" --pte="${pte_file}" --build_type=${build_type} --target=${target} --system_config=${system_config} --memory_mode=${memory_mode} ${bundleio_flag} ${et_dump_flag} --extra_build_flags="${extra_build_flags}" --ethosu_tools_dir="${ethos_u_scratch_dir}"
backends/arm/scripts/build_executor_runner.sh --et_build_root="${et_build_root}" --pte="${pte_file}" --build_type=${build_type} --target=${target} --system_config=${system_config} --memory_mode=${memory_mode} ${bundleio_flag} ${et_dump_flag} --extra_build_flags="${extra_build_flags}" --ethosu_tools_dir="${ethos_u_scratch_dir}" --toolchain="${toolchain}"
if [ "$build_only" = false ] ; then
# Execute the executor_runner on FVP Simulator
elf_file="${output_folder}/${elf_folder}/cmake-out/arm_executor_runner"
Expand Down
Loading