xref: /aosp_15_r20/external/executorch/backends/arm/test/setup_testing.sh (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1#!/usr/bin/env bash
2# Copyright 2024 Arm Limited and/or its affiliates.
3# All rights reserved.
4#
5# This source code is licensed under the BSD-style license found in the
6# LICENSE file in the root directory of this source tree.
7
8set -eu
9
10script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
11et_root_dir=$(cd ${script_dir}/../../.. && pwd)
12ethos_u_root_dir=${et_root_dir}/examples/arm/ethos-u-scratch/ethos-u
13
14toolchain_cmake=${et_root_dir}/examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake
15et_build_dir=${et_root_dir}/cmake-out
16build_root_test_dir=${et_build_dir}/arm_semihosting_executor_runner
17fvp_model=FVP_Corstone_SSE-300_Ethos-U55
18
19# Build Arm Baremetal executor_runner in semihosting mode.
20# Put in backends/arm/test/res to be used by unit tests.
21function build_semihosting_executorch_runner() {
22    target_board=$1
23    build_test_dir=${build_root_test_dir}_${target_board}
24    echo "[${FUNCNAME[0]}] Configuring ${target_board}"
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          -DTARGET_BOARD=${target_board}                     \
40          -DSEMIHOSTING=ON                                   \
41          -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${build_test_dir} \
42          -B ${build_test_dir}                               \
43          -DETHOS_SDK_PATH:PATH=${ethos_u_root_dir}          \
44          -DET_DIR_PATH:PATH=${et_root_dir}                  \
45          -DET_BUILD_DIR_PATH:PATH=${et_build_dir}           \
46          -DPYTHON_EXECUTABLE=$(which python3)
47
48    echo "[${FUNCNAME[0]}] Configured CMAKE"
49
50    n=$(nproc)
51    cmake --build ${build_test_dir} -- -j"$((n - 5))" arm_executor_runner
52    echo "[${FUNCNAME[0]}] Generated baremetal elf file: with semihosting enabled"
53    find ${build_test_dir} -name "arm_executor_runner"
54}
55
56build_semihosting_executorch_runner corstone-300
57
58build_semihosting_executorch_runner corstone-320
59