Skip to content

Commit 6f2a661

Browse files
authored
docker: fix NRF_SDK download and subsequent build.sh (#2299)
The upstream NRF-SDK download url and zip archive filename changed, which was fixed with #2270 But the archive contents stayed the same, with the "old" folder name. After #2270 we have basically the same docker-container as before the PR, but the `GetNrfSdk` function of the `build.sh` script is called again during firmware build time as the expected foldername for the SDK isn't the same as the zip filename: ```sh [ ! -d "$TOOLS_DIR/$NRF_SDK_VER" ] && GetNrfSdk ``` Then during the build the `buils.sh` script tries to execute `GetNrfSdk` again, which fails as the files already exist resulting in the following error: ``` replace /opt/nRF5_SDK_15.3.0_59ac345/components/802_15_4/api/HAL/hal_atomic.h? [y]es, [n]o, [A]ll, [N]one, [r]ename: NULL ``` Fix this by reverting the `NRF_SDK_VER` to the folder name in the zip archive and by some character replacement generate the download URL from the above (the download is in lower-case without the `_` and `.` characters). Furthermore add safeguards to check after the `GetNrfSdk` call if the expected folder is really created. Then we have an error early during container image creation if the contents of the zip-archive are unexpected.
1 parent 9fb35cc commit 6f2a661

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

docker/build.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ export npm_config_cache="${NPM_DIR}"
1717

1818
export BUILD_TYPE=${BUILD_TYPE:=Release}
1919
export GCC_ARM_VER=${GCC_ARM_VER:="10.3-2021.10"}
20-
export NRF_SDK_VER=${NRF_SDK_VER:="nrf5sdk153059ac345"}
20+
export NRF_SDK_VER=${NRF_SDK_VER:="nRF5_SDK_15.3.0_59ac345"}
21+
# convert to lower case and remove _ and . character
22+
# the download URL uses the SLUG, but the extracted folder is named like the original value
23+
NRF_SDK_VER_SLUG=${NRF_SDK_VER,,}
24+
export NRF_SDK_VER_SLUG=${NRF_SDK_VER_SLUG//[_.]/}
2125

2226
MACHINE="$(uname -m)"
2327
[ "$MACHINE" = "arm64" ] && MACHINE="aarch64"
@@ -47,17 +51,29 @@ main() {
4751

4852
GetGcc() {
4953
wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/$GCC_ARM_VER/$GCC_ARM_PATH-$MACHINE-linux.tar.bz2 -O - | tar -xj -C $TOOLS_DIR/
54+
if [ ! -d "$TOOLS_DIR/$GCC_ARM_PATH" ]; then
55+
echo "missing GCC path: $TOOLS_DIR/$GCC_ARM_PATH"
56+
return 1
57+
fi
5058
}
5159

5260
GetMcuBoot() {
5361
git clone https://github.com/mcu-tools/mcuboot.git "$TOOLS_DIR/mcuboot"
5462
pip3 install -r "$TOOLS_DIR/mcuboot/scripts/requirements.txt"
63+
if [ ! -d "$TOOLS_DIR/mcuboot" ]; then
64+
echo "missing mcuboot path: $TOOLS_DIR/mcuboot"
65+
return 1
66+
fi
5567
}
5668

5769
GetNrfSdk() {
58-
wget -q "https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/sdks/nrf5/binaries/$NRF_SDK_VER.zip" -O /tmp/$NRF_SDK_VER
70+
wget -q "https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/sdks/nrf5/binaries/$NRF_SDK_VER_SLUG.zip" -O /tmp/$NRF_SDK_VER
5971
unzip -q /tmp/$NRF_SDK_VER -d "$TOOLS_DIR/"
6072
rm /tmp/$NRF_SDK_VER
73+
if [ ! -d "$TOOLS_DIR/$NRF_SDK_VER" ]; then
74+
echo "missing NRF_SDK path: $TOOLS_DIR/$NRF_SDK_VER"
75+
return 1
76+
fi
6177
}
6278

6379
CmakeGenerate() {

0 commit comments

Comments
 (0)