@@ -16,6 +16,12 @@ script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
16
16
et_dir=$( realpath $script_dir /../..)
17
17
ARCH=" $( uname -m) "
18
18
OS=" $( uname -s) "
19
+ root_dir=" ${script_dir} /ethos-u-scratch"
20
+ eula_acceptance=0
21
+ skip_toolchain_setup=0
22
+ skip_fvp_setup=0
23
+ skip_vela_setup=0
24
+
19
25
20
26
# Figure out if setup.sh was called or sourced and save it into "is_script_sourced"
21
27
(return 0 2> /dev/null) && is_script_sourced=1 || is_script_sourced=0
@@ -65,41 +71,81 @@ vela_rev="8cac2b9a7204b57125a8718049519b091a98846c"
65
71
# #######
66
72
# ## Functions
67
73
# #######
74
+
75
+ function print_usage() {
76
+ echo " Usage: $( basename $0 ) <--i-agree-to-the-contained-eula> [--root-dir path-to-a-scratch-dir] [--skip-fvp-setup] [--skip-toolchain-setup] [--skip-vela-setup]"
77
+ echo " Supplied args: $* "
78
+ }
79
+
80
+ function check_options() {
81
+ while [[ " ${# } " -gt 0 ]]; do
82
+ case " $1 " in
83
+ --i-agree-to-the-contained-eula)
84
+ eula_acceptance=1
85
+ shift
86
+ ;;
87
+ --root-dir)
88
+ # Only change default root dir if the script is being executed and not sourced.
89
+ if [[ $is_script_sourced -eq 0 ]]; then
90
+ root_dir=${2:- " ${root_dir} " }
91
+ fi
92
+
93
+ if [[ $# -ge 2 ]]; then
94
+ shift 2
95
+ else
96
+ print_usage " $@ "
97
+ exit 1
98
+ fi
99
+ ;;
100
+ --skip-toolchain-setup)
101
+ skip_toolchain_setup=1
102
+ shift
103
+ ;;
104
+ --skip-fvp-setup)
105
+ skip_fvp_setup=1
106
+ shift
107
+ ;;
108
+ --skip-vela-setup)
109
+ skip_vela_setup=1
110
+ shift
111
+ ;;
112
+ --help)
113
+ print_usage " $@ "
114
+ exit 0
115
+ ;;
116
+ * )
117
+ print_usage " $@ "
118
+ exit 1
119
+ ;;
120
+ esac
121
+ done
122
+ }
123
+
68
124
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
125
mkdir -p ${root_dir}
77
126
root_dir=$( realpath ${root_dir} )
78
127
setup_path_script=" ${root_dir} /setup_path.sh"
79
128
}
80
129
81
130
function check_fvp_eula () {
82
131
# Mandatory user arg --i-agree-to-the-contained-eula
83
- eula_acceptance=" ${1:- ' .' } "
84
132
eula_acceptance_by_variable=" ${ARM_FVP_INSTALL_I_AGREE_TO_THE_CONTAINED_EULA:- False} "
85
133
86
- if [[ " ${eula_acceptance} " != " --i-agree-to-the-contained-eula " ]]; then
134
+ if [[ " ${eula_acceptance} " -eq 0 ]]; then
87
135
if [[ ${eula_acceptance_by_variable} != " True" ]]; then
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!"
136
+ echo " Must pass argument '--i-agree-to-the-contained-eula' to agree to EULA associated with downloading the FVP."
137
+ echo " Alternativly set environment variable ARM_FVP_INSTALL_I_AGREE_TO_THE_CONTAINED_EULA=True."
138
+ echo " Exiting!"
91
139
exit 1
92
140
else
93
141
echo " Arm EULA for FVP agreed to with ARM_FVP_INSTALL_I_AGREE_TO_THE_CONTAINED_EULA=True environment variable"
94
142
fi
95
- else
96
- shift ; # drop this arg
97
143
fi
98
144
}
99
145
100
146
function setup_fvp() {
101
147
# check EULA, forward argument
102
- check_fvp_eula ${1 :- ' . ' }
148
+ check_fvp_eula
103
149
104
150
if [[ " ${OS} " != " Linux" ]]; then
105
151
# Check if FVP is callable
@@ -169,81 +215,91 @@ function setup_vela() {
169
215
pip install ethos-u-vela@git+${vela_repo_url} @${vela_rev}
170
216
}
171
217
172
- function setup_path() {
173
- echo $setup_path_script
174
- }
175
-
176
218
function create_setup_path(){
177
- echo " " > " ${setup_path_script} "
178
- fvps=(" corstone300" " corstone320" )
179
- for fvp in " ${fvps[@]} " ; do
180
- model_dir_variable=${fvp} _model_dir
181
- fvp_model_dir=${! model_dir_variable}
182
- fvp_bin_path=" ${root_dir} /FVP-${fvp} /models/${fvp_model_dir} "
183
- echo " export PATH=\$ {PATH}:${fvp_bin_path} " >> ${setup_path_script}
184
- done
219
+ cd " ${root_dir} "
185
220
186
- # Fixup for Corstone-320 python dependency
187
- echo " export LD_LIBRARY_PATH=${root_dir} /FVP-corstone320/python/lib/" >> ${setup_path_script}
221
+ echo " " > " ${setup_path_script} "
188
222
189
- toolchain_bin_path=" $( cd ${toolchain_dir} /bin && pwd) "
190
- echo " export PATH=\$ {PATH}:${toolchain_bin_path} " >> ${setup_path_script}
223
+ if [[ " ${skip_fvp_setup} " -eq 0 ]]; then
224
+ fvps=(" corstone300" " corstone320" )
225
+ for fvp in " ${fvps[@]} " ; do
226
+ model_dir_variable=${fvp} _model_dir
227
+ fvp_model_dir=${! model_dir_variable}
228
+ fvp_bin_path=" ${root_dir} /FVP-${fvp} /models/${fvp_model_dir} "
229
+ echo " export PATH=\$ {PATH}:${fvp_bin_path} " >> ${setup_path_script}
230
+ done
231
+
232
+ # Fixup for Corstone-320 python dependency
233
+ echo " export LD_LIBRARY_PATH=${root_dir} /FVP-corstone320/python/lib/" >> ${setup_path_script}
234
+
235
+ echo " hash FVP_Corstone_SSE-300_Ethos-U55" >> ${setup_path_script}
236
+ echo " hash FVP_Corstone_SSE-300_Ethos-U65" >> ${setup_path_script}
237
+ echo " hash FVP_Corstone_SSE-320" >> ${setup_path_script}
238
+ fi
191
239
192
- echo " hash FVP_Corstone_SSE-300_Ethos-U55" >> ${setup_path_script}
193
- echo " hash FVP_Corstone_SSE-300_Ethos-U65" >> ${setup_path_script}
194
- echo " hash FVP_Corstone_SSE-320" >> ${setup_path_script}
240
+ if [[ " ${skip_toolchain_setup} " -eq 0 ]]; then
241
+ toolchain_bin_path=" $( cd ${toolchain_dir} /bin && pwd) "
242
+ echo " export PATH=\$ {PATH}:${toolchain_bin_path} " >> ${setup_path_script}
243
+ fi
195
244
}
196
245
197
246
function check_platform_support() {
247
+ # Make sure we are on a supported platform
198
248
if [[ " ${ARCH} " != " x86_64" ]] && [[ " ${ARCH} " != " aarch64" ]] \
199
249
&& [[ " ${ARCH} " != " arm64" ]]; then
200
250
echo " [main] Error: only x86-64 & aarch64 architecture is supported for now!"
201
251
exit 1
202
252
fi
203
-
204
- # Make sure we are on a supported platform
205
- if [[ " ${1:- ' .' } " == " -h" || " ${# } " -gt 2 ]]; then
206
- echo " Usage: $( basename $0 ) <--i-agree-to-the-contained-eula> [path-to-a-scratch-dir]"
207
- echo " Supplied args: $* "
208
- exit 1
209
- fi
210
253
}
211
254
255
+
212
256
# #######
213
257
# ## main
214
258
# #######
215
259
216
260
# script is not sourced! Lets run "main"
217
- if [[ $is_script_sourced -eq 0 ]]
218
- then
261
+ if [[ $is_script_sourced -eq 0 ]]; then
219
262
set -e
220
263
264
+ check_options " $@ "
265
+
221
266
check_platform_support
222
267
223
268
cd " ${script_dir} "
224
269
225
270
# Setup the root dir
226
271
setup_root_dir
227
272
cd " ${root_dir} "
228
- echo " [main] Using root dir ${root_dir} "
273
+ echo " [main] Using root dir ${root_dir} and options:"
274
+ echo " skip-fvp-setup=${skip_fvp_setup} "
275
+ echo " skip-toolchain-setup=${skip_toolchain_setup} "
276
+ echo " skip-vela-setup=${skip_vela_setup} "
229
277
230
278
# Import utils
231
279
source $et_dir /backends/arm/scripts/utils.sh
232
280
233
- # Setup FVP
234
- setup_fvp ${1:- ' .' }
235
-
236
281
# Setup toolchain
237
- setup_toolchain
282
+ if [[ " ${skip_toolchain_setup} " -eq 0 ]]; then
283
+ setup_toolchain
284
+ fi
238
285
239
- # Create new setup_path script only if fvp and toolchain setup went well.
240
- create_setup_path
286
+ # Setup FVP
287
+ if [[ " ${skip_fvp_setup} " -eq 0 ]]; then
288
+ setup_fvp
289
+ fi
290
+
291
+ # Create new setup_path script
292
+ if [[ " ${skip_toolchain_setup} " -eq 0 || " ${skip_fvp_setup} " -eq 0 ]]; then
293
+ create_setup_path
294
+ fi
241
295
242
296
# Setup the tosa_reference_model
243
297
$et_dir /backends/arm/scripts/install_reference_model.sh ${root_dir}
244
298
245
299
# Setup vela and patch in codegen fixes
246
- setup_vela
300
+ if [[ " ${skip_vela_setup} " -eq 0 ]]; then
301
+ setup_vela
302
+ fi
247
303
248
304
echo " [main] update path by doing 'source ${setup_path_script} '"
249
305
0 commit comments