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
55 changes: 39 additions & 16 deletions examples/arm/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ system_config=""
memory_mode=""
et_build_root="${et_root_dir}/arm_test"
ethos_u_scratch_dir=${script_dir}/ethos-u-scratch
scratch_dir_set=false

function help() {
echo "Usage: $(basename $0) [options]"
Expand Down Expand Up @@ -81,7 +82,7 @@ for arg in "$@"; do
--system_config=*) system_config="${arg#*=}";;
--memory_mode=*) memory_mode="${arg#*=}";;
--et_build_root=*) et_build_root="${arg#*=}";;
--scratch-dir=*) ethos_u_scratch_dir="${arg#*=}";;
--scratch-dir=*) ethos_u_scratch_dir="${arg#*=}" ; scratch_dir_set=true ;;
*)
;;
esac
Expand Down Expand Up @@ -113,25 +114,47 @@ then
fi
fi

#######
### Main
#######
# Source the tools
# This should be prepared by the setup.sh
[[ -f ${setup_path_script} ]] \
|| { echo "Missing ${setup_path_script}. ${_setup_msg}"; exit 1; }
function check_setup () {
# basic checks that setup.sh did everything needed before we get started

source ${setup_path_script}
# check if setup_path_script was created, if so source it
if [[ -f ${setup_path_script} ]]; then
source $setup_path_script
else
echo "Could not find ${setup_path_script} file, ${_setup_msg}"
return 1
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; }

# basic checks before we get started
hash arm-none-eabi-gcc \
|| { echo "Could not find arm baremetal toolchain on PATH, ${_setup_msg}"; exit 1; }
[[ -f ${toolchain_cmake} ]] \
|| { echo "Could not find ${toolchain_cmake} file, ${_setup_msg}"; return 1; }

[[ -f ${toolchain_cmake} ]] \
|| { echo "Could not find ${toolchain_cmake} file, ${_setup_msg}"; exit 1; }
[[ -f ${et_root_dir}/CMakeLists.txt ]] \
|| { echo "Executorch repo doesn't contain CMakeLists.txt file at root level"; return 1; }

[[ -f ${et_root_dir}/CMakeLists.txt ]] \
|| { echo "Executorch repo doesn't contain CMakeLists.txt file at root level"; exit 1; }
return 0
}

#######
### Main
#######
if ! check_setup; then
if [ "$scratch_dir_set" = false ] ; then
# check setup failed, no scratchdir given as parameter. trying to run setup.sh
if ${script_dir}/setup.sh; then
# and recheck setup. If this fails exit.
if ! check_setup; then
exit 1
fi
else
# setup.sh failed, it should print why
exit 1
fi
fi
fi

# Build executorch libraries
cd $et_root_dir
Expand Down
63 changes: 41 additions & 22 deletions examples/arm/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ et_dir=$(realpath $script_dir/../..)
ARCH="$(uname -m)"
OS="$(uname -s)"

# Figure out if setup.sh was called or sourced and save it into "is_script_sourced"
(return 0 2>/dev/null) && is_script_sourced=1 || is_script_sourced=0

if [[ "${ARCH}" == "x86_64" ]]; then
# FVPs
corstone300_url="https://developer.arm.com/-/media/Arm%20Developer%20Community/Downloads/OSS/FVP/Corstone-300/FVP_Corstone_SSE-300_11.22_20_Linux64.tgz?rev=018659bd574f4e7b95fa647e7836ccf4&hash=22A79103C6FA5FFA7AFF3BE0447F3FF9"
Expand Down Expand Up @@ -59,35 +62,45 @@ fi
vela_repo_url="https://gitlab.arm.com/artificial-intelligence/ethos-u/ethos-u-vela"
vela_rev="425541302c7e4b6fbeca7c0061286b131ee507c3"

########
### Optional user args
########
root_dir=${2:-"${script_dir}/ethos-u-scratch"}
mkdir -p ${root_dir}
root_dir=$(realpath ${root_dir})
setup_path_script="${root_dir}/setup_path.sh"


########
### Functions
########
function setup_root_dir() {
# Handle a different root_dir set by the user as argument to the
# script. This can only happen if the script is being executed and
# not sourced.
root_dir="${script_dir}/ethos-u-scratch"
if [[ $is_script_sourced -eq 0 ]]; then
root_dir=${2:-"${script_dir}/ethos-u-scratch"}
fi
mkdir -p ${root_dir}
root_dir=$(realpath ${root_dir})
setup_path_script="${root_dir}/setup_path.sh"
}

function setup_fvp() {

function check_fvp_eula () {
# Mandatory user arg --i-agree-to-the-contained-eula
eula_acceptance="${1:-'.'}"
eula_acceptance_by_variable="${ARM_FVP_INSTALL_I_AGREE_TO_THE_CONTAINED_EULA:-False}"

if [[ "${eula_acceptance}" != "--i-agree-to-the-contained-eula" ]]; then
if [[ ${eula_acceptance_by_variable} != "True" ]]; then
echo "Must pass first positional argument '--i-agree-to-the-contained-eula' to agree to EULA associated with downloading the FVP. Exiting!"
exit 1
echo "Must pass first positional argument '--i-agree-to-the-contained-eula' to agree to EULA associated with downloading the FVP."
echo "Alternativly set environment variable ARM_FVP_INSTALL_I_AGREE_TO_THE_CONTAINED_EULA=True."
echo "Exiting!"
exit 1
else
echo "Arm EULA for FVP agreed to with ARM_FVP_INSTALL_I_AGREE_TO_THE_CONTAINED_EULA=True environment variable"
echo "Arm EULA for FVP agreed to with ARM_FVP_INSTALL_I_AGREE_TO_THE_CONTAINED_EULA=True environment variable"
fi
else
shift; # drop this arg
fi
}

function setup_fvp() {
# check EULA, forward argument
check_fvp_eula ${1:-'.'}

if [[ "${OS}" != "Linux" ]]; then
# Check if FVP is callable
if command -v FVP_Corstone_SSE-300_Ethos-U55 &> /dev/null; then
Expand Down Expand Up @@ -181,14 +194,7 @@ function create_setup_path(){
echo "hash FVP_Corstone_SSE-320" >> ${setup_path_script}
}

########
### main
########
# Only run this if script is executed, not if it is sourced
(return 0 2>/dev/null) && is_script_sourced=1 || is_script_sourced=0
if [[ $is_script_sourced -eq 0 ]]
then
set -e
function check_platform_support() {
if [[ "${ARCH}" != "x86_64" ]] && [[ "${ARCH}" != "aarch64" ]] \
&& [[ "${ARCH}" != "arm64" ]]; then
echo "[main] Error: only x86-64 & aarch64 architecture is supported for now!"
Expand All @@ -201,10 +207,23 @@ if [[ $is_script_sourced -eq 0 ]]
echo "Supplied args: $*"
exit 1
fi
}

########
### main
########

# script is not sourced! Lets run "main"
if [[ $is_script_sourced -eq 0 ]]
then
set -e

check_platform_support

cd "${script_dir}"

# Setup the root dir
setup_root_dir
cd "${root_dir}"
echo "[main] Using root dir ${root_dir}"

Expand Down
Loading