Zephyr Radio Samples on the Wio-LR2021 Dev Kit

Introduction
The samples cover the radio, and they climb the same stack in order:
- RF self-test talks to the LR2021 through the Semtech porting layer: SPI, interrupt line, timers and the TX/RX paths.
- FLRC link test measures a real link between two boards.
- LoRaWAN uplink runs LoRa Basics Modem on top of the same driver and joins a network server.
Screw the sub-GHz antenna onto the SUB-1G connector before you run the tests. Transmitting into an open port can destroy the power amplifier of the LR2021.
1. Wio-LR2021 RF self-test
This application is the porting test from Semtech's usp_zephyr module, adapted to this board. It runs fourteen cases and prints one verdict each. Most of them check the glue that LoRa Basics Modem needs: the HAL time base, the radio interrupt, both timers, the random generator and the RX and TX configuration timings.
cd .../wio-lr2021-dev-kit-zephyr/wio_lr2021_dev_kit_RF_test
west build -p always -b wio_lr2021_dev_kit/esp32s3/procpu -d build_rf -- -DBOARD_ROOT=../
west flash -d build_rf
The radio porting test prints bare lines through its own reporting macros, so its excerpt has no Zephyr prefix. The FLRC and LoRaWAN excerpts below also omit the prefix, so that the message text stays readable.
[PASS] SPI / LR2021 version
[PASS] Radio IRQ (DIO8)
[PASS] RF TX
[PASS] RF RX noise floor
[SKIP] RF link
[PASS] HAL time base
...
================ TEST SUMMARY ================
14 checks, 0 failed, 1 skipped
RF link is skipped because the default configuration is a single board. To measure a link, build one board as transmitter and one as receiver. Create rx.conf next to prj.conf, because the sample does not ship one:
CONFIG_RF_TEST_LINK_ROLE_NONE=n
CONFIG_RF_TEST_LINK_ROLE_RX=y
cd .../wio-lr2021-dev-kit-zephyr/wio_lr2021_dev_kit_RF_test
west build -p always -b wio_lr2021_dev_kit/esp32s3/procpu -d build_rf_rx -- -DBOARD_ROOT=../ -DEXTRA_CONF_FILE=rx.conf
west flash -d build_rf_rx
Flash the receiver first and leave it running, then flash the transmitter. Both boards must share the same rf-test-freq-hz, rf-test-sync-word, rf-test-payload-len and rf-test-link-count in the same overlay file.
Every case starts from the same radio setup, which is worth reading once because the order is not arbitrary:
/* reset_init_radio(), then ... (return checks elided) */
smtc_modem_hal_irq_config_radio_irq( callback, NULL ); /* DIO8 (GPIO45) -> GPIO interrupt */
smtc_modem_hal_start_radio_tcxo( ); /* 32 MHz TCXO, tick based */
smtc_modem_hal_set_ant_switch( tx ); /* TX or RX path */
ralf_setup_lora( &modem_radio, params ); /* RAL front end */
ral_set_standby( &( modem_radio.ral ), RAL_STANDBY_CFG_RC );
ral_set_dio_irq_params( &( modem_radio.ral ), irq_mask );
ral_clear_irq_status( &( modem_radio.ral ), RAL_IRQ_ALL );
The transmit case then hands a payload to the radio and waits for the interrupt instead of sleeping for a guessed duration:
if( rf_setup( &rf_link_param, RAL_IRQ_TX_DONE, true, radio_tx_irq_callback ) == false )
{
return TEST_RESULT_FAIL;
}
ral_set_pkt_payload( &( modem_radio.ral ), payload, sizeof( payload ) );
ral_set_tx( &( modem_radio.ral ) );
bool irq_seen = wait_radio_irq( RF_TEST_TX_TIMEOUT_MS );
if( irq_seen == false )
{
rf_test_tx_report_diag( "Timeout: TX_DONE irq not received", elapsed_ms );
return TEST_RESULT_FAIL;
}
Test parameters live in the application overlay, so you can change them without touching C:
| Property | Default | Meaning |
|---|---|---|
rf-test-freq-hz | 868300000 | Carrier, 868.3 MHz |
rf-test-tx-power-dbm | 14 | Output power |
rf-test-payload-len | 50 | Bytes per packet |
rf-test-link-count | 20 | Packets in the link case |
rf-test-sync-word | 0x12 | LoRa sync word, both ends must match |
The porting test expects LR2021 firmware 0x01/0x18. A different version is reported as a failure of the first case, not as a broken board: update the transceiver firmware or adjust the constants before you debug anything else.
2. FLRC link test
FLRC is the high speed mode of the Wio-LR2021: with CRC and a bit-by-bit payload comparison. Two boards run the same application, one as transmitter and one as receiver, and the receiver reports packet error rate, bit error rate, RSSI and throughput.
Build both images from the same source; the role is a Kconfig choice, not a separate application:
cd wio-lr2021-dev-kit-zephyr/wio_lr2021_dev_kit_flrc_test
# transmitter (default role)
west build -p always -b wio_lr2021_dev_kit/esp32s3/procpu -d build_flrc_tx -- -DBOARD_ROOT=../
west flash build_flrc_tx
# receiver, the role comes from the shipped rx.conf
west build -p always -b wio_lr2021_dev_kit/esp32s3/procpu -d build_flrc_rx -- -DBOARD_ROOT=../ -DEXTRA_CONF_FILE=rx.conf
west flash build_flrc_rx
Flash the transmitter on one board and the receiver on the other. The transmitter sends a series of 100 packets with a 200 ms interval, then pauses for two seconds before the next series:
LR2021 firmware: major=0x01 minor=0x18
FLRC TX configuration:
frequency : 866500000 Hz
bitrate : 2600000 bps, BW 2666000 Hz, CR 3/4, BT 0.5
TX seq=0/99 len=255 start=613 ms end=614 ms
TX series 1 done: sent=100, payload=255 B, span=20087 ms, payload rate=10155 bps
The receiver logs each packet, dumps the first bytes of the payload when the check fails, and prints one summary line per series:
RX seq=0/99 len=255 rssi=-32 dBm
RX series 1 done: ok=100/100 lost=0 crc_err=0 PER=0.00% bit_err=0/204000 bits BER=0 ppm rssi_avg=-32.0 dBm payload_rate=10155 bps
| Property | Default | Meaning |
|---|---|---|
flrc-test-freq-hz | 866500000 | Carrier, 866.5 MHz |
flrc-test-tx-power-dbm | 14 | Output power |
flrc-test-payload-len | 255 | Bytes per packet |
flrc-test-packet-count | 100 | Packets per series |
flrc-test-sync-word | 0x90 0x56 0x34 0x12 | Four-byte sync word, both ends must match |
The application overlay lowers the Wio-LR2021 SPI clock to 8 MHz (instead of 16 MHz) to avoid the data corruption during the long RX FIFO reads.
For a bit error rate measurement, build both ends from the BER configuration files. CRC is DISABLED there, so a corrupted payload still counts as received and its bits are compared against the expected pattern:
cd wio-lr2021-dev-kit-zephyr/wio_lr2021_dev_kit_flrc_test
# transmitter
west build -p always -b wio_lr2021_dev_kit/esp32s3/procpu -d build_flrc_tx_ber -- -DBOARD_ROOT=../ -DEXTRA_CONF_FILE=ber_tx.conf
west flash build_flrc_tx_ber
# receiver, stops after three series
west build -p always -b wio_lr2021_dev_kit/esp32s3/procpu -d build_flrc_rx_ber -- -DBOARD_ROOT=../ -DEXTRA_CONF_FILE=ber_rx.conf
west flash build_flrc_rx_ber
Both ends of a link must use the same CRC mode. Mixing ber_*.conf with the normal configuration produces a link that never reports a valid packet.
3. LoRaWAN uplink
The LoRaWAN uplink sample puts LoRa Basics Modem on top of the same driver. It joins a network server over OTAA, sends three uplinks on port 101 five seconds apart, then keeps a periodic uplink on the same port through a 60-second alarm. A USER press sends the uplink counter on port 102.
Put your credentials in a local overlay. The committed boards/user_keys.overlay is just a template which contains only zeroes, and CMakeLists.txt prefers boards/user_keys.overlay.local when that file exists:
/ {
zephyr,user {
user-lorawan-device-eui = <0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00>;
user-lorawan-join-eui = <0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00>;
user-lorawan-gen_app-key = <0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00>;
user-lorawan-app-key = <0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00>;
user-lorawan-region = "US_915";
};
};
Fill in the values of the device registered on your network server. They are byte arrays in the order the server prints them. user-lorawan-region is the region name without the SMTC_MODEM_REGION_ prefix, and it must match the server.
cd wio-lr2021-dev-kit-zephyr/wio_lr2021_dev_kit_lorawan_uplink
west build -p always -b wio_lr2021_dev_kit/esp32s3/procpu -d build_lorawan -- -DBOARD_ROOT=../
west flash -d build_lorawan
Join the LNS:
Serial Output: Device OTAA
[00:00:46.472,000] <inf> lorawan: DevEUI
70 b3 d5 7e d0 07 8a a7 |p..~....
[00:00:46.472,000] <inf> lorawan: JoinEUI
00 00 00 00 00 00 00 00 |........
[00:00:46.472,000] <inf> lorawan: DevNonce 0x1b, stack_id 0
[00:00:46.473,000] <inf> lorawan:
[00:00:46.473,000] <inf> lorawan: *************************************
[00:00:46.473,000] <inf> lorawan: * Send Payload for stack_id = 0
[00:00:46.473,000] <inf> lorawan: *************************************
[00:00:46.473,000] <inf> lorawan: Tx LoRa at 49468 ms: freq:904700000, SF10, BW125, len 23 bytes 22 dBm, fcnt_up 1, toa = 371
[00:00:49.847,000] <inf> lorawan:
[00:00:49.848,000] <inf> lorawan: *************************************
[00:00:49.848,000] <inf> lorawan: * TX DONE
[00:00:49.848,000] <inf> lorawan: *************************************
[00:00:49.909,000] <inf> lorawan:
[00:00:49.909,000] <inf> lorawan: Open Rx1 for Hook Id = 4
[00:00:49.909,000] <inf> lorawan: RX1 LoRa at 54842 ms: freq:925700000, SF10, BW500, sync word = 0x34
[00:00:49.909,000] <inf> lorawan: Timer will expire in 4934 ms
[00:00:54.963,000] <inf> lorawan:
[00:00:54.963,000] <inf> lorawan: *************************************
[00:00:54.963,000] <inf> lorawan: * Receive a Valid downlink Rx1 for stack_id = 0, rssi: -37 dBm, snr: 10 dB
[00:00:54.963,000] <inf> lorawan: *************************************
[00:00:54.963,000] <inf> lorawan: update join procedure
[00:00:54.963,000] <inf> lorawan: DevAddr= 260c2416
[00:00:54.963,000] <inf> lorawan: MacRx1DataRateOffset= 0
[00:00:54.963,000] <inf> lorawan: MacRx2DataRate= 8
[00:00:54.963,000] <inf> lorawan: MacRx1Delay= 5
[00:00:55.023,000] <inf> usp: Event received: JOINED
[00:00:55.023,000] <inf> usp: OTAA join completed in 54 s
[00:00:55.023,000] <inf> usp: [PASS] OTAA join
Uplink Verify:
Once the device has successfully joined the LNS, it will send three consecutive uplinks to verify uplink connectivity:
Serial Output: Uplink Verify
[00:02:29.828,000] <inf> usp: Event received: TXDONE (SENT)
[00:02:29.829,000] <inf> usp: Uplink 3/3 sent
[00:02:29.829,000] <inf> usp: [PASS] Uplink
[00:02:29.829,000] <inf> usp: ================ TEST SUMMARY ================
[00:02:29.829,000] <inf> usp: Modem initialization : PASS
[00:02:29.829,000] <inf> usp: Credentials : PASS
[00:02:29.829,000] <inf> usp: OTAA join : PASS
[00:02:29.829,000] <inf> usp: Uplink : PASS
[00:02:29.829,000] <inf> usp: ----------------------------------------------
[00:02:29.829,000] <inf> usp: 4 checks, 0 failed, 0 skipped
[00:02:29.829,000] <inf> usp: ==============================================
[00:02:29.829,000] <inf> usp: LoRaWAN join/uplink test PASSED
[00:03:29.829,000] <inf> usp: Event received: ALARM
[00:03:29.829,000] <inf> lorawan: add send task
[00:03:29.829,000] <inf> lorawan: User LoRaWAN tx on FPort 101
Periodical Uplink:
Then the device uploads data once per minute using a counter that increments starting from 01 on FPort 101. You can monitor the data in real time on the console as shown below:
Serial Output: Periodical Uplink
[00:03:29.829,000] <inf> lorawan: add send task
[00:03:29.829,000] <inf> lorawan: User LoRaWAN tx on FPort 101
[00:03:29.829,000] <inf> lorawan:
[00:03:29.829,000] <inf> lorawan: *************************************
[00:03:29.829,000] <inf> lorawan: * Send Payload for stack_id = 0
[00:03:29.829,000] <inf> lorawan: *************************************
[00:03:29.830,000] <inf> lorawan: Tx LoRa at 210646 ms: freq:904900000, SF7, BW125, len 17 bytes -6 dBm, fcnt_up 12, toa = 52
[00:03:30.706,000] <inf> lorawan:
[00:03:30.706,000] <inf> lorawan: *************************************
[00:03:30.706,000] <inf> lorawan: * TX DONE
[00:03:30.706,000] <inf> lorawan: *************************************
[00:03:30.706,000] <inf> lorawan:
[00:03:30.706,000] <inf> lorawan: Open Rx1 for Hook Id = 4
[00:03:30.706,000] <inf> lorawan: RX1 LoRa at 215692 ms: freq:926300000, SF7, BW500, sync word = 0x34
[00:03:30.706,000] <inf> lorawan: Timer will expire in 4986 ms
[00:03:35.717,000] <inf> lorawan:
[00:03:35.717,000] <inf> lorawan: *************************************
[00:03:35.717,000] <inf> lorawan: * RX1 Timeout for stack_id = 0
[00:03:35.717,000] <inf> lorawan: *************************************
[00:03:35.717,000] <inf> lorawan:
[00:03:35.718,000] <inf> lorawan: Open Rx2 for Hook Id = 4
[00:03:35.718,000] <inf> lorawan: RX2 LoRa at 216705 ms: freq:923300000, SF12, BW500, sync word = 0x34
[00:03:35.718,000] <inf> lorawan: Timer will expire in 988 ms
[00:03:36.765,000] <inf> lorawan:
[00:03:36.765,000] <inf> lorawan: *************************************
[00:03:36.765,000] <inf> lorawan: * RX2 Timeout for stack_id = 0
[00:03:36.765,000] <inf> lorawan: *************************************
[00:03:36.766,000] <inf> usp: Event received: TXDONE (SENT)

Button-Triggered Uplink:
Serial Output: Button-Triggered Uplink
[00:34:53.643,000] <inf> usp: Button pushed
[00:34:57.973,000] <inf> lorawan:
[00:34:57.973,000] <inf> lorawan: *************************************
[00:34:57.973,000] <inf> lorawan: * TX DONE
[00:34:57.973,000] <inf> lorawan: *************************************
[00:34:57.973,000] <inf> lorawan:
[00:34:57.973,000] <inf> lorawan: Open Rx1 for Hook Id = 4
[00:34:57.973,000] <inf> lorawan: RX1 LoRa at 2102958 ms: freq:923300000, SF7, BW500, sync word = 0x34
[00:34:57.973,000] <inf> lorawan: Timer will expire in 4985 ms
[00:35:02.983,000] <inf> lorawan:
[00:35:02.983,000] <inf> lorawan: *************************************
[00:35:02.983,000] <inf> lorawan: * RX1 Timeout for stack_id = 0
[00:35:02.983,000] <inf> lorawan: *************************************
[00:35:02.983,000] <inf> lorawan:
[00:35:02.983,000] <inf> lorawan: Open Rx2 for Hook Id = 4
[00:35:02.983,000] <inf> lorawan: RX2 LoRa at 2103970 ms: freq:923300000, SF12, BW500, sync word = 0x34
[00:35:02.983,000] <inf> lorawan: Timer will expire in 987 ms
[00:35:04.030,000] <inf> lorawan:
[00:35:04.030,000] <inf> lorawan: *************************************
[00:35:04.030,000] <inf> lorawan: * RX2 Timeout for stack_id = 0
[00:35:04.030,000] <inf> lorawan: *************************************
[00:35:04.030,000] <inf> usp: Event received: TXDONE (SENT)

Scheduled Downlink:
Schedule a downlink packet from the TTN in the Messaging opetion. Specify the frame port (FPort 1) and the data content (AA BB CC DD), then click Schedule downlink. You can observe that the payload now is waiting in the queue, once the next uplink coming, the downlink packet will be sent by the network server and received by the device.
Output: Scheduled Downlink
[00:45:29.842,000] <inf> lorawan: add send task
[00:45:29.843,000] <inf> lorawan: User LoRaWAN tx on FPort 101
[00:45:29.843,000] <inf> lorawan:
[00:45:29.843,000] <inf> lorawan: *************************************
[00:45:29.843,000] <inf> lorawan: * Send Payload for stack_id = 0
[00:45:29.843,000] <inf> lorawan: *************************************
[00:45:29.843,000] <inf> lorawan: Tx LoRa at 2734120 ms: freq:904300000, SF7, BW125, len 17 bytes -6 dBm, fcnt_up 55, toa = 52
[00:45:34.180,000] <inf> lorawan:
[00:45:34.180,000] <inf> lorawan: *************************************
[00:45:34.180,000] <inf> lorawan: * TX DONE
[00:45:34.180,000] <inf> lorawan: *************************************
[00:45:34.181,000] <inf> lorawan:
[00:45:34.181,000] <inf> lorawan: Open Rx1 for Hook Id = 4
[00:45:34.181,000] <inf> lorawan: RX1 LoRa at 2739166 ms: freq:924500000, SF7, BW500, sync word = 0x34
[00:45:34.181,000] <inf> lorawan: Timer will expire in 4986 ms
[00:45:39.193,000] <inf> lorawan:
[00:45:39.193,000] <inf> lorawan: *************************************
[00:45:39.193,000] <inf> lorawan: * Receive a Valid downlink Rx1 for stack_id = 0, rssi: -31 dBm, snr: 11 dB
[00:45:39.193,000] <inf> lorawan: *************************************
[00:45:39.193,000] <inf> usp: Event received: DOWNDATA
[00:45:39.193,000] <inf> usp: Data received on port 1
[00:45:39.193,000] <inf> usp: Event received: TXDONE (SENT)

The credential guard is deliberate. With the template overlay every byte is zero, so a build that skipped the local file logs Placeholder credentials, the OTAA join is skipped instead of burning join attempts against the server.
Keep the real keys out of the repository. boards/user_keys.overlay.local is git-ignored on purpose: if you copy the sample into your own project, copy the ignore rule too.
Troubleshooting
Q1: The RF self-test fails on "SPI / LR2021 version"
The first case reads the chip version over SPI and compares it with 0x01/0x18. A mismatch usually means an older transceiver firmware, not a wiring fault. A bus that returns only 0x00 or 0xFF is a wiring fault: check the antenna is not shorting the board, then reseat the module.
Q2: "RF TX" times out without a "TX_DONE" interrupt
The radio finished the SPI transaction but never raised DIO8. Check that the interrupt line is not held low by a shield, and that the TCXO started: without a stable reference the radio never enters TX. A missing antenna can also trip the protection path on some modules.
Q3: The RSSI noise floor is far too high
A value around -30 dBm instead of -110 dBm means the receiver is hearing a transmitter nearby, often the second board of the link test. Power the other board down, or move it a few metres away, before you judge the noise floor.
Q4: The FLRC receiver never reports a packet
Three causes cover almost every case: the roles are swapped (two transmitters), the two boards disagree on flrc-test-sync-word or CRC mode, or the BER and normal images are mixed on one link. Rebuild both ends with the same configuration and flash the receiver first.
Q5: The LoRaWAN join fails with repeated JOINFAIL
Verify the region matches the server, that DevEUI, JoinEUI and Appkey were copied without byte reordering, and that the gateway is actually forwarding. A device that is out of range fails identically, so check the gateway log before you touch the firmware. A join can take a few attempts, and the sample waits up to CONFIG_LORAWAN_TEST_JOIN_TIMEOUT_S (180 s by default) before it reports a failure.
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.