2222ARCH=" $( uname -m) "
2323OS=" $( uname -s) "
2424
25- function verify_md5() {
26- [[ $# -ne 2 ]] \
27- && { echo " [${FUNCNAME[0]} ] Invalid number of args, expecting 2, but got $# " ; exit 1; }
28- local ref_checksum=" ${1} "
29- local file=" ${2} "
3025
31- if [[ " ${OS} " == " Darwin" ]]; then
32- local file_checksum=" $( md5 -q $file ) "
33- else
34- local file_checksum=" $( md5sum $file | awk ' {print $1}' ) "
35- fi
36- if [[ ${ref_checksum} != ${file_checksum} ]]; then
37- echo " Mismatched MD5 checksum for file: ${file} . Expecting ${ref_checksum} but got ${file_checksum} . Exiting."
38- exit 1
39- fi
40- }
4126
4227# #######
4328# ## Hardcoded constants
4429# #######
4530script_dir=$( cd -- " $( dirname -- " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd)
31+ et_dir=$( realpath $script_dir /../..)
4632
4733if [[ " ${ARCH} " == " x86_64" ]]; then
4834 # FVPs
@@ -140,7 +126,7 @@ function setup_fvp() {
140126 curl --output " FVP_${fvp} .tgz" " ${fvp_url} "
141127 md5_variable=${fvp} _md5_checksum
142128 fvp_md5_checksum=${! md5_variable}
143- verify_md5 ${fvp_md5_checksum} FVP_${fvp} .tgz
129+ verify_md5 ${fvp_md5_checksum} FVP_${fvp} .tgz || exit 1
144130 fi
145131
146132 echo " [${FUNCNAME[0]} ] Installing FVP ${fvp} ..."
@@ -181,7 +167,7 @@ function setup_toolchain() {
181167 if [[ ! -e " ${toolchain_dir} .tar.xz" ]]; then
182168 echo " [${FUNCNAME[0]} ] Downloading toolchain ..."
183169 curl --output " ${toolchain_dir} .tar.xz" " ${toolchain_url} "
184- verify_md5 ${toolchain_md5_checksum} " ${toolchain_dir} .tar.xz"
170+ verify_md5 ${toolchain_md5_checksum} " ${toolchain_dir} .tar.xz" || exit 1
185171 fi
186172
187173 echo " [${FUNCNAME[0]} ] Installing toolchain ..."
@@ -207,20 +193,6 @@ function setup_ethos_u() {
207193 echo " [${FUNCNAME[0]} ] Done @ $( git describe --all --long 3> /dev/null) in ${root_dir} /ethos-u dir."
208194}
209195
210- function patch_repo() {
211- # This is a temporary hack until it finds a better home in one for the ARM Ml repos
212- name=" $( basename $repo_dir ) "
213- echo -e " [${FUNCNAME[0]} ] Preparing ${name} ..."
214- cd $repo_dir
215- git fetch
216- git reset --hard ${base_rev}
217-
218- patch_dir=${script_dir} /ethos-u-setup/${name} /patches/
219- [[ -e ${patch_dir} && $( ls -A ${patch_dir} ) ]] && \
220- git am -3 ${patch_dir} /* .patch
221-
222- echo -e " [${FUNCNAME[0]} ] Patched ${name} @ $( git describe --all --long 2> /dev/null) in ${repo_dir} dir.\n"
223- }
224196
225197function setup_tosa_reference_model() {
226198
@@ -258,6 +230,9 @@ echo "[main] Using root dir ${root_dir}"
258230setup_path_script=" ${root_dir} /setup_path.sh"
259231echo " " > " ${setup_path_script} "
260232
233+ # Import utils
234+ source $et_dir /backends/arm/scripts/utils.sh
235+
261236# Setup toolchain
262237setup_toolchain
263238
@@ -267,7 +242,8 @@ setup_ethos_u
267242# Patch the ethos-u dev environment to include executorch application
268243repo_dir=" ${root_dir} /ethos-u/core_platform"
269244base_rev=b728c774158248ba2cad8e78a515809e1eb9b77f
270- patch_repo
245+ patch_dir=${script_dir} /ethos-u-setup/
246+ patch_repo $repo_dir $base_rev $patch_dir
271247
272248# Setup the tosa_reference_model
273249setup_tosa_reference_model
0 commit comments