From db6d584807a0c0af62911f38e9f6f343735ce357 Mon Sep 17 00:00:00 2001 From: Scott Penrose Date: Thu, 26 Nov 2026 16:12:09 +1100 Subject: [PATCH] 0.4.0: builds on Zephyr 4.5 as well as 4.4 --- CHANGELOG.md | 15 ++++++++++++++- Kconfig | 12 +++++++++++- README.md | 13 ++++++++++++- docs/TESTING.md | 13 +++++++++++++ python/pyproject.toml | 2 +- python/rb9704tools/__init__.py | 2 +- src/rb9704_serial.c | 9 ++++++++- tests/rig/bridge/Kconfig | 15 +++++++++++++++ tests/rig/bridge/prj.conf | 1 - tests/rig/bridge/src/main.c | 22 +++++++++++++++++----- west.yml | 5 +++-- 11 files changed, 95 insertions(+), 14 deletions(-) create mode 100644 tests/rig/bridge/Kconfig diff --git a/CHANGELOG.md b/CHANGELOG.md index 87aaa82..6b5e7f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,19 @@ # Changes -## Unreleased +## 0.4.0, 2026-11-26 + +- Builds on Zephyr v4.5.0 as well as v4.4.0. 4.5 made + `uart_irq_update()` return `void`, and the receive interrupt used it as + its loop condition, so 0.3.0 does not compile on 4.5 ("void value not + ignored"). It is now called at the top of each pass, as Zephyr's own + samples do. +- `CONFIG_RB9704` selects `CONFIG_RING_BUFFER` only before Zephyr 4.5. + From 4.5 the ring buffer is header-only, and that option brings back + the deprecated legacy implementation and a build warning. The check + compares `KERNELVERSION` in Kconfig. The rig bridge reads its ring with + `ring_buf_peek()` and `ring_buf_get()` in place of the claim API, which + is legacy from 4.5, and gates the option the same way. +- The standalone manifest pins Zephyr v4.5.0. - `rbtest` in the shell sample: airtime tests with a payload that can be checked at the other end. `rbtest small` sends a few 32-byte messages diff --git a/Kconfig b/Kconfig index e28e0ac..59ddb06 100644 --- a/Kconfig +++ b/Kconfig @@ -6,7 +6,7 @@ menuconfig RB9704 default y depends on DT_HAS_ROCK7_ROCKBLOCK_9704_ENABLED depends on SERIAL - select RING_BUFFER + select RING_BUFFER if RB9704_ZEPHYR_BEFORE_4_5 select UART_INTERRUPT_DRIVEN help Ground Control's RockBLOCK 9704 (Iridium Certus, IMT messages) on the @@ -16,6 +16,16 @@ menuconfig RB9704 if RB9704 +# Zephyr 4.5 made the ring buffer header-only, and CONFIG_RING_BUFFER there +# brings back the deprecated legacy implementation. Before 4.5 it is what +# builds the ring buffer at all. KERNELVERSION is 0xMMmmpp00. +config RB9704_KERNEL_VERSION + hex + default "$(KERNELVERSION)" + +config RB9704_ZEPHYR_BEFORE_4_5 + def_bool RB9704_KERNEL_VERSION < 0x4050000 + config RB9704_MESSAGE_MAX int "Largest message in either direction (bytes)" default 2048 diff --git a/README.md b/README.md index a8032f1..e718160 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,17 @@ and is mirrored to Open issues and pull requests on the GitHub mirror; the Gitea instance does not allow public sign-ups. +## Zephyr versions + +The module builds and its tests pass on Zephyr v4.4.0 and v4.5.0. Use +0.4.0 or later with Zephyr 4.5: 0.3.0 does not compile there, because +4.5 changed `uart_irq_update()` to return `void` and the module's +receive interrupt used its value. 0.4.0 calls it the way Zephyr's own 4.5 +samples do. It also selects `CONFIG_RING_BUFFER` only before 4.5, since +the ring buffer needs no option from 4.5 on and that option there brings +back the deprecated implementation. `CHANGELOG.md` has the detail and +`docs/TESTING.md` what was run on each. + ## Ground Control's library This module does not reimplement or fork the protocol. Ground Control's @@ -89,7 +100,7 @@ library, pinned, at the path the module looks in, and nothing else: ```yaml - name: rockblock9704-zephyr url: https://github.com/SH3D/rockblock9704-zephyr - revision: v0.3.0 + revision: v0.4.0 path: modules/lib/rockblock9704-zephyr import: name-allowlist: diff --git a/docs/TESTING.md b/docs/TESTING.md index 180b277..696dac2 100644 --- a/docs/TESTING.md +++ b/docs/TESTING.md @@ -174,4 +174,17 @@ all three control lines wired. Those were the first messages through a real modem and a satellite. `boards/stamp_c3.md` has the pins, the runs and the P_EN fault found on the way. +On 2026-11-26, with the changes for Zephyr 4.5, the same Ground Control +library: the module was built and tested on both Zephyr v4.4.0 and +v4.5.0, in the WII6 workspace. + +| Level | v4.4.0 | v4.5.0 | +| --- | --- | --- | +| Python: fake, command line, binding, and `native_sim/native/64` against the fake | 31 pass, 2 skip (no real modem) | 31 pass, 2 skip | +| The shell sample built for NUCLEO-U575ZI-Q, XIAO ESP32S3, ESP32-S3-DevKitC, ESP32 DevKitC, M5Stamp-C3 | all build | all build | +| The Stamp-C3 with `overlay-wifi.conf`, both rig overlays, the bridge on the Nucleo and the XIAO | the Nucleo rig and both bridges build with these changes; the WiFi and XIAO rig builds were run at 0.3.0 only | all build | + +Nothing on a board under 4.5 yet: the rig and the real modem runs above +were on v4.4.0. 0.3.0 itself does not build on 4.5. + Not yet: an MT message down to the board. diff --git a/python/pyproject.toml b/python/pyproject.toml index be51444..8b16f47 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "rockblock9704-tools" -version = "0.3.0" +version = "0.4.0" description = "Host tools for the RockBLOCK 9704: a command line for the modem and Cloudloop, and a fake modem for testing" readme = "README.md" license = "MIT" diff --git a/python/rb9704tools/__init__.py b/python/rb9704tools/__init__.py index bf46eda..0d6cf05 100644 --- a/python/rb9704tools/__init__.py +++ b/python/rb9704tools/__init__.py @@ -2,4 +2,4 @@ # Copyright (c) 2026 Scott Penrose """Host tools for the RockBLOCK 9704.""" -__version__ = "0.3.0" +__version__ = "0.4.0" diff --git a/src/rb9704_serial.c b/src/rb9704_serial.c index 9c30e07..251f390 100644 --- a/src/rb9704_serial.c +++ b/src/rb9704_serial.c @@ -118,7 +118,14 @@ static void modem_uart_isr(const struct device *dev, void *user_data) { ARG_UNUSED(user_data); - while (uart_irq_update(dev) && uart_irq_rx_ready(dev)) { + /* uart_irq_update() is void since Zephyr 4.5; the STM32, ESP32 + * and native drivers returned 1 from it before that. */ + while (true) { + uart_irq_update(dev); + if (uart_irq_rx_ready(dev) <= 0) { + break; + } + uint8_t tmp[64]; int n = uart_fifo_read(dev, tmp, sizeof(tmp)); int keep = 0; diff --git a/tests/rig/bridge/Kconfig b/tests/rig/bridge/Kconfig new file mode 100644 index 0000000..11081c5 --- /dev/null +++ b/tests/rig/bridge/Kconfig @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: MIT +# Copyright (c) 2026 Scott Penrose + +source "Kconfig.zephyr" + +# Before Zephyr 4.5 the ring buffer is built only with CONFIG_RING_BUFFER; +# from 4.5 it is header-only and that option is the deprecated legacy one. +# The module's Kconfig is not used here: the bridge has no modem node. +config BRIDGE_KERNEL_VERSION + hex + default "$(KERNELVERSION)" + +config BRIDGE_RING_BUFFER + def_bool y + select RING_BUFFER if BRIDGE_KERNEL_VERSION < 0x4050000 diff --git a/tests/rig/bridge/prj.conf b/tests/rig/bridge/prj.conf index 4c73e70..126aaaf 100644 --- a/tests/rig/bridge/prj.conf +++ b/tests/rig/bridge/prj.conf @@ -1,6 +1,5 @@ CONFIG_SERIAL=y CONFIG_UART_INTERRUPT_DRIVEN=y -CONFIG_RING_BUFFER=y # Both UARTs carry the bridged bytes; nothing else may print on them. CONFIG_CONSOLE=n CONFIG_UART_CONSOLE=n diff --git a/tests/rig/bridge/src/main.c b/tests/rig/bridge/src/main.c index 33a9313..bad099b 100644 --- a/tests/rig/bridge/src/main.c +++ b/tests/rig/bridge/src/main.c @@ -24,7 +24,14 @@ static void isr(const struct device *dev, void *user) struct ring_buf *back = out == &to_target ? &to_host : &to_target; uint8_t b[64]; - while (uart_irq_update(dev) && uart_irq_is_pending(dev)) { + /* uart_irq_update() is void since Zephyr 4.5; the STM32, ESP32 + * and native drivers returned 1 from it before that. */ + while (true) { + uart_irq_update(dev); + if (uart_irq_is_pending(dev) <= 0) { + break; + } + if (uart_irq_rx_ready(dev)) { int n = uart_fifo_read(dev, b, sizeof(b)); @@ -34,8 +41,11 @@ static void isr(const struct device *dev, void *user) } } if (uart_irq_tx_ready(dev)) { - uint8_t *p; - uint32_t n = ring_buf_get_claim(back, &p, 64); + /* Peek, fill, then take what the FIFO took: the claim + * API this used is legacy from Zephyr 4.5, and peek and + * get are in both. */ + uint8_t t[64]; + uint32_t n = ring_buf_peek(back, t, sizeof(t)); if (n == 0) { /* The other port's ISR may have put bytes in `back` @@ -44,9 +54,11 @@ static void isr(const struct device *dev, void *user) * soon. Not worth a lock here. */ uart_irq_tx_disable(dev); } else { - int w = uart_fifo_fill(dev, p, n); + int w = uart_fifo_fill(dev, t, n); - ring_buf_get_finish(back, w > 0 ? w : 0); + if (w > 0) { + ring_buf_get(back, t, (uint32_t)w); + } } } } diff --git a/west.yml b/west.yml index 6e5ce49..2e84da6 100644 --- a/west.yml +++ b/west.yml @@ -32,10 +32,11 @@ manifest: revision: ab37e8ac7711e1ba8061835a0685c25b6069e767 path: modules/lib/rockblock9704 - # Zephyr v4.4.0, for working on this module alone. Tested with it. + # Zephyr v4.5.0, for working on this module alone. The module is + # tested with v4.4.0 (684c9e8f32e4373a21098559f748f06915f950c9) too. - name: zephyr remote: zephyrproject - revision: 684c9e8f32e4373a21098559f748f06915f950c9 + revision: 41d10b59730406bbab4ca9f1fbbe9e96aafb4966 import: name-allowlist: - cmsis_6