@@ -25,15 +25,18 @@ function gcc_select_toolchain() {
2525 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"
2626 toolchain_dir=" arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi"
2727 toolchain_md5_checksum=" 0601a9588bc5b9c99ad2b56133b7f118"
28+ toolchain_archive=" ${toolchain_dir} .tar.xz"
2829 elif [[ " ${ARCH} " == " aarch64" ]] || [[ " ${ARCH} " == " arm64" ]] ; then
2930 if [[ " ${OS} " == " Darwin" ]]; then
3031 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"
3132 toolchain_dir=" arm-gnu-toolchain-13.3.rel1-darwin-arm64-arm-none-eabi"
3233 toolchain_md5_checksum=" f1c18320bb3121fa89dca11399273f4e"
34+ toolchain_archive=" ${toolchain_dir} .tar.xz"
3335 elif [[ " ${OS} " == " Linux" ]]; then
3436 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"
3537 toolchain_dir=" arm-gnu-toolchain-13.3.rel1-aarch64-arm-none-eabi"
3638 toolchain_md5_checksum=" 303102d97b877ebbeb36b3158994b218"
39+ toolchain_archive=" ${toolchain_dir} .tar.xz"
3740 fi
3841 else
3942 # This should never happen, it should be covered by setup.sh but catch it anyway
@@ -52,20 +55,41 @@ function zephyr_select_toolchain() {
5255 toolchain_url=" https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.4/toolchain_linux-x86_64_arm-zephyr-eabi.tar.xz"
5356 toolchain_dir=" arm-zephyr-eabi"
5457 toolchain_md5_checksum=" 68ae71edc0106c3093055b97aaa47017"
58+ toolchain_archive=" ${toolchain_dir} .tar.xz"
5559 elif [[ " ${ARCH} " == " aarch64" ]] || [[ " ${ARCH} " == " arm64" ]] ; then
5660 toolchain_url=" https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.4/toolchain_linux-aarch64_arm-zephyr-eabi.tar.xz"
5761 toolchain_dir=" arm-zephyr-eabi"
5862 toolchain_md5_checksum=" d8a6dfd4314d55da713957d0b161d01f"
63+ toolchain_archive=" ${toolchain_dir} .tar.xz"
5964 else
6065 # This should never happen, it should be covered by setup.sh but catch it anyway
6166 log_step " toolchain" " Error: Unsupported architecture ${ARCH} "
6267 exit 1
6368 fi
6469}
6570
71+ function musl_select_toolchain() {
72+ if [[ " ${OS} " != " Linux" ]] ; then
73+ log_step " toolchain" " Error: Linux is required for musl toolchain support"
74+ exit 1
75+ fi
76+
77+ if [[ " ${ARCH} " == " x86_64" ]] ; then
78+ toolchain_url=" https://musl.cc/aarch64-linux-musl-cross.tgz"
79+ toolchain_dir=" aarch64-linux-musl-cross"
80+ toolchain_md5_checksum=" a6bb806af217a91cf575e15163e8b12b"
81+ toolchain_archive=" ${toolchain_dir} .tgz"
82+ else
83+ log_step " toolchain" " Error: Unsupported architecture ${ARCH} for musl toolchain"
84+ exit 1
85+ fi
86+ }
87+
6688function select_toolchain() {
6789 if [[ " ${target_toolchain} " == " zephyr" ]]; then
6890 zephyr_select_toolchain
91+ elif [[ " ${target_toolchain} " == " linux-musl" ]]; then
92+ musl_select_toolchain
6993 else
7094 gcc_select_toolchain
7195 fi
@@ -76,18 +100,28 @@ function setup_toolchain() {
76100 # Download and install the arm toolchain (default is arm-none-eabi)
77101 # setting --target-toolchain to zephyr sets this to arm-zephyr-eabi
78102 cd " ${root_dir} "
79- if [[ ! -e " ${toolchain_dir} .tar.xz" ]]; then
103+ if [[ -z " ${toolchain_archive} " ]]; then
104+ log_step " toolchain" " Error: Toolchain archive not set"
105+ exit 1
106+ fi
107+
108+ if [[ ! -e " ${toolchain_archive} " ]]; then
80109 log_step " toolchain" " Downloading ${toolchain_dir} toolchain"
81- curl --output " ${toolchain_dir} .tar.xz " -L " ${toolchain_url} "
82- verify_md5 ${toolchain_md5_checksum} " ${toolchain_dir} .tar.xz " || exit 1
110+ curl --output " ${toolchain_archive} " -L " ${toolchain_url} "
111+ verify_md5 ${toolchain_md5_checksum} " ${toolchain_archive} " || exit 1
83112 fi
84113
85114 log_step " toolchain" " Installing ${toolchain_dir} toolchain"
86115 rm -rf " ${toolchain_dir} "
87- tar xf " ${toolchain_dir} .tar.xz "
116+ tar xf " ${toolchain_archive} "
88117}
89118
90119function setup_path_toolchain() {
91120 toolchain_bin_path=" $( cd ${toolchain_dir} /bin && pwd) "
92121 append_env_in_setup_path PATH ${toolchain_bin_path}
122+
123+ if [[ " ${target_toolchain} " == " linux-musl" ]]; then
124+ local toolchain_root_path=" $( cd ${toolchain_dir} && pwd) "
125+ set_env_in_setup_path MUSL_TOOLCHAIN_ROOT ${toolchain_root_path}
126+ fi
93127}
0 commit comments