@@ -16,12 +16,16 @@ script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
1616et_dir=$( realpath $script_dir /../..)
1717ARCH=" $( uname -m) "
1818OS=" $( uname -s) "
19- root_dir=" ${script_dir} /ethos-u-scratch"
19+ root_dir=" ${script_dir} /ethos-u-scratch" # TODO: rename
2020eula_acceptance=0
21- skip_toolchain_setup=0
21+ enable_baremetal_toolchain=1
2222target_toolchain=" "
23- skip_fvp_setup=0
24- skip_vela_setup=0
23+ enable_fvps=1
24+ enable_vela=1
25+ enable_model_converter=0 # model-converter tool for VGF output
26+ enable_vgf_lib=0 # vgf reader - runtime backend dependency
27+ enable_emulation_layer=0 # Vulkan layer driver - emulates Vulkan ML extensions
28+ mlsdk_manifest_url=" "
2529
2630
2731# Figure out if setup.sh was called or sourced and save it into "is_script_sourced"
5458 echo " [main] Error: only x86-64 & aarch64/arm64 architecture is supported for now!" ; exit 1;
5559fi
5660
57- # vela
61+ # Vela
5862vela_repo_url=" https://gitlab.arm.com/artificial-intelligence/ethos-u/ethos-u-vela"
5963vela_rev=" 8cac2b9a7204b57125a8718049519b091a98846c"
6064
65+ # MLSDK dependencies
66+ mlsdk_manifest_dir=" ml-sdk-for-vulkan-manifest"
67+
68+ # List of supported options and their descriptions
69+ OPTION_LIST=(
70+ " --i-agree-to-the-contained-eula (required) Agree to the EULA"
71+ " --root-dir Path to scratch directory"
72+ " --enable-baremetal-toolchain Enable baremetal toolchain setup"
73+ " --enable-fvps Enable FVP setup"
74+ " --enable-vela Enable VELA setup"
75+ " --enable-model-converter Enable MLSDK model converter setup"
76+ " --enable-vgf-lib Enable MLSDK vgf library setup"
77+ " --enable-emulation-layer Enable MLSDK Vulkan emulation layer"
78+ " --disable-ethos-u-deps Do not setup what is needed for Ethos-U"
79+ " --enable-mlsdk-deps Setup what is needed for MLSDK"
80+ " --mlsdk-manifest-url URL to the MLSDK manifest for vulkan."
81+ " --help Display help"
82+ )
83+
84+
6185# #######
6286# ## Functions
6387# #######
6488
6589function print_usage() {
66- echo " Usage: $( basename $0 ) <--i-agree-to-the-contained-eula> [--root-dir path-to-a-scratch-dir] [--target-toolchain toolchain name] [--skip-fvp-setup] [--skip-toolchain-setup] [--skip-vela-setup]"
90+ echo " Usage: $( basename " $0 " ) [OPTIONS]"
91+ echo
92+ echo " Available options:"
93+ for entry in " ${OPTION_LIST[@]} " ; do
94+ opt=" ${entry%% * } "
95+ desc=" ${entry#* } "
96+ printf " %-40s %s\n" " $opt " " $desc "
97+ done
98+ echo
6799 echo " Supplied args: $* "
68100}
69101
@@ -87,8 +119,8 @@ function check_options() {
87119 exit 1
88120 fi
89121 ;;
90- --skip-toolchain-setup )
91- skip_toolchain_setup =1
122+ --enable-baremetal-toolchain )
123+ enable_baremetal_toolchain =1
92124 shift
93125 ;;
94126 --target-toolchain)
@@ -104,14 +136,49 @@ function check_options() {
104136 exit 1
105137 fi
106138 ;;
107- --skip-fvp-setup)
108- skip_fvp_setup=1
139+ --enable-fvps)
140+ enable_fvps=1
141+ shift
142+ ;;
143+ --enable-vela)
144+ enable_vela=1
145+ shift
146+ ;;
147+ --enable-model-converter)
148+ enable_model_converter=1
149+ shift
150+ ;;
151+ --enable-vgf-lib)
152+ enable_vgf_lib=1
109153 shift
110154 ;;
111- --skip-vela-setup )
112- skip_vela_setup =1
155+ --enable-emulation-layer )
156+ enable_emulation_layer =1
113157 shift
114158 ;;
159+ --disable-ethos-u-deps)
160+ enable_baremetal_toolchain=0
161+ enable_fvps=0
162+ enable_vela=0
163+ shift
164+ ;;
165+ --enable-mlsdk-deps)
166+ enable_model_converter=1
167+ enable_vgf_lib=1
168+ enable_emulation_layer=1
169+ shift
170+ ;;
171+ --mlsdk-manifest-url)
172+ # Ensure that there is a url provided.
173+ if [[ -n " $2 " && " ${2: 0: 1} " != " -" ]]; then
174+ mlsdk_manifest_url=" $2 "
175+ shift 2
176+ else
177+ echo " Error: --mlsdk-manifest-url requires a URL argument."
178+ print_usage " $@ "
179+ exit 1
180+ fi
181+ ;;
115182 --help)
116183 print_usage " $@ "
117184 exit 0
@@ -267,7 +334,7 @@ function create_setup_path(){
267334
268335 echo " " > " ${setup_path_script} "
269336
270- if [[ " ${skip_fvp_setup } " -eq 0 ]]; then
337+ if [[ " ${enable_fvps } " -eq 1 ]]; then
271338 fvps=(" corstone300" " corstone320" )
272339 for fvp in " ${fvps[@]} " ; do
273340 model_dir_variable=${fvp} _model_dir
@@ -284,10 +351,29 @@ function create_setup_path(){
284351 echo " hash FVP_Corstone_SSE-320" >> ${setup_path_script}
285352 fi
286353
287- if [[ " ${skip_toolchain_setup } " -eq 0 ]]; then
354+ if [[ " ${enable_baremetal_toolchain } " -eq 1 ]]; then
288355 toolchain_bin_path=" $( cd ${toolchain_dir} /bin && pwd) "
289356 echo " export PATH=\$ {PATH}:${toolchain_bin_path} " >> ${setup_path_script}
290357 fi
358+
359+ if [[ " ${enable_model_converter} " -eq 1 ]]; then
360+ cd " ${root_dir} "
361+ model_converter_bin_path=" $( cd ${mlsdk_manifest_dir} /sw/model-converter/build && pwd) "
362+ echo " export PATH=\$ {PATH}:${model_converter_bin_path} " >> ${setup_path_script}
363+ fi
364+
365+ # Add Path for vgf-lib and emulation-layer
366+ if [[ " ${enable_vgf_lib} " -eq 1 ]]; then
367+ cd " ${root_dir} "
368+ model_vgf_lib_bin_path=" $( cd ${mlsdk_manifest_dir} /sw/vgf-lib/build && pwd) "
369+ echo " export PATH=\$ {PATH}:${model_vgf_lib_bin_path} " >> ${setup_path_script}
370+ fi
371+
372+ if [[ " ${enable_emulation_layer} " -eq 1 ]]; then
373+ cd " ${root_dir} "
374+ model_emulation_layer_bin_path=" $( cd ${mlsdk_manifest_dir} /sw/vgf-lib/build && pwd) "
375+ echo " export PATH=\$ {PATH}:${model_emulation_layer_bin_path} " >> ${setup_path_script}
376+ fi
291377}
292378
293379function check_platform_support() {
@@ -318,10 +404,14 @@ if [[ $is_script_sourced -eq 0 ]]; then
318404 setup_root_dir
319405 cd " ${root_dir} "
320406 echo " [main] Using root dir ${root_dir} and options:"
321- echo " skip-fvp-setup =${skip_fvp_setup } "
407+ echo " enable-fvps =${enable_fvps } "
322408 echo " target-toolchain=${target_toolchain} "
323- echo " skip-toolchain-setup=${skip_toolchain_setup} "
324- echo " skip-vela-setup=${skip_vela_setup} "
409+ echo " enable-baremetal-toolchain=${enable_baremetal_toolchain} "
410+ echo " enable-model-converter=${enable_model_converter} "
411+ echo " enable-vgf-lib=${enable_vgf_lib} "
412+ echo " enable-emulation-layer=${enable_emulation_layer} "
413+ echo " enable-vela=${enable_vela} "
414+ echo " mlsdk-manifest-url=${mlsdk_manifest_url} "
325415
326416 # Import utils
327417 source $et_dir /backends/arm/scripts/utils.sh
@@ -330,25 +420,42 @@ if [[ $is_script_sourced -eq 0 ]]; then
330420 select_toolchain
331421
332422 # Setup toolchain
333- if [[ " ${skip_toolchain_setup } " -eq 0 ]]; then
423+ if [[ " ${enable_baremetal_toolchain } " -eq 1 ]]; then
334424 setup_toolchain
335425 fi
336426
337427 # Setup FVP
338- if [[ " ${skip_fvp_setup } " -eq 0 ]]; then
428+ if [[ " ${enable_fvps } " -eq 1 ]]; then
339429 setup_fvp
340430 fi
341431
432+
433+ if [[ -z " $mlsdk_manifest_url " && " ${enable_model_converter} " -eq 1 ]]; then
434+ echo " Warning: mlsdk-manifest-url is not set, but model converter setup is not skipped."
435+ echo " Please set the --mlsdk-manifest-url option to the correct URL."
436+ echo " Skipping MLSDK model converter setup."
437+ enable_model_converter=0 # Q: Can we assume if we enable mlsdk, we will always enable model converter
438+ enable_vgf_lib=0
439+ enable_emulation_layer=0
440+ fi
441+
442+ if [[ " ${enable_model_converter} " -eq 1 ]]; then
443+ source $et_dir /backends/arm/scripts/mlsdk_utils.sh -u " ${mlsdk_manifest_url} "
444+ setup_model_converter ${root_dir} ${mlsdk_manifest_dir} ${enable_vgf_lib} ${enable_emulation_layer}
445+ fi
446+
342447 # Create new setup_path script
343- if [[ " ${skip_toolchain_setup} " -eq 0 || " ${skip_fvp_setup} " -eq 0 ]]; then
448+ if [[ " ${enable_baremetal_toolchain} " -eq 1 || \
449+ " ${enable_fvps} " -eq 1 || \
450+ " ${enable_model_converter} " -eq 1 ]]; then
344451 create_setup_path
345452 fi
346453
347454 # Setup the tosa_reference_model
348455 $et_dir /backends/arm/scripts/install_reference_model.sh ${root_dir}
349456
350457 # Setup vela and patch in codegen fixes
351- if [[ " ${skip_vela_setup } " -eq 0 ]]; then
458+ if [[ " ${enable_vela } " -eq 1 ]]; then
352459 setup_vela
353460 fi
354461
0 commit comments