@@ -19,13 +19,19 @@ OS="$(uname -s)"
1919root_dir=" ${script_dir} /ethos-u-scratch"
2020eula_acceptance=0
2121skip_toolchain_setup=0
22+ target_toolchain=" "
2223skip_fvp_setup=0
2324skip_vela_setup=0
2425
2526
2627# Figure out if setup.sh was called or sourced and save it into "is_script_sourced"
2728(return 0 2> /dev/null) && is_script_sourced=1 || is_script_sourced=0
2829
30+ # Global scope these so they can be set later
31+ toolchain_url=" "
32+ toolchain_dir=" "
33+ toolchain_md5_checksum=" "
34+
2935if [[ " ${ARCH} " == " x86_64" ]]; then
3036 # FVPs
3137 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"
@@ -35,11 +41,6 @@ if [[ "${ARCH}" == "x86_64" ]]; then
3541 corstone320_url=" https://developer.arm.com/-/media/Arm%20Developer%20Community/Downloads/OSS/FVP/Corstone-320/FVP_Corstone_SSE-320_11.27_25_Linux64.tgz?rev=a507bffc219a4d5792f1192ab7002d89&hash=D9A824AA8227D2E679C9B9787FF4E8B6FBE3D7C6"
3642 corstone320_model_dir=" Linux64_GCC-9.3"
3743 corstone320_md5_checksum=" 3deb3c68f9b2d145833f15374203514d"
38-
39- # toochain
40- toolchain_url=" https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/13.3.rel1/binrel/arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi.tar.xz"
41- toolchain_dir=" arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi"
42- toolchain_md5_checksum=" 0601a9588bc5b9c99ad2b56133b7f118"
4344elif [[ " ${ARCH} " == " aarch64" ]] || [[ " ${ARCH} " == " arm64" ]]; then
4445 # FVPs
4546 corstone300_url=" https://developer.arm.com/-/media/Arm%20Developer%20Community/Downloads/OSS/FVP/Corstone-300/FVP_Corstone_SSE-300_11.22_20_Linux64_armv8l.tgz?rev=9cc6e9a32bb947ca9b21fa162144cb01&hash=7657A4CF27D42E892E3F08D452AAB073"
@@ -49,17 +50,6 @@ elif [[ "${ARCH}" == "aarch64" ]] || [[ "${ARCH}" == "arm64" ]]; then
4950 corstone320_url=" https://developer.arm.com/-/media/Arm%20Developer%20Community/Downloads/OSS/FVP/Corstone-320/FVP_Corstone_SSE-320_11.27_25_Linux64_armv8l.tgz?rev=b6ebe0923cb84f739e017385fd3c333c&hash=8965C4B98E2FF7F792A099B08831FE3CB6120493"
5051 corstone320_model_dir=" Linux64_armv8l_GCC-9.3"
5152 corstone320_md5_checksum=" 3889f1d80a6d9861ea4aa6f1c88dd0ae"
52-
53- # toochain
54- if [[ " ${OS} " == " Darwin" ]]; then
55- toolchain_url=" https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/13.3.rel1/binrel/arm-gnu-toolchain-13.3.rel1-darwin-arm64-arm-none-eabi.tar.xz"
56- toolchain_dir=" arm-gnu-toolchain-13.3.rel1-darwin-arm64-arm-none-eabi"
57- toolchain_md5_checksum=" f1c18320bb3121fa89dca11399273f4e"
58- elif [[ " ${OS} " == " Linux" ]]; then
59- toolchain_url=" https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/13.3.rel1/binrel/arm-gnu-toolchain-13.3.rel1-aarch64-arm-none-eabi.tar.xz"
60- toolchain_dir=" arm-gnu-toolchain-13.3.rel1-aarch64-arm-none-eabi"
61- toolchain_md5_checksum=" 303102d97b877ebbeb36b3158994b218"
62- fi
6353else
6454 echo " [main] Error: only x86-64 & aarch64/arm64 architecture is supported for now!" ; exit 1;
6555fi
@@ -73,7 +63,7 @@ vela_rev="8cac2b9a7204b57125a8718049519b091a98846c"
7363# #######
7464
7565function 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]"
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]"
7767 echo " Supplied args: $* "
7868}
7969
@@ -101,6 +91,19 @@ function check_options() {
10191 skip_toolchain_setup=1
10292 shift
10393 ;;
94+ --target-toolchain)
95+ # Only change default root dir if the script is being executed and not sourced.
96+ if [[ $is_script_sourced -eq 0 ]]; then
97+ target_toolchain=${2:- " ${target_toolchain} " }
98+ fi
99+
100+ if [[ $# -ge 2 ]]; then
101+ shift 2
102+ else
103+ print_usage " $@ "
104+ exit 1
105+ fi
106+ ;;
104107 --skip-fvp-setup)
105108 skip_fvp_setup=1
106109 shift
@@ -197,16 +200,59 @@ function setup_fvp() {
197200 done
198201}
199202
203+ function select_toolchain() {
204+ if [[ " ${ARCH} " == " x86_64" ]]; then
205+ if [[ " ${OS} " == " Linux" ]]; then
206+ if [[ " ${target_toolchain} " == " zephyr" ]]; then
207+ # TODO can include support for zephyr toolchain for other host platforms later
208+ toolchain_url=" https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.2/toolchain_linux-x86_64_arm-zephyr-eabi.tar.xz"
209+ toolchain_dir=" arm-zephyr-eabi"
210+ toolchain_md5_checksum=" 93128be0235cf5cf5f1ee561aa6eac5f"
211+ else
212+ toolchain_url=" https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/13.3.rel1/binrel/arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi.tar.xz"
213+ toolchain_dir=" arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi"
214+ toolchain_md5_checksum=" 0601a9588bc5b9c99ad2b56133b7f118"
215+ fi
216+ else
217+ echo " [main] Error: only Linux is currently supported for x86-64 architecture now!" ; exit 1;
218+ fi
219+ elif [[ " ${ARCH} " == " aarch64" ]] || [[ " ${ARCH} " == " arm64" ]]; then
220+ if [[ " ${OS} " == " Darwin" ]]; then
221+ if [[ " ${target_toolchain} " == " zephyr" ]]; then
222+ echo " [main] Error: only Linux OS is currently supported for aarch64 architecture targeting Zephyr now!" ; exit 1;
223+ else
224+ toolchain_url=" https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/13.3.rel1/binrel/arm-gnu-toolchain-13.3.rel1-darwin-arm64-arm-none-eabi.tar.xz"
225+ toolchain_dir=" arm-gnu-toolchain-13.3.rel1-darwin-arm64-arm-none-eabi"
226+ toolchain_md5_checksum=" f1c18320bb3121fa89dca11399273f4e"
227+ fi
228+ elif [[ " ${OS} " == " Linux" ]]; then
229+ if [[ " ${target_toolchain} " == " zephyr" ]]; then
230+ # eventually, this can be support by downloading the the toolchain from
231+ # "https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.2/toolchain_linux-aarch64_arm-zephyr-eabi.tar.xz"
232+ # but for now, we error if user tries to specify this
233+ echo " [main] Error: currently target_toolchain zephyr is only support for x86-64 Linux host systems!" ; exit 1;
234+ else
235+ toolchain_url=" https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/13.3.rel1/binrel/arm-gnu-toolchain-13.3.rel1-aarch64-arm-none-eabi.tar.xz"
236+ toolchain_dir=" arm-gnu-toolchain-13.3.rel1-aarch64-arm-none-eabi"
237+ toolchain_md5_checksum=" 303102d97b877ebbeb36b3158994b218"
238+ fi
239+ fi
240+ else
241+ echo " [main] Error: only x86-64 & aarch64/arm64 architecture is supported for now!" ; exit 1;
242+ fi
243+ echo " [main] Info selected ${toolchain_dir} for ${ARCH} - ${OS} platform"
244+ }
200245function setup_toolchain() {
201- # Download and install the arm-none-eabi toolchain
246+ # Download and install the arm toolchain (default is arm-none-eabi)
247+ # setting --target-toolchain to zephyr sets this to arm-zephyr-eabi
202248 cd " ${root_dir} "
203249 if [[ ! -e " ${toolchain_dir} .tar.xz" ]]; then
204- echo " [${FUNCNAME[0]} ] Downloading toolchain ..."
205- curl --output " ${toolchain_dir} .tar.xz" " ${toolchain_url} "
250+ echo " [${FUNCNAME[0]} ] Downloading ${toolchain_dir} toolchain ..."
251+ curl --output " ${toolchain_dir} .tar.xz" -L " ${toolchain_url} "
206252 verify_md5 ${toolchain_md5_checksum} " ${toolchain_dir} .tar.xz" || exit 1
207253 fi
208254
209- echo " [${FUNCNAME[0]} ] Installing toolchain ..."
255+ echo " [${FUNCNAME[0]} ] Installing ${toolchain_dir} toolchain ..."
210256 rm -rf " ${toolchain_dir} "
211257 tar xf " ${toolchain_dir} .tar.xz"
212258}
@@ -272,12 +318,16 @@ if [[ $is_script_sourced -eq 0 ]]; then
272318 cd " ${root_dir} "
273319 echo " [main] Using root dir ${root_dir} and options:"
274320 echo " skip-fvp-setup=${skip_fvp_setup} "
321+ echo " target-toolchain=${target_toolchain} "
275322 echo " skip-toolchain-setup=${skip_toolchain_setup} "
276323 echo " skip-vela-setup=${skip_vela_setup} "
277324
278325 # Import utils
279326 source $et_dir /backends/arm/scripts/utils.sh
280327
328+ # Select appropriate toolchain
329+ select_toolchain
330+
281331 # Setup toolchain
282332 if [[ " ${skip_toolchain_setup} " -eq 0 ]]; then
283333 setup_toolchain
0 commit comments