-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·60 lines (53 loc) · 2.11 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·60 lines (53 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
#
# Fetch the Nordic nRF5 SDK 17.1.0 and apply this project's overlay so the
# firmware can be built. The SDK itself is NOT committed (large, 3rd-party,
# downloadable) — this script reconstructs the buildable tree under ./sdk/.
#
# ./setup.sh # auto-detect arm-none-eabi-gcc on PATH
# GNU_INSTALL_ROOT=/opt/gcc/bin/ ./setup.sh # or point it at a specific toolchain
#
set -euo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
SDK_VER="17.1.0"
SDK_ID="nRF5_SDK_17.1.0_ddde560"
SDK_ZIP="nrf5_sdk_${SDK_VER}.zip"
SDK_URL="https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/sdks/nrf5/binaries/${SDK_ZIP}"
SDK_DIR="${HERE}/sdk/${SDK_ID}"
mkdir -p "${HERE}/sdk"
# 1. Download + unzip the SDK (skip if already present)
if [ ! -d "${SDK_DIR}" ]; then
if [ ! -f "${HERE}/sdk/${SDK_ZIP}" ]; then
echo ">> Downloading nRF5 SDK ${SDK_VER} (~125 MB) ..."
curl -fL --retry 3 -o "${HERE}/sdk/${SDK_ZIP}" "${SDK_URL}"
fi
echo ">> Unzipping SDK ..."
unzip -q "${HERE}/sdk/${SDK_ZIP}" -d "${HERE}/sdk"
fi
# 2. Apply the project overlay (the modified SDK files)
echo ">> Applying overlay ..."
cp -r "${HERE}/overlay/." "${SDK_DIR}/"
# 3. Point the SDK GCC at your arm-none-eabi toolchain
GCC_BIN="${GNU_INSTALL_ROOT:-}"
if [ -z "${GCC_BIN}" ] && command -v arm-none-eabi-gcc >/dev/null 2>&1; then
GCC_BIN="$(dirname "$(command -v arm-none-eabi-gcc)")/"
fi
if [ -n "${GCC_BIN}" ]; then
GCC_VER="$("${GCC_BIN}arm-none-eabi-gcc" -dumpversion)"
cat > "${SDK_DIR}/components/toolchain/gcc/Makefile.posix" <<EOF
GNU_INSTALL_ROOT ?= ${GCC_BIN}
GNU_VERSION ?= ${GCC_VER}
GNU_PREFIX ?= arm-none-eabi
EOF
echo ">> Toolchain: ${GCC_BIN} (gcc ${GCC_VER})"
else
echo "!! arm-none-eabi-gcc not found. Re-run with GNU_INSTALL_ROOT=/path/to/bin/ ,"
echo " or edit ${SDK_DIR}/components/toolchain/gcc/Makefile.posix"
fi
cat <<EOF
>> Setup done. Build the firmware:
cd "${SDK_DIR}/examples/ble_peripheral/ble_app_hids_keyboard/pca10100/s140/armgcc" && make
Output: _build/nrf52833_xxaa.hex
>> Flash the micro:bit v2:
${HERE}/flash.sh
EOF