Skip to main content

Develop with Zephyr on the Wio-LR2021 Dev Kit

Introduction​

The Wio-LR2021 Dev Kit pairs an ESP32-S3 with a Semtech LR2021 sub-GHz transceiver. The Zephyr repository for this board wraps that hardware into a regular west workspace: an out-of-tree BOARD definition, a SHIELD for the camera and audio hat, and several sample applications that you can build, flash and verify.


You do not need previous Zephyr experience, but you should be comfortable with C, a command line and a soldering-free dev kit. This page takes you from an empty folder to a booting board. The samples are documented in the two companion pages:

note

Everything here is plain upstream Zephyr: no vendor fork, no hidden SDK. The board support is a normal out-of-tree board, and the samples are normal Zephyr applications.

Preparation​

ItemNotes
Wio-LR2021 Dev KitThe ESP32-S3 main board with the LR2021 transceiver
USB-C data cableMust carry data, not only power
Sub-GHz antennaScrews onto the SUB-1G connector; fit it before any radio sample runs
Media Hat (optional)Required for the media samples only
Grove SHT40 (optional)Required for the Grove sample only
LoRaWAN gateway (optional)Required for the uplink sample only

On the software side you need Git, CMake, Ninja, dtc, Python 3.10 or newer and about 5 GB of disk space. macOS, Linux and WSL2 are supported. Native Windows is not, because the build uses host tools that expect a POSIX shell.

caution

The LR2021 can be damaged when it transmits without an antenna. Screw the Sub-GHz antenna onto the SUB-1G connector before you flash or run any radio sample, and keep the board away from the antenna of a gateway during the first test. The LR-2.4G connector is not used in this tutorial, but you should also make sure that you have connected it with the corresponding antenna before running any applications involving the 2.4GHz channel.

Introduction to the Zephyr workspace​

The checkout is a west workspace with a T2 star topology of Zephyr project: the manifest repository wio-lr2021-dev-kit-zephyr/ holds the board definition, the shield and the samples, and describes where every other repository comes from and which revision to check out.

wio-lr2021-workspace/             west workspace root
├── wio-lr2021-dev-kit-zephyr/ ★ manifest repository, the one you clone and edit
│ └── west.yml pins zephyr v4.4.0, usp_zephyr v1.0.0, usp v1.0.0
├── zephyr/ ┐
├── usp_zephyr/ ├ cloned by `west update` from those pins
├── modules/lib/usp/ ┘
└── modules/... other imported modules

west init reads that manifest and west update clones or checks out every pinned project next to it. You never edit those upstream trees, and you never copy them into your own repository.

ProjectPathVersionWhy it is here
zephyrzephyr/v4.4.0The RTOS, drivers, devicetree, LVGL and networking stack
usp_zephyrusp_zephyr/v1.0.0Semtech USP for Zephyr: LR2021 driver, LoRa Basics Modem, RAC API, shields
uspmodules/lib/usp/v1.0.0The LoRa Basics Modem library used through usp_zephyr
mcubootbootloader/mcuboot/pinned by ZephyrBootloader sources, not used by these samples
Espressif HALsmodules/hal/pinned by ZephyrSoC support, Wi-Fi and Bluetooth blobs

The manifest imports only the modules this workspace needs (hal_espressif, hal_xtensa, mcuboot, mbedtls, tf-psa-crypto, tinycrypt, lvgl, hostap, lora-basics-modem), so the tree stays small. If you need other modules, you can add them in the west.yml with the corresponding meta data of the repository:

manifest:
projects:
- name: zephyr
url: https://github.com/zephyrproject-rtos/zephyr
revision: v4.4.0
import:
name-allowlist:
- hal_espressif
- hal_xtensa
- mcuboot
- mbedtls
- tf-psa-crypto
- tinycrypt
- lvgl
- hostap
- lora-basics-modem
... <--- Add the modules you need starting with '- '

After west update the folder looks like this:

wio-lr2021-workspace/                  # west workspace root
├── .west/config # manifest path, Zephyr base, build options
├── .venv/ # Python virtual environment (not in git)
├── wio-lr2021-dev-kit-zephyr/ # ★ the manifest repository you edit
│ ├── west.yml # workspace manifest
│ ├── boards/
│ │ ├── seeed/wio_lr2021_dev_kit/ # out-of-tree board definition
│ │ │ ├── board.yml
│ │ │ ├── wio_lr2021_dev_kit_procpu.dts
│ │ │ ├── wio_lr2021_dev_kit-pinctrl.dtsi
│ │ │ ├── wio_lr2021_dev_kit_procpu_defconfig
│ │ │ ├── wio_lr2021_dev_kit_appcpu.dts # second core, peripherals stripped
│ │ │ ├── board.cmake # west flash via OpenOCD
│ │ │ └── support/openocd.cfg
│ │ └── shields/seeed_wio_lr2021_dev_kit_media_hat/
│ │ ├── shield.yml
│ │ └── seeed_wio_lr2021_dev_kit_media_hat.overlay
│ ├── wio_lr2021_dev_kit_test/ # board self-test
│ ├── wio_lr2021_dev_kit_display_test/
│ ├── wio_lr2021_dev_kit_grove_test/
│ ├── wio_lr2021_dev_kit_camera_test/
│ ├── wio_lr2021_dev_kit_RF_test/
│ ├── wio_lr2021_dev_kit_flrc_test/
│ └── wio_lr2021_dev_kit_lorawan_uplink/
├── zephyr/ # Zephyr v4.4.0
├── bootloader/mcuboot/
├── modules/
│ ├── hal/{espressif,xtensa}/
│ ├── crypto/{mbedtls,tf-psa-crypto}/
│ └── lib/{gui/lvgl,hostap,lora-basics-modem,usp}/
└── usp_zephyr/ # Semtech USP for Zephyr

Every application folder has the same shape: CMakeLists.txt, prj.conf, README.md, src/ and, when it needs to add devicetree nodes, an optional boards/wio_lr2021_dev_kit_esp32s3_procpu.overlay.

How a build is assembled​

A Zephyr build is the merge of four independent layers. Knowing which layer owns what saves you time later.

LayerWhere it livesWhat it contributes
Boardwio-lr2021-dev-kit-zephyr/boards/seeed/wio_lr2021_dev_kit/Pins, buses, regulators, aliases, console and flash layout
Shieldwio-lr2021-dev-kit-zephyr/boards/shields/seeed_wio_lr2021_dev_kit_media_hat/Camera, audio and the shield power rails
Application devicetree<app>/boards/*.overlayNodes only this sample needs, such as i2c1
Application config<app>/prj.conf and <app>/KconfigWhich drivers and libraries are compiled in

Two details are easy to miss:

  • The board is out of tree (the devicetree has not yet been merged into the Zephyr mainline), so every build needs -DBOARD_ROOT=../ (relative to the application folder, pointing at wio-lr2021-dev-kit-zephyr/). Without it, CMake reports that the board does not exist.
  • The board target has two qualifiers. Use wio_lr2021_dev_kit/esp32s3/procpu for anything that touches hardware; appcpu has no peripherals and exists only for the second core.

Set up the environment​

Install the build prerequisites​

brew install cmake ninja dtc gperf python3 git

Clone and initialize the workspace​

mkdir wio-lr2021-workspace
cd wio-lr2021-workspace
git clone github.com/DavidDu-Seeed/wio-lr2021-dev-kit-zephyr

The workspace root only holds the clone, the modules and the virtual environment. Create the Python environment next, because west itself lives inside it:

python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip west

Then let the manifest fill in the rest of the workspace:

west init -l wio-lr2021-dev-kit-zephyr
west update
pip install -r zephyr/scripts/requirements.txt

west init -l wio-lr2021-dev-kit-zephyr registers the clone as the manifest repository of the workspace that already exists around it, which is why no URL is needed at this step. west update then clones Zephyr v4.4.0, the Semtech modules and every imported module, and can take five to ten minutes on a first run.

tip

Keep using .venv/bin/west or re-activate .venv in every new shell. The Espressif build system looks for esptool on PATH and stops with esptool>=5.0.2 not found in PATH when the environment is inactive.

Install the Zephyr SDK​

The SDK provides the Xtensa cross compiler and the host tools. Install only the ESP32-S3 toolchain, which keeps the download at a few hundred megabytes instead of several gigabytes:

west sdk install -t xtensa-espressif_esp32s3_zephyr-elf

The SDK lands in ~/zephyr-sdk-<version>, which is where Zephyr looks by default. If you install it somewhere else, either export the path or pass it on every build:

export ZEPHYR_SDK_INSTALL_DIR=/opt/zephyr-sdk-1.0.1

Fetch the Espressif Wi-Fi blobs​

The camera sample runs a Wi-Fi access point, and Espressif ships the Wi-Fi firmware as prebuilt libraries:

west blobs fetch hal_espressif
note

The other samples do not need the blobs. Fetching them once is enough for the whole workspace.

Verify the workspace​

west topdir
west list

west topdir prints the workspace root, west list prints every project and its revision.

Build, flash and observe output​

Every sample is built and flashed the same way. This example builds the board self-test from the application wio_lr2021_dev_kit_test directory:

cd wio-lr2021-dev-kit-zephyr/wio_lr2021_dev_kit_test
west build -p always -d build_test -b wio_lr2021_dev_kit/esp32s3/procpu -- -DBOARD_ROOT=../
west flash
FlagWhy it is there
-p alwaysWipes the build folder first, so a stale devicetree cannot survive a config change
-d build_testKeeps one build folder per sample; without it everything lands in ./build
-DBOARD_ROOT=../Tells CMake where the out-of-tree board lives, relative to the application folder
-b wio_lr2021_dev_kit/esp32s3/procpuSelects the board and the main core
note

Semtech's usp_zephyr module ships its own devicetree for the LR2021, and this workspace disables that layer on purpose. The next subsection explains why.

west flash uses Espressif OpenOCD over the USB-JTAG interface of the ESP32-S3, so no button sequence is needed. The console is the same USB cable: open the port at 115200 baud, 8 data bits, no parity, 1 stop bit.

# macOS
screen /dev/tty.usbmodem* 115200
# Linux
picocom -b 115200 /dev/ttyACM0

The self-test prints a line for every check and ends with a summary. A healthy board looks like this:

*** Booting Zephyr OS build v4.4.0 ***
[00:00:00.320,000] <inf> board_test: Wio-LR2021 Dev Kit board test
[00:00:00.321,000] <inf> board_test: --- I2C0 bus, PCA9535 expander and SH1106 OLED ---
[00:00:00.322,000] <inf> board_test: [PASS] I2C0 controller is ready
[00:00:00.331,000] <inf> board_test: I2C scan found 2 device(s)
[00:00:00.332,000] <inf> board_test: 0x3d
[00:00:00.332,000] <inf> board_test: [PASS] SH1106 OLED answers
...
[00:00:05.481,000] <inf> board_test: --- SPI2 bus and LR2021 transceiver ---
[00:00:05.492,000] <inf> board_test: [PASS] GetVersion command completed
[00:00:05.492,000] <inf> board_test: LR2021 firmware version: 1.24
[00:00:05.495,000] <inf> board_test: ================ TEST SUMMARY ================
[00:00:05.496,000] <inf> board_test: I2C0 bus : PASS
[00:00:05.496,000] <inf> board_test: User LED : PASS
[00:00:05.497,000] <inf> board_test: Buttons : PASS
[00:00:05.497,000] <inf> board_test: SPI2 bus : PASS
[00:00:05.498,000] <inf> board_test: 25 checks, 0 failed
caution

If the log stops after Booting Zephyr, the firmware is running but the console port is wrong. Close other serial terminals first: only one program can own the port.

Why the Semtech shield is disabled​

The usp_zephyr module is Semtech's upstream integration, and it ships its own devicetree for the LR2021: a semtech_wio_lr2021 shield that puts a lora@0 node on the XIAO SPI connector and sets the zephyr,lorawan-transceiver chosen node. That description does not fit this board, where the transceiver sits on spi2 with its own reset, busy and interrupt pins and the board devicetree defines the node itself.

The workspace therefore switches the module's board and shield layer off, with two local edits that are not in upstream:

EditFileEffect
board_root commented outusp_zephyr/zephyr/module.ymlZephyr never scans the module for boards or shields
boards/ renamed to boards.bak/usp_zephyr/The shields and the XIAO nRF54L15 board stay out of the build but remain readable

dts_root: . stays enabled on purpose: the module still provides the bindings (semtech,lr2021, semtech,lr20xx-dios) that the board devicetree needs, only the shield DTS files are gone.

Two consequences are worth remembering:

  • Pass the board target only. Adding -DSHIELD=semtech_wio_lr2021 stops the configure step with Invalid SHIELD; see above., because the shield is no longer registered.
  • The samples under usp_zephyr/samples/usp/ are written for xiao_nrf54l15 with that shield, so their README commands do not apply here. The applications in wio-lr2021-dev-kit-zephyr/ replace them and carry their own devicetree overlays.
caution

Re-fetching or resetting the module (west update, or a fresh git checkout inside usp_zephyr) brings both files back, so reapply the two edits if you ever reset it.

Applications at a glance​

ApplicationWhat it validatesExtra build arguments
wio_lr2021_dev_kit_testBoard bring-up: I2C, expander, OLED, LED, buttons, LR2021 versionNone
wio_lr2021_dev_kit_display_testSH1106 framebuffer, six test patterns, LVGL widgetsNone
wio_lr2021_dev_kit_grove_testGrove power rail, I2C1 scan, SHT40 samplingNone
wio_lr2021_dev_kit_camera_testGC2145 capture, Wi-Fi access point, browser viewer-DSHIELD=seeed_wio_lr2021_dev_kit_media_hat
wio_lr2021_dev_kit_RF_testLR2021 SPI, IRQ, timers, TX and RX pathsNone
wio_lr2021_dev_kit_flrc_testFLRC link between two boards, PER and BER modes-DEXTRA_CONF_FILE=rx.conf for the receiver
wio_lr2021_dev_kit_lorawan_uplinkOTAA join and periodic uplinks through LoRa Basics ModemCredentials in boards/user_keys.overlay.local

Run them in that order. Each sample leaves the board in a known state, and the radio samples assume the bus and IRQ paths were already proven by the self-test.

Troubleshooting​

Q1: CMake cannot find the board

The usual cause is a missing or misplaced -DBOARD_ROOT. It must be relative to the application folder, so ../ from wio-lr2021-dev-kit-zephyr/wio_lr2021_dev_kit_test points at wio-lr2021-dev-kit-zephyr/, which contains boards/. Running the build from another directory or omitting the argument produces Board "wio_lr2021_dev_kit" not found.

Q2: The build stops with "esptool>=5.0.2 not found in PATH"

Activate the virtual environment before building:

source .venv/bin/activate

The check runs inside the Espressif SoC CMake code, so calling .venv/bin/west directly is not enough when esptool is not on PATH.

Q3: "west update" stops with a git error

The Semtech projects use Git submodules. Remove the half-fetched project and retry:

rm -rf usp_zephyr modules/lib/usp
west update

If the failure is a network timeout, retry with west update --narrow -o=--depth=1 to fetch shallow clones.

Q4: "west flash" cannot open the debugger

Check that the USB cable carries data, then put the board into download mode manually: hold BOOT, press and release RESET, release BOOT, and run west flash again. On Linux, add a udev rule for the ESP32-S3 USB-JTAG device if the port is only writable by root.

Q5: The console stays silent or prints garbage

Confirm three things: the port matches /dev/tty.usbmodem* on macOS or /dev/ttyACM* on Linux, the terminal is at 115200 baud and 8N1, and no other program holds the port. A board that was just flashed reboots by itself, so open the terminal again after west flash.

Q6: Zephyr reports that no toolchain was found

The SDK is not where Zephyr expects it. Run west sdk list to see what is installed, then pass the location explicitly:

west build ... -- -DBOARD_ROOT=../ -DZEPHYR_SDK_INSTALL_DIR=/path/to/zephyr-sdk-1.0.1

Resources​

Tech Support & Product Discussion​

Thank you for choosing our products! We are here to provide you with different support to ensure that your experience with our products is as smooth as possible. We offer several communication channels to cater to different preferences and needs.

Loading Comments...