Skip to content

Commit

Permalink
[#54467] scripts: prepare_zephyr_env: Add fallback to older SDK version
Browse files Browse the repository at this point in the history
Signed-off-by: Maciej Torhan <mtorhan@antmicro.com>
  • Loading branch information
m-torhan authored and glatosinski committed Jan 31, 2024
1 parent 50b6b21 commit 733b9c8
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions scripts/prepare_zephyr_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,23 @@ PROJECT_ROOT=$(realpath $(pwd))

# setup SDK
if [ ! -d "$ZEPHYR_SDK_PATH" ]; then
# determine latest SDK version
ZEPHYR_SDK_VERSION=$(curl "https://api.github.com/repos/zephyrproject-rtos/sdk-ng/tags" | jq -r '[.[].name | select(.|test("-")|not)][0]')
ZEPHYR_SDK_VERSION="${ZEPHYR_SDK_VERSION:1}"
cd /tmp
for SDK_IDX in 0 1 2
do
# determine latest SDK version
ZEPHYR_SDK_VERSION=$(curl "https://api.github.com/repos/zephyrproject-rtos/sdk-ng/tags" | jq -r "[.[].name | select(.|test(\"-\")|not)][$SDK_IDX]")
ZEPHYR_SDK_VERSION="${ZEPHYR_SDK_VERSION:1}"

ZEPHYR_SDK_ARCHIVE="zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64_minimal.tar.xz"
ZEPHYR_SDK_ARCHIVE="zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64_minimal.tar.xz"

WGET_RETVAL=0
wget "https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/${ZEPHYR_SDK_ARCHIVE}" || WGET_RETVAL=$?
if [ "$WGET_RETVAL" -eq 0 ]; then
break
fi
echo "Fallback to older SDK version"
done
mkdir -p $(dirname $ZEPHYR_SDK_PATH)
cd /tmp
wget "https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/${ZEPHYR_SDK_ARCHIVE}"
tar xvf ${ZEPHYR_SDK_ARCHIVE}
mv ./zephyr-sdk-${ZEPHYR_SDK_VERSION} ${ZEPHYR_SDK_PATH}
rm ${ZEPHYR_SDK_ARCHIVE}
Expand All @@ -36,7 +44,7 @@ fi

cd ${PROJECT_ROOT}
# setup Zephyr project
if [ ! -d ".west" ]; then
if [ ! -d "../.west" ]; then
west init -l .
west update
west zephyr-export
Expand Down

0 comments on commit 733b9c8

Please sign in to comment.