Skip to content

pkg/radiolib: add RadioLib as external package#22271

Open
baptleduc wants to merge 19 commits into
RIOT-OS:masterfrom
baptleduc:port-radiolib
Open

pkg/radiolib: add RadioLib as external package#22271
baptleduc wants to merge 19 commits into
RIOT-OS:masterfrom
baptleduc:port-radiolib

Conversation

@baptleduc
Copy link
Copy Markdown
Contributor

@baptleduc baptleduc commented May 10, 2026

Contribution description

This PR adds RadioLib as an external package (pkg/radiolib), providing a universal radio transceiver library for RIOT applications. This is particularly useful for #22267, as the SeeedStudio T1000-E board carries a Semtech LR1110 LoRa transceiver not currently supported natively in RIOT.

The package integrates RadioLib via RIOT's standard pkg/ mechanism and includes:

  • A multi-module build structure mapping RadioLib source subdirectories to individual RIOT modules (radiolib_core, radiolib_utils, radiolib_physicallayer, radiolib_lr11x0)
  • A RIOT HAL (pkg/radiolib/contrib/radiolib_riotos.{h,cpp}) implementing RadioLibHal using periph/gpio, periph/spi, and ztimer

Testing procedure

Tested on the b-l072z-lrwan1 (SX1276, supported by RadioLib) using the IoT-LAB testbed (Saclay site).

Build:

make -C tests/pkg/radiolib/ BOARD=b-l072z-lrwan1

Hardware (IoT-LAB, 2× b-l072z-lrwan1, Saclay):

The tests/pkg/radiolib application includes a SX1276 PingPong test. Flashed on two nodes; one transmits a Ping, the other receives and replies with a Pong. Both nodes exchanged packets successfully.

# Node 1 (TX → sends Ping)
make -C tests/pkg/radiolib/ BOARD=b-l072z-lrwan1 IOTLAB_NODE=<node1>.saclay.iot-lab.info PING=1 flash term

# Node 2 (RX → responds with Pong)
make -C tests/pkg/radiolib/ BOARD=b-l072z-lrwan1 IOTLAB_NODE=<node2>.saclay.iot-lab.info flash term

Issues/PRs references

#22267

Declaration of AI Tools / LLMs usage

  • Claude Code for code review and guidance, with user authorship of the implementation

baptleduc added 6 commits May 10, 2026 21:57
Signed-off-by: Baptiste Le Duc <baptiste.leduc@etik.com>
Signed-off-by: Baptiste Le Duc <baptiste.leduc@etik.com>
Signed-off-by: Baptiste Le Duc <baptiste.leduc@etik.com>
Signed-off-by: Baptiste Le Duc <baptiste.leduc@etik.com>
Signed-off-by: Baptiste Le Duc <baptiste.leduc@etik.com>
Signed-off-by: Baptiste Le Duc <baptiste.leduc@etik.com>
@github-actions github-actions Bot added Area: tests Area: tests and testing framework Area: build system Area: Build system Area: pkg Area: External package ports labels May 10, 2026
@baptleduc baptleduc changed the title Port radiolib pkg/radiolib: add RadioLib as external package May 10, 2026
baptleduc added 3 commits May 10, 2026 22:14
Signed-off-by: Baptiste Le Duc <baptiste.leduc@etik.com>
Declare RiotHal class inheriting RadioLibHal with all pure-virtual
overrides. Expose pkg/radiolib/include/ via Makefile.include.

Signed-off-by: Baptiste Le Duc <baptiste.leduc@etik.com>
Implement all RadioLibHal pure-virtual methods using RIOT periph/gpio,
periph/spi, and ztimer APIs.

Signed-off-by: Baptiste Le Duc <baptiste.leduc@etik.com>
@crasbe crasbe added Type: new feature The issue requests / The PR implemements a new feature for RIOT CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels May 10, 2026
@riot-ci
Copy link
Copy Markdown

riot-ci commented May 10, 2026

Murdock results

FAILED

6e5a7c7 tests/pkg/radiolib: add SX1276 PingPong test on b-l072z-lrwan1

Build failures (16)
Application Target Toolchain Runtime (s) Worker
tests/pkg/radiolib native32 llvm 1.34 mobi6
tests/pkg/radiolib nrf52840dk gnu 2.00 mobi6
tests/pkg/radiolib native32 gnu 1.25 mobi6
tests/pkg/radiolib samr21-xpro gnu 3.14 mobi1
tests/pkg/radiolib qn9080dk gnu 1.68 mobi6
tests/pkg/radiolib adafruit-itsybitsy-m4 gnu 1.90 mobi6
tests/pkg/radiolib native64 llvm 1.36 mobi6
tests/pkg/radiolib frdm-k64f gnu 2.13 mobi7
tests/pkg/radiolib samr21-xpro llvm 3.72 mobi1
tests/pkg/radiolib stm32f429i-disc1 gnu 5.60 mobi7
tests/pkg/radiolib native64 gnu 3.85 mobi7
tests/pkg/radiolib stk3200 gnu 3.92 mobi7
tests/pkg/radiolib msba2 gnu 1.19 mobi6
tests/pkg/radiolib hifive1b gnu 12.33 riot-ci
tests/pkg/radiolib esp32s3-devkit gnu 5.89 mobi5
tests/pkg/radiolib esp32-wroom-32 gnu 15.33 mobi1

Artifacts

- add Doxygen /** doc blocks to all override methods
- wrap C includes in extern "C" block
- guard entire C++ content with #ifdef __cplusplus

Signed-off-by: Baptiste Le Duc <baptiste.leduc@etik.com>
Comment thread pkg/radiolib/include/radiolib_riotos.h Outdated
Comment thread pkg/radiolib/Makefile Outdated
Comment thread pkg/radiolib/include/radiolib_riotos.h
Comment thread pkg/radiolib/Makefile.dep Outdated
Comment thread tests/pkg/radiolib/main.cpp
baptleduc added 5 commits May 10, 2026 23:07
Signed-off-by: Baptiste Le Duc <baptiste.leduc@etik.com>
Signed-off-by: Baptiste Le Duc <baptiste.leduc@etik.com>
Signed-off-by: Baptiste Le Duc <baptiste.leduc@etik.com>
Signed-off-by: Baptiste Le Duc <baptiste.leduc@etik.com>
Signed-off-by: Baptiste Le Duc <baptiste.leduc@etik.com>
Upstream RadioLib triggers -Wmissing-braces in Cryptography.cpp
(subobject initialization) and -Woverloaded-virtual in LR11x0
(getTimeOnAir/setOutputPower hide base class overloads). Both are
upstream code issues outside RIOT control.

Signed-off-by: Baptiste Le Duc <baptiste.leduc@etik.com>
@crasbe crasbe added the CI: no fast fail don't abort PR build after first error label May 10, 2026
@aabadie
Copy link
Copy Markdown
Contributor

aabadie commented May 11, 2026

Hardware testing on a b-l072z-lrwan1 would be welcome. If you have one, please report.

There are 20 of them available on IoT-LAB: https://www.iot-lab.info. See https://www.iot-lab.info/docs/boards/st-b-l072z-lrwan1/

You can book an experiment on the testbed and use "IOTLAB_NODE=auto" with make flash term to flash and access the board stdio from your machine.

Comment thread pkg/radiolib/include/radiolib_riotos.h Outdated
Signed-off-by: Baptiste Le Duc <baptiste.le-duc@vates.tech>
@baptleduc
Copy link
Copy Markdown
Contributor Author

baptleduc commented May 11, 2026

There are 20 of them available on IoT-LAB: https://www.iot-lab.info. See https://www.iot-lab.info/docs/boards/st-b-l072z-lrwan1/

You can book an experiment on the testbed and use "IOTLAB_NODE=auto" with make flash term to flash and access the board stdio from your machine.

Oh thanks ! Is it expected to manually reset the node after each flash? Running make flash term with IOTLAB_NODE=auto flashes successfully but board does not boot new firmware until iotlab-node --reset is called separately.

@aabadie
Copy link
Copy Markdown
Contributor

aabadie commented May 11, 2026

Is it expected to manually reset the node after each flash? Running make flash term with IOTLAB_NODE=auto flashes successfully but board does not boot new firmware until iotlab-node --reset is called separately.

Normally the node is reset automatically after flashing but the boot message might be missed before you attached to the serial port.

@baptleduc
Copy link
Copy Markdown
Contributor Author

baptleduc commented May 11, 2026

It seems not. I also tested with examples/basic/hello-world and I didn't get any output before manually doing the reset.
This could be explained as dist/testbed-support/makefile.iotlab.single.inc.mk doesn't declare flash-recip so it uses the default one which doesn't include a reset:

define default-flash-recipe
  $(call check_cmd,$(FLASHER),Flash program)
  $(PROGRAMMER_FLASH)
endef
flash-recipe ?= $(default-flash-recipe)

It could be fixed by adding this patch :

diff --git a/dist/testbed-support/makefile.iotlab.single.inc.mk b/dist/testbed-support/makefile.iotlab.single.inc.mk
index 6f35fcee40..2bc52172c0 100644
--- a/dist/testbed-support/makefile.iotlab.single.inc.mk
+++ b/dist/testbed-support/makefile.iotlab.single.inc.mk
@@ -215,6 +215,14 @@ else

 endif

+define iotlab-flash-recipe
+  $(call check_cmd,$(FLASHER),Flash program)
+  $(PROGRAMMER_FLASH)
+  $(call check_cmd,$(RESET),Reset program)
+  $(PROGRAMMER_RESET)
+endef
+flash-recipe = $(iotlab-flash-recipe)
+
 ifneq (,$(filter firefly iotlab-a8-m3 zigduino,$(BOARD)))
   # Debugger not supported on these boards
   DEBUGGER =

- Wire board pins via RiotHal (SPI1, NSS/DIO0/RESET/DIO1 from board.h).
- TX/RX selected at build time with -DRADIOLIB_TEST_TX.
- Enable radiolib_sx127x in pkg build and dep files.

Signed-off-by: Baptiste Le Duc <baptiste.le-duc@vates.tech>
@baptleduc
Copy link
Copy Markdown
Contributor Author

It seems not. I also tested with examples/basic/hello-world and I didn't get any output before manually doing the reset. This could be explained as dist/testbed-support/makefile.iotlab.single.inc.mk doesn't declare flash-recip so it uses the default one which doesn't include a reset:

define default-flash-recipe
  $(call check_cmd,$(FLASHER),Flash program)
  $(PROGRAMMER_FLASH)
endef
flash-recipe ?= $(default-flash-recipe)

It could be fixed by adding this patch :

diff --git a/dist/testbed-support/makefile.iotlab.single.inc.mk b/dist/testbed-support/makefile.iotlab.single.inc.mk
index 6f35fcee40..2bc52172c0 100644
--- a/dist/testbed-support/makefile.iotlab.single.inc.mk
+++ b/dist/testbed-support/makefile.iotlab.single.inc.mk
@@ -215,6 +215,14 @@ else

 endif

+define iotlab-flash-recipe
+  $(call check_cmd,$(FLASHER),Flash program)
+  $(PROGRAMMER_FLASH)
+  $(call check_cmd,$(RESET),Reset program)
+  $(PROGRAMMER_RESET)
+endef
+flash-recipe = $(iotlab-flash-recipe)
+
 ifneq (,$(filter firefly iotlab-a8-m3 zigduino,$(BOARD)))
   # Debugger not supported on these boards
   DEBUGGER =

I opened a dedicated PR for that: #22287

@baptleduc baptleduc requested review from crasbe and kfessel May 12, 2026 22:06
@github-actions github-actions Bot added the Area: boards Area: Board ports label May 12, 2026
Two-node blocking PingPong using RadioLib transmit()/receive() at
868 MHz. Build with PING=1 for the initiating node, default for
the responder. Debug output (RSSI, SNR, frequency error, RX
timeouts) gated behind ENABLE_DEBUG.

Signed-off-by: Baptiste Le Duc <baptiste.le-duc@vates.tech>
@github-actions github-actions Bot removed the Area: boards Area: Board ports label May 12, 2026
@baptleduc
Copy link
Copy Markdown
Contributor Author

The PingPong test in tests/pkg/radiolib is working now, I updated the PR's description.
Now, how should I make this test board agnostic ?

@benpicco benpicco requested a review from fabian18 May 13, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: build system Area: Build system Area: pkg Area: External package ports Area: tests Area: tests and testing framework CI: no fast fail don't abort PR build after first error CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants