@@ -17,6 +17,9 @@ et_dir=$(realpath $script_dir/../..)
1717ARCH=" $( uname -m) "
1818OS=" $( uname -s) "
1919
20+ # Figure out if setup.sh was called or sourced and save it into "is_script_sourced"
21+ (return 0 2> /dev/null) && is_script_sourced=1 || is_script_sourced=0
22+
2023if [[ " ${ARCH} " == " x86_64" ]]; then
2124 # FVPs
2225 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"
5962vela_repo_url=" https://gitlab.arm.com/artificial-intelligence/ethos-u/ethos-u-vela"
6063vela_rev=" 425541302c7e4b6fbeca7c0061286b131ee507c3"
6164
62- # #######
63- # ## Optional user args
64- # #######
65- root_dir=${2:- " ${script_dir} /ethos-u-scratch" }
66- mkdir -p ${root_dir}
67- root_dir=$( realpath ${root_dir} )
68- setup_path_script=" ${root_dir} /setup_path.sh"
69-
70-
7165# #######
7266# ## Functions
7367# #######
68+ function setup_root_dir() {
69+ # Handle a different root_dir set by the user as argument to the
70+ # script. This can only happen if the script is being executed and
71+ # not sourced.
72+ root_dir=" ${script_dir} /ethos-u-scratch"
73+ if [[ $is_script_sourced -eq 0 ]]; then
74+ root_dir=${2:- " ${script_dir} /ethos-u-scratch" }
75+ fi
76+ mkdir -p ${root_dir}
77+ root_dir=$( realpath ${root_dir} )
78+ setup_path_script=" ${root_dir} /setup_path.sh"
79+ }
7480
75- function setup_fvp() {
76-
81+ function check_fvp_eula () {
7782 # Mandatory user arg --i-agree-to-the-contained-eula
7883 eula_acceptance=" ${1:- ' .' } "
7984 eula_acceptance_by_variable=" ${ARM_FVP_INSTALL_I_AGREE_TO_THE_CONTAINED_EULA:- False} "
8085
8186 if [[ " ${eula_acceptance} " != " --i-agree-to-the-contained-eula" ]]; then
8287 if [[ ${eula_acceptance_by_variable} != " True" ]]; then
83- echo " Must pass first positional argument '--i-agree-to-the-contained-eula' to agree to EULA associated with downloading the FVP. Exiting!"
84- exit 1
88+ echo " Must pass first positional argument '--i-agree-to-the-contained-eula' to agree to EULA associated with downloading the FVP."
89+ echo " Alternativly set environment variable ARM_FVP_INSTALL_I_AGREE_TO_THE_CONTAINED_EULA=True."
90+ echo " Exiting!"
91+ exit 1
8592 else
86- echo " Arm EULA for FVP agreed to with ARM_FVP_INSTALL_I_AGREE_TO_THE_CONTAINED_EULA=True environment variable"
93+ echo " Arm EULA for FVP agreed to with ARM_FVP_INSTALL_I_AGREE_TO_THE_CONTAINED_EULA=True environment variable"
8794 fi
8895 else
8996 shift ; # drop this arg
9097 fi
98+ }
99+
100+ function setup_fvp() {
101+ # check EULA, forward argument
102+ check_fvp_eula ${1:- ' .' }
103+
91104 if [[ " ${OS} " != " Linux" ]]; then
92105 # Check if FVP is callable
93106 if command -v FVP_Corstone_SSE-300_Ethos-U55 & > /dev/null; then
@@ -181,14 +194,7 @@ function create_setup_path(){
181194 echo " hash FVP_Corstone_SSE-320" >> ${setup_path_script}
182195}
183196
184- # #######
185- # ## main
186- # #######
187- # Only run this if script is executed, not if it is sourced
188- (return 0 2> /dev/null) && is_script_sourced=1 || is_script_sourced=0
189- if [[ $is_script_sourced -eq 0 ]]
190- then
191- set -e
197+ function check_platform_support() {
192198 if [[ " ${ARCH} " != " x86_64" ]] && [[ " ${ARCH} " != " aarch64" ]] \
193199 && [[ " ${ARCH} " != " arm64" ]]; then
194200 echo " [main] Error: only x86-64 & aarch64 architecture is supported for now!"
@@ -201,10 +207,23 @@ if [[ $is_script_sourced -eq 0 ]]
201207 echo " Supplied args: $* "
202208 exit 1
203209 fi
210+ }
211+
212+ # #######
213+ # ## main
214+ # #######
215+
216+ # script is not sourced! Lets run "main"
217+ if [[ $is_script_sourced -eq 0 ]]
218+ then
219+ set -e
220+
221+ check_platform_support
204222
205223 cd " ${script_dir} "
206224
207225 # Setup the root dir
226+ setup_root_dir
208227 cd " ${root_dir} "
209228 echo " [main] Using root dir ${root_dir} "
210229
0 commit comments