diff --git a/backends/arm/scripts/build_executor_runner.sh b/backends/arm/scripts/build_executor_runner.sh index 9e2f3954c53..974c5ca1ff7 100755 --- a/backends/arm/scripts/build_executor_runner.sh +++ b/backends/arm/scripts/build_executor_runner.sh @@ -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." @@ -46,6 +46,7 @@ help() { echo " --output= Output folder Default: /_.pte" echo " --et_build_root= Build output root folder to use, defaults to ${et_build_root}" echo " --ethosu_tools_dir= Path to your Ethos-U tools dir if you not using default: ${ethosu_tools_dir}" + echo " --toolchain= Toolchain can be specified (e.g. bare metal as arm-none-eabi-gcc or zephyr as arm-zephyr-eabi-gcc" exit 0 } @@ -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} ]] \ @@ -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 @@ -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} \ @@ -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" diff --git a/backends/arm/scripts/build_executorch.sh b/backends/arm/scripts/build_executorch.sh index cb2b48a644d..c66eeea4ca9 100755 --- a/backends/arm/scripts/build_executorch.sh +++ b/backends/arm/scripts/build_executorch.sh @@ -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." @@ -30,6 +29,7 @@ help() { echo " --build_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 can be specified (e.g. bare metal as arm-none-eabi-gcc or zephyr as arm-zephyr-eabi-gcc" exit 0 } @@ -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} ]] \ diff --git a/backends/arm/scripts/build_portable_kernels.sh b/backends/arm/scripts/build_portable_kernels.sh index 2719fbb603e..0d06b59dd03 100755 --- a/backends/arm/scripts/build_portable_kernels.sh +++ b/backends/arm/scripts/build_portable_kernels.sh @@ -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." @@ -29,6 +28,7 @@ help() { echo " --et_build_root= Build output root folder to use, defaults to ${et_build_root}" echo " --build_type= Build with Release, Debug or RelWithDebInfo, default is ${build_type}" echo " --portable_kernels= Comma separated list of portable (non delagated) kernels to include Default: ${portable_kernels}" + echo " --toolchain= Toolchain can be specified (e.g. bare metal as arm-none-eabi-gcc or zephyr as arm-zephyr-eabi-gcc" exit 0 } @@ -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} ]] \ diff --git a/examples/arm/run.sh b/examples/arm/run.sh index 797739e3cd2..389a69bc0c6 100755 --- a/examples/arm/run.sh +++ b/examples/arm/run.sh @@ -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]" @@ -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 ;; @@ -94,7 +96,16 @@ done # Default Ethos-u tool folder override with --scratch-dir= 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." @@ -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; } @@ -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 @@ -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"