@@ -19,13 +19,19 @@ OS="$(uname -s)"
19
19
root_dir=" ${script_dir} /ethos-u-scratch"
20
20
eula_acceptance=0
21
21
skip_toolchain_setup=0
22
+ target_toolchain=" "
22
23
skip_fvp_setup=0
23
24
skip_vela_setup=0
24
25
25
26
26
27
# Figure out if setup.sh was called or sourced and save it into "is_script_sourced"
27
28
(return 0 2> /dev/null) && is_script_sourced=1 || is_script_sourced=0
28
29
30
+ # Global scope these so they can be set later
31
+ toolchain_url=" "
32
+ toolchain_dir=" "
33
+ toolchain_md5_checksum=" "
34
+
29
35
if [[ " ${ARCH} " == " x86_64" ]]; then
30
36
# FVPs
31
37
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
35
41
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"
36
42
corstone320_model_dir=" Linux64_GCC-9.3"
37
43
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"
43
44
elif [[ " ${ARCH} " == " aarch64" ]] || [[ " ${ARCH} " == " arm64" ]]; then
44
45
# FVPs
45
46
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
49
50
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"
50
51
corstone320_model_dir=" Linux64_armv8l_GCC-9.3"
51
52
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
63
53
else
64
54
echo " [main] Error: only x86-64 & aarch64/arm64 architecture is supported for now!" ; exit 1;
65
55
fi
@@ -73,7 +63,7 @@ vela_rev="8cac2b9a7204b57125a8718049519b091a98846c"
73
63
# #######
74
64
75
65
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]"
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]"
77
67
echo " Supplied args: $* "
78
68
}
79
69
@@ -101,6 +91,19 @@ function check_options() {
101
91
skip_toolchain_setup=1
102
92
shift
103
93
;;
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
+ ;;
104
107
--skip-fvp-setup)
105
108
skip_fvp_setup=1
106
109
shift
@@ -197,16 +200,59 @@ function setup_fvp() {
197
200
done
198
201
}
199
202
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
+ }
200
245
function 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
202
248
cd " ${root_dir} "
203
249
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} "
206
252
verify_md5 ${toolchain_md5_checksum} " ${toolchain_dir} .tar.xz" || exit 1
207
253
fi
208
254
209
- echo " [${FUNCNAME[0]} ] Installing toolchain ..."
255
+ echo " [${FUNCNAME[0]} ] Installing ${toolchain_dir} toolchain ..."
210
256
rm -rf " ${toolchain_dir} "
211
257
tar xf " ${toolchain_dir} .tar.xz"
212
258
}
@@ -272,12 +318,16 @@ if [[ $is_script_sourced -eq 0 ]]; then
272
318
cd " ${root_dir} "
273
319
echo " [main] Using root dir ${root_dir} and options:"
274
320
echo " skip-fvp-setup=${skip_fvp_setup} "
321
+ echo " target-toolchain=${target_toolchain} "
275
322
echo " skip-toolchain-setup=${skip_toolchain_setup} "
276
323
echo " skip-vela-setup=${skip_vela_setup} "
277
324
278
325
# Import utils
279
326
source $et_dir /backends/arm/scripts/utils.sh
280
327
328
+ # Select appropriate toolchain
329
+ select_toolchain
330
+
281
331
# Setup toolchain
282
332
if [[ " ${skip_toolchain_setup} " -eq 0 ]]; then
283
333
setup_toolchain
0 commit comments