From bb3e77dc369b788e62a8491d3f7c22e8ce519fdc Mon Sep 17 00:00:00 2001 From: Will MacGregor Date: Wed, 4 Nov 2026 09:46:27 -0500 Subject: [PATCH 1/3] Enable simple_room_server on the STM32 platform The room server gated its filesystem paths on NRF52_PLATFORM only, so an STM32 build fell through to the ESP32 branch and failed to compile: MyMesh.cpp:147: no matching function for call to 'Adafruit_LittleFS::open(const char*&, const char [2], bool)' main.cpp:69: 'store' was not declared in this scope STM32 uses the same InternalFS / Adafruit_LittleFS API as nRF52, including append semantics (FILE_O_WRITE opens LFS_O_RDWR|LFS_O_CREAT and then seeks to the end), so the nRF52 branch is already correct for it. Add STM32_PLATFORM alongside NRF52_PLATFORM in the four remaining gates; saveIdentity() already did this. This unblocks the room_server example on the existing STM32WL boards (wio-e5-mini, wio-e5-dev, rak3x72, tiny_relay) as well as new ones. Co-Authored-By: Claude Opus 5 (1M context) --- examples/simple_room_server/MyMesh.cpp | 4 ++-- examples/simple_room_server/MyMesh.h | 2 +- examples/simple_room_server/main.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/simple_room_server/MyMesh.cpp b/examples/simple_room_server/MyMesh.cpp index 935fd7f92..b1a88dd87 100644 --- a/examples/simple_room_server/MyMesh.cpp +++ b/examples/simple_room_server/MyMesh.cpp @@ -140,7 +140,7 @@ mesh::Packet *MyMesh::createSelfAdvert() { } File MyMesh::openAppend(const char *fname) { -#if defined(NRF52_PLATFORM) +#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM) return _fs->open(fname, FILE_O_WRITE); #elif defined(RP2040_PLATFORM) return _fs->open(fname, "a"); @@ -782,7 +782,7 @@ void MyMesh::applyTempRadioParams(float freq, float bw, uint8_t sf, uint8_t cr, } bool MyMesh::formatFileSystem() { -#if defined(NRF52_PLATFORM) +#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM) return InternalFS.format(); #elif defined(RP2040_PLATFORM) return LittleFS.format(); diff --git a/examples/simple_room_server/MyMesh.h b/examples/simple_room_server/MyMesh.h index 4dee8bdbf..974e633a2 100644 --- a/examples/simple_room_server/MyMesh.h +++ b/examples/simple_room_server/MyMesh.h @@ -3,7 +3,7 @@ #include // needed for PlatformIO #include -#if defined(NRF52_PLATFORM) +#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM) #include #elif defined(RP2040_PLATFORM) #include diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 65fc55ef7..4bfad4e54 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -50,7 +50,7 @@ void setup() { fast_rng.begin(radio_driver.getRngSeed()); FILESYSTEM* fs; -#if defined(NRF52_PLATFORM) +#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM) InternalFS.begin(); fs = &InternalFS; IdentityStore store(InternalFS, ""); From dd78cc35d2bb5615f273ea2bb594fcf1b2191f39 Mon Sep 17 00:00:00 2001 From: Will MacGregor Date: Wed, 4 Nov 2026 09:46:40 -0500 Subject: [PATCH 2/3] Add variant for ST Nucleo-WL55JC1 Adds repeater, room_server, companion_radio_usb and kiss_modem environments for the NUCLEO-WL55JC1 (STM32WL55JC, integrated SubGHz radio). Notes on the board setup: - Uses the upstream nucleo_wl55jc board. PlatformIO's boards_remap maps it to the core's NUCLEO_WL55JC1 variant, so the LEDs, user buttons and the LPUART1 -> ST-LINK VCP serial mapping all come from the core rather than being redefined here. - The RF switch table is built from the core's LORAWAN_RFSWITCH_* macros (SP3T front end on PC3/PC4/PC5) so it tracks upstream if those are ever revised. Both RFO_LP and RFO_HP are registered, so RadioLib selects HP above 14 dBm and LP below it. - board_build.extra_flags pins the device to STM32WL55xx. The stock board manifest declares product_line STM32WL55xx but extra_flags -DSTM32WLE5xx; that only works because every #elif chain happens to test WL55xx first. - The Nucleo's LD1..LD3 are driven active HIGH, so the TX LED hooks are inverted relative to STM32Board's active-LOW default. - 32 KB reserved at the top of flash for LittleFS, as on the other STM32WL variants. Verified on hardware: all four environments build; repeater and room_server flash and run over ST-LINK; identity and prefs persist across reboot and across a firmware swap; and GPIOC reads back the documented RX levels at idle, confirming the front-end switch is driven correctly. Co-Authored-By: Claude Opus 5 (1M context) --- variants/nucleo_wl55jc/platformio.ini | 57 +++++++++++++++++++++++ variants/nucleo_wl55jc/target.cpp | 65 +++++++++++++++++++++++++++ variants/nucleo_wl55jc/target.h | 47 +++++++++++++++++++ variants/nucleo_wl55jc/variant.h | 5 +++ 4 files changed, 174 insertions(+) create mode 100644 variants/nucleo_wl55jc/platformio.ini create mode 100644 variants/nucleo_wl55jc/target.cpp create mode 100644 variants/nucleo_wl55jc/target.h create mode 100644 variants/nucleo_wl55jc/variant.h diff --git a/variants/nucleo_wl55jc/platformio.ini b/variants/nucleo_wl55jc/platformio.ini new file mode 100644 index 000000000..0de5ba6ff --- /dev/null +++ b/variants/nucleo_wl55jc/platformio.ini @@ -0,0 +1,57 @@ +[nucleo_wl55jc] +extends = stm32_base +board = nucleo_wl55jc +; The upstream board manifest tags the part as STM32WLE5xx even though its +; product_line is STM32WL55xx. Pin both to WL55 so a single device header and +; startup file (startup_stm32wl55xx_cm4.s) are in play. +board_build.extra_flags = -DSTM32WL -DSTM32WLxx -DSTM32WL55xx +board_upload.maximum_size = 229376 ; 32kb at the top of flash reserved for LittleFS +build_flags = ${stm32_base.build_flags} + -D RADIO_CLASS=CustomSTM32WLx + -D WRAPPER_CLASS=CustomSTM32WLxWrapper + -D LORA_TX_POWER=22 + -D SPI_INTERFACES_COUNT=0 + -D RX_BOOSTED_GAIN=true + -D STM32WL_TCXO_VOLTAGE=1.7 + -D P_LORA_TX_LED=LED_BLUE + -D PIN_USER_BTN=USER_BTN + -D USER_BTN_PRESSED=LOW + -I variants/nucleo_wl55jc +build_src_filter = ${stm32_base.build_src_filter} + +<../variants/nucleo_wl55jc> + +[env:nucleo_wl55jc_repeater] +extends = nucleo_wl55jc +build_flags = ${nucleo_wl55jc.build_flags} + -D ADVERT_NAME='"Nucleo WL55JC Repeater"' + -D ADMIN_PASSWORD='"password"' + -D MAX_NEIGHBOURS=50 +build_src_filter = ${nucleo_wl55jc.build_src_filter} + +<../examples/simple_repeater/*.cpp> + +[env:nucleo_wl55jc_companion_radio_usb] +extends = nucleo_wl55jc +build_flags = ${nucleo_wl55jc.build_flags} + -D MAX_CONTACTS=100 + -D MAX_GROUP_CHANNELS=8 + -D ENABLE_USB_INTERFACE ; binds to Serial, i.e. the ST-LINK virtual COM port +build_src_filter = ${nucleo_wl55jc.build_src_filter} + +<../examples/companion_radio/*.cpp> +lib_deps = ${nucleo_wl55jc.lib_deps} + densaugeo/base64 @ ~1.4.0 + +[env:nucleo_wl55jc_kiss_modem] +extends = nucleo_wl55jc +build_src_filter = ${nucleo_wl55jc.build_src_filter} + +<../examples/kiss_modem/> + +[env:nucleo_wl55jc_room_server] +extends = nucleo_wl55jc +build_flags = ${nucleo_wl55jc.build_flags} + -D ADVERT_NAME='"Nucleo WL55JC Room"' + -D ADVERT_LAT=0.0 + -D ADVERT_LON=0.0 + -D ADMIN_PASSWORD='"password"' + -D ROOM_PASSWORD='"hello"' +build_src_filter = ${nucleo_wl55jc.build_src_filter} + +<../examples/simple_room_server> diff --git a/variants/nucleo_wl55jc/target.cpp b/variants/nucleo_wl55jc/target.cpp new file mode 100644 index 000000000..8e773adf1 --- /dev/null +++ b/variants/nucleo_wl55jc/target.cpp @@ -0,0 +1,65 @@ +#include +#include "target.h" +#include + +NucleoWL55JCBoard board; + +RADIO_CLASS radio = new STM32WLx_Module(); + +WRAPPER_CLASS radio_driver(radio, board); + +// The NUCLEO-WL55JC1 drives an SP3T front-end switch from FE_CTRL1..3 (PC4, PC5, PC3), +// routing the single SMA between RX, RFO_LP and RFO_HP. Pin order and levels are taken +// straight from the core's board definition (variant_NUCLEO_WL55JC1.h) so they stay in +// sync with upstream. +static const uint32_t rfswitch_pins[] = {LORAWAN_RFSWITCH_PINS, RADIOLIB_NC, RADIOLIB_NC}; +static const Module::RfSwitchMode_t rfswitch_table[] = { + {STM32WLx::MODE_IDLE, {LORAWAN_RFSWITCH_OFF_VALUES}}, + {STM32WLx::MODE_RX, {LORAWAN_RFSWITCH_RX_VALUES}}, + {STM32WLx::MODE_TX_LP, {LORAWAN_RFSWITCH_RFO_LP_VALUES}}, + {STM32WLx::MODE_TX_HP, {LORAWAN_RFSWITCH_RFO_HP_VALUES}}, + END_OF_MODE_TABLE, +}; + +VolatileRTCClock rtc_clock; +SensorManager sensors; + +#ifndef LORA_CR + #define LORA_CR 5 +#endif + +#ifndef STM32WL_TCXO_VOLTAGE + // The board is fitted with a 32MHz TCXO powered from the radio's DIO3 at 1.7V + #define STM32WL_TCXO_VOLTAGE 1.7 +#endif + +#ifndef LORA_TX_POWER + #define LORA_TX_POWER 22 +#endif + +bool radio_init() { + radio.setRfSwitchTable(rfswitch_pins, rfswitch_table); + + // Both PA paths are registered above, so RadioLib picks RFO_HP whenever the + // requested power is above 14dBm, and RFO_LP below that. + int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, STM32WL_TCXO_VOLTAGE, 0); + + if (status != RADIOLIB_ERR_NONE) { + Serial.print("ERROR: radio init failed: "); + Serial.println(status); + return false; // fail + } + + #ifdef RX_BOOSTED_GAIN + radio.setRxBoostedGainMode(RX_BOOSTED_GAIN); + #endif + + radio.setCRC(1); + + return true; // success +} + +mesh::LocalIdentity radio_new_identity() { + RadioNoiseListener rng(radio); + return mesh::LocalIdentity(&rng); // create new random identity +} diff --git a/variants/nucleo_wl55jc/target.h b/variants/nucleo_wl55jc/target.h new file mode 100644 index 000000000..4b1c3ada7 --- /dev/null +++ b/variants/nucleo_wl55jc/target.h @@ -0,0 +1,47 @@ +#pragma once + +#define RADIOLIB_STATIC_ONLY 1 +#include +#include +#include +#include +#include +#include + +class NucleoWL55JCBoard : public STM32Board { +public: + void begin() override { + STM32Board::begin(); + + pinMode(P_LORA_TX_LED, OUTPUT); + digitalWrite(P_LORA_TX_LED, LOW); // see note on LED polarity below + pinMode(PIN_USER_BTN, INPUT_PULLUP); + } + + const char* getManufacturerName() const override { + return "ST Nucleo WL55JC1"; + } + + // LD1..LD3 on the Nucleo are driven active HIGH, whereas STM32Board's + // default TX-LED handling assumes the active LOW wiring used by the + // Wio-E5 boards. Invert both halves here. + void onBeforeTransmit() override { + digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED on + } + void onAfterTransmit() override { + digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off + } + + // No battery on this dev board, it is USB/ST-LINK powered. + uint16_t getBattMilliVolts() override { + return 0; + } +}; + +extern NucleoWL55JCBoard board; +extern WRAPPER_CLASS radio_driver; +extern VolatileRTCClock rtc_clock; +extern SensorManager sensors; + +bool radio_init(); +mesh::LocalIdentity radio_new_identity(); diff --git a/variants/nucleo_wl55jc/variant.h b/variants/nucleo_wl55jc/variant.h new file mode 100644 index 000000000..a006d1f10 --- /dev/null +++ b/variants/nucleo_wl55jc/variant.h @@ -0,0 +1,5 @@ +#pragma once + +#include + +#undef RNG From 33a27e175cccc47c6c9d94ff953dff9b533229f0 Mon Sep 17 00:00:00 2001 From: Will MacGregor Date: Wed, 4 Nov 2026 09:51:33 -0500 Subject: [PATCH 3/3] Build nucleo_wl55jc_repeater in PR build check Adds the new variant to the PR build matrix, next to the existing STM32 entry, so it is covered by CI going forward. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/pr-build-check.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-build-check.yml b/.github/workflows/pr-build-check.yml index cebf0cfe5..1d4314515 100644 --- a/.github/workflows/pr-build-check.yml +++ b/.github/workflows/pr-build-check.yml @@ -40,6 +40,7 @@ jobs: - PicoW_repeater # STM32 - wio-e5-mini_repeater + - nucleo_wl55jc_repeater # ESP32-C6 - LilyGo_Tlora_C6_repeater_ # LR1110 (nRF52)