Browse Source

container missing lib/config

pull/2944/head
Mohamad EL CHAMAA 4 weeks ago
parent
commit
632e28ecfa
  1. 7
      .devcontainer/devcontainer.json
  2. 132
      .devcontainer/setup-zephyr.sh

7
.devcontainer/devcontainer.json

@ -6,7 +6,7 @@
"ghcr.io/rocker-org/devcontainer-features/apt-packages:1": {
"packages": [
"sudo",
// Zephyr / nRF Connect SDK host build dependencies
// Mainline Zephyr host build dependencies (companion is NOT built on NCS)
"git",
"cmake",
"ninja-build",
@ -21,7 +21,10 @@
"libsdl2-dev",
"libmagic1",
"python3-venv",
"python3-dev"
"python3-dev",
// pyocd (CMSIS-DAP flash/RTT for the XIAO nRF54L15 on-board debugger)
"libusb-1.0-0",
"libhidapi-hidraw0"
]
}
},

132
.devcontainer/setup-zephyr.sh

@ -1,32 +1,57 @@
#!/usr/bin/env bash
#
# Installs the Nordic nRF Connect SDK (NCS) + Zephyr toolchain *alongside* the
# existing PlatformIO setup, so MeshCore can be ported to the Zephyr-based
# Seeed XIAO nRF54L15 without disturbing the ESP32/nRF52/RP2040/STM32 builds.
# Provisions everything the Zephyr MeshCore companion
# (zephyr-port/07_companion) needs, *alongside* the existing PlatformIO setup,
# so the ESP32/nRF52/RP2040/STM32 builds are left untouched.
#
# This is intentionally idempotent: re-running it skips work that's already done.
# It is HEAVY (multi-GB download + Zephyr SDK). Expect the first run to take a while.
# The companion is built on **mainline Zephyr** (NOT the Nordic nRF Connect SDK):
# see zephyr-port/07_companion/README.md. This script therefore installs:
# 1. a west/Zephyr workspace from zephyrproject-rtos/zephyr -> $ZEPHYR_WORKSPACE
# 2. the matching Zephyr SDK (compilers) via `west sdk install`
# 3. pyocd (CMSIS-DAP flash/RTT for the XIAO's on-board debugger)
# 4. arduino-cli + the three Arduino libraries the CMake references by
# absolute path ($HOME/Arduino/libraries/{RadioLib,Crypto,base64})
#
# It is intentionally idempotent: re-running skips work that's already done.
# It is HEAVY (multi-GB clone + Zephyr SDK). Expect the first run to take a while.
#
# Usage:
# bash .devcontainer/setup-zephyr.sh
#
# Override defaults via env, e.g.:
# NCS_REV=v3.0.0 NCS_WORKSPACE=$HOME/ncs bash .devcontainer/setup-zephyr.sh
# Override defaults via env, track the moving mainline tip instead of the
# pinned commit:
# ZEPHYR_REV=main bash .devcontainer/setup-zephyr.sh
#
set -euo pipefail
# --- Tunables ----------------------------------------------------------------
# Pick the latest NCS release that ships the Seeed XIAO nRF54L15 board
NCS_REV="${NCS_REV:-v2.9.0}"
NCS_WORKSPACE="${NCS_WORKSPACE:-$HOME/ncs}"
# Mainline Zephyr revision. Pinned to a known-good commit on `main` that reports
# VERSION 4.4.99 and ships the Seeed XIAO nRF54L15 board
# (boards/seeed/xiao_nrf54l15). Override with ZEPHYR_REV=main to track the tip.
# https://docs.zephyrproject.org/latest/boards/seeed/xiao_nrf54l15/doc/index.html
ZEPHYR_REV="${ZEPHYR_REV:-c9a40340e8e3b94d6660beb98f4d9a858cfd937e}"
ZEPHYR_WORKSPACE="${ZEPHYR_WORKSPACE:-$HOME/zephyrproject}"
VENV_DIR="${VENV_DIR:-$HOME/.zephyr-venv}"
# The board target the companion builds for (README + CMakeLists).
BOARD="${BOARD:-xiao_nrf54l15/nrf54l15/cpuapp}"
# Arduino libraries the companion's CMakeLists.txt pulls in by absolute path
# ($HOME/Arduino/libraries/...). Versions match a known-good build; RadioLib
# 7.7.1 already carries the LR2021 driver *and* the multi-SF side-detector API
# (setSideDetector / setLoRaSideDetCad) upstream, so no fork/patch is needed.
ARDUINO_DIR="${ARDUINO_DIR:-$HOME/Arduino}"
RADIOLIB_VER="${RADIOLIB_VER:-7.7.1}"
CRYPTO_VER="${CRYPTO_VER:-0.4.0}"
BASE64_VER="${BASE64_VER:-1.3.0}"
# -----------------------------------------------------------------------------
echo ">> NCS revision : ${NCS_REV}"
echo ">> Workspace : ${NCS_WORKSPACE}"
echo ">> Python venv : ${VENV_DIR}"
echo ">> Zephyr revision : ${ZEPHYR_REV}"
echo ">> Workspace : ${ZEPHYR_WORKSPACE}"
echo ">> Python venv : ${VENV_DIR}"
echo ">> Board : ${BOARD}"
# 1) Isolated Python venv for west (don't pollute the PlatformIO/pipx env).
# 1) Isolated Python venv for west + pyocd (don't pollute the PlatformIO/pipx env).
if [ ! -d "${VENV_DIR}" ]; then
echo ">> Creating Python venv for west..."
python3 -m venv "${VENV_DIR}"
@ -34,17 +59,18 @@ fi
# shellcheck disable=SC1091
source "${VENV_DIR}/bin/activate"
pip install --upgrade pip wheel >/dev/null
pip install --upgrade west >/dev/null
# west (build system) + pyocd (CMSIS-DAP flash & RTT console for the XIAO).
pip install --upgrade west pyocd >/dev/null
# 2) Initialise the NCS workspace (skip if already initialised).
if [ ! -d "${NCS_WORKSPACE}/.west" ]; then
echo ">> west init NCS workspace (${NCS_REV})..."
west init -m https://github.com/nrfconnect/sdk-nrf --mr "${NCS_REV}" "${NCS_WORKSPACE}"
# 2) Initialise the mainline Zephyr workspace (skip if already initialised).
if [ ! -d "${ZEPHYR_WORKSPACE}/.west" ]; then
echo ">> west init mainline Zephyr workspace (${ZEPHYR_REV})..."
west init -m https://github.com/zephyrproject-rtos/zephyr --mr "${ZEPHYR_REV}" "${ZEPHYR_WORKSPACE}"
else
echo ">> NCS workspace already initialised, skipping west init."
echo ">> Zephyr workspace already initialised, skipping west init."
fi
cd "${NCS_WORKSPACE}"
cd "${ZEPHYR_WORKSPACE}"
echo ">> west update (this is the slow part)..."
west update
west zephyr-export
@ -61,38 +87,58 @@ west sdk install || {
echo "!! Zephyr SDK manually: https://docs.zephyrproject.org/latest/develop/getting_started/index.html"
}
# 5) Sanity build: confirm the XIAO nRF54L15 target actually compiles here.
echo ">> Smoke-building Zephyr 'hello_world' for seeed/xiao_nrf54l15..."
if west build -p always -b seeed/xiao_nrf54l15 zephyr/samples/hello_world -d /tmp/xiao_hello; then
# 5) arduino-cli + the Arduino libraries the companion CMake references by
# absolute path. arduino-cli's default sketchbook is $HOME/Arduino, so the
# libraries land in $HOME/Arduino/libraries/{RadioLib,Crypto,base64} exactly
# where CMakeLists.txt looks.
if ! command -v arduino-cli >/dev/null 2>&1; then
echo ">> Installing arduino-cli (user space -> ~/.local/bin)..."
mkdir -p "$HOME/.local/bin"
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh \
| BINDIR="$HOME/.local/bin" sh
export PATH="$HOME/.local/bin:$PATH"
fi
# Keep libraries in $HOME/Arduino so they match the CMake absolute paths.
arduino-cli config init --overwrite >/dev/null 2>&1 || true
arduino-cli config set directories.user "${ARDUINO_DIR}" >/dev/null 2>&1 || true
echo ">> Installing Arduino libraries (RadioLib/Crypto/base64) into ${ARDUINO_DIR}/libraries..."
arduino-cli lib update-index >/dev/null
arduino-cli lib install \
"RadioLib@${RADIOLIB_VER}" \
"Crypto@${CRYPTO_VER}" \
"base64@${BASE64_VER}"
# 6) Sanity build: confirm the XIAO nRF54L15 target actually compiles here.
echo ">> Smoke-building Zephyr 'hello_world' for ${BOARD}..."
if west build -p always -b "${BOARD}" zephyr/samples/hello_world -d /tmp/xiao_hello; then
echo ">> OK: native Zephyr toolchain can build for the XIAO nRF54L15."
else
echo "!! Zephyr build for seeed/xiao_nrf54l15 FAILED."
echo "!! Likely cause: NCS_REV=${NCS_REV} predates XIAO nRF54L15 board support."
echo "!! Re-run with a newer release, e.g. NCS_REV=v3.0.0 bash .devcontainer/setup-zephyr.sh"
echo "!! Zephyr build for ${BOARD} FAILED."
echo "!! Likely cause: ZEPHYR_REV=${ZEPHYR_REV} predates XIAO nRF54L15 board support,"
echo "!! or the board target string changed. Confirm the board at:"
echo "!! https://docs.zephyrproject.org/latest/boards/seeed/xiao_nrf54l15/doc/index.html"
fi
cat <<EOF
============================================================================
Zephyr / NCS toolchain ready (workspace: ${NCS_WORKSPACE}).
Zephyr toolchain + companion deps ready.
To use it in a shell:
source ${VENV_DIR}/bin/activate
source ${NCS_WORKSPACE}/zephyr/zephyr-env.sh
PlatformIO is untouched and still drives the existing ESP32/nRF52/etc. variants.
Zephyr workspace : ${ZEPHYR_WORKSPACE} (mainline, VERSION 4.4.99)
Zephyr base : ${ZEPHYR_WORKSPACE}/zephyr
Python venv : ${VENV_DIR}
Arduino libs : ${ARDUINO_DIR}/libraries/{RadioLib,Crypto,base64}
Flash/RTT tool : pyocd (target: nrf54)
--- Arduino-Zephyr core (the recommended on-ramp; see tools/lr2021_nrf54l15_smoke) ---
The nRF54L15 Arduino core is itself Zephyr-based and reuses this NCS install.
Install arduino-cli + the core, then build the smoke test:
To build & flash the companion:
source ${VENV_DIR}/bin/activate
export ZEPHYR_BASE=${ZEPHYR_WORKSPACE}/zephyr
# arduino-cli (user space)
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
cd zephyr-port/07_companion
west build -b ${BOARD} -d build . --pristine
pyocd flash -t nrf54 -e chip build/zephyr/zephyr.hex
pyocd reset -t nrf54
# TODO: add the nRF54L15 Arduino core's Boards Manager URL, then:
# arduino-cli config add board_manager.additional_urls <CORE_INDEX_JSON_URL>
# arduino-cli core update-index
# arduino-cli core install <core:nrf54l>
# Ref: https://blog.adafruit.com/2026/02/17/an-arduino-core-for-nrf54l15-zephyr-based/
PlatformIO is untouched and still drives the existing ESP32/nRF52/etc. variants.
============================================================================
EOF

Loading…
Cancel
Save