@@ -17,6 +17,9 @@ et_dir=$(realpath $script_dir/../..)
17
17
ARCH=" $( uname -m) "
18
18
OS=" $( uname -s) "
19
19
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
+
20
23
if [[ " ${ARCH} " == " x86_64" ]]; then
21
24
# FVPs
22
25
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"
59
62
vela_repo_url=" https://gitlab.arm.com/artificial-intelligence/ethos-u/ethos-u-vela"
60
63
vela_rev=" 425541302c7e4b6fbeca7c0061286b131ee507c3"
61
64
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
-
71
65
# #######
72
66
# ## Functions
73
67
# #######
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
+ }
74
80
75
- function setup_fvp() {
76
-
81
+ function check_fvp_eula () {
77
82
# Mandatory user arg --i-agree-to-the-contained-eula
78
83
eula_acceptance=" ${1:- ' .' } "
79
84
eula_acceptance_by_variable=" ${ARM_FVP_INSTALL_I_AGREE_TO_THE_CONTAINED_EULA:- False} "
80
85
81
86
if [[ " ${eula_acceptance} " != " --i-agree-to-the-contained-eula" ]]; then
82
87
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
85
92
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"
87
94
fi
88
95
else
89
96
shift ; # drop this arg
90
97
fi
98
+ }
99
+
100
+ function setup_fvp() {
101
+ # check EULA, forward argument
102
+ check_fvp_eula ${1:- ' .' }
103
+
91
104
if [[ " ${OS} " != " Linux" ]]; then
92
105
# Check if FVP is callable
93
106
if command -v FVP_Corstone_SSE-300_Ethos-U55 & > /dev/null; then
@@ -181,14 +194,7 @@ function create_setup_path(){
181
194
echo " hash FVP_Corstone_SSE-320" >> ${setup_path_script}
182
195
}
183
196
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() {
192
198
if [[ " ${ARCH} " != " x86_64" ]] && [[ " ${ARCH} " != " aarch64" ]] \
193
199
&& [[ " ${ARCH} " != " arm64" ]]; then
194
200
echo " [main] Error: only x86-64 & aarch64 architecture is supported for now!"
@@ -201,10 +207,23 @@ if [[ $is_script_sourced -eq 0 ]]
201
207
echo " Supplied args: $* "
202
208
exit 1
203
209
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
204
222
205
223
cd " ${script_dir} "
206
224
207
225
# Setup the root dir
226
+ setup_root_dir
208
227
cd " ${root_dir} "
209
228
echo " [main] Using root dir ${root_dir} "
210
229
0 commit comments