From 4d80b6ce106e018d6d828417e455996cb5a9e210 Mon Sep 17 00:00:00 2001 From: Andrew Yong Date: Fri, 10 Jul 2026 03:53:41 +0800 Subject: [PATCH 1/5] stm32wl: consult SX126X_DIO3_TCXO_VOLTAGE instead of hardcoding 1.7V Every STM32WL variant except rak3172 got setTCXOVoltage(1.7) unconditionally, regardless of what the board's hardware actually needs, and rak3172 got no TCXO configuration at all - so a real RAK3172-T (populated TCXO) failed radio init outright. Read SX126X_DIO3_TCXO_VOLTAGE per variant instead. When TCXO_OPTIONAL is also defined, retry once on XTAL if the TCXO attempt fails, mirroring the existing pattern in LR11x0Interface.cpp, LR20x0Interface.cpp, and the SX1262/SX1268 paths in RadioInterface.cpp. Signed-off-by: Andrew Yong Assisted-by: Claude Sonnet 5 --- src/mesh/STM32WLE5JCInterface.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/mesh/STM32WLE5JCInterface.cpp b/src/mesh/STM32WLE5JCInterface.cpp index f6e4b3512a2..567cd4c00f0 100644 --- a/src/mesh/STM32WLE5JCInterface.cpp +++ b/src/mesh/STM32WLE5JCInterface.cpp @@ -19,8 +19,8 @@ bool STM32WLE5JCInterface::init() RadioLibInterface::init(); // https://github.com/Seeed-Studio/LoRaWan-E5-Node/blob/main/Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver/radio_driver.c -#if (!defined(_VARIANT_RAK3172_)) - setTCXOVoltage(1.7); +#if defined(SX126X_DIO3_TCXO_VOLTAGE) + setTCXOVoltage(SX126X_DIO3_TCXO_VOLTAGE); #endif lora.setRfSwitchTable(rfswitch_pins, rfswitch_table); @@ -29,6 +29,17 @@ bool STM32WLE5JCInterface::init() int res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength, tcxoVoltage); +#if defined(TCXO_OPTIONAL) + // If a TCXO was requested but isn't actually populated (e.g. non-T RAK3172), retry on XTAL + if (res != RADIOLIB_ERR_NONE && res != RADIOLIB_ERR_CHIP_NOT_FOUND && tcxoVoltage > 0) { + LOG_WARN("STM32WLx init failed with TCXO Vref %fV (err %d), retrying without TCXO", tcxoVoltage, res); + setTCXOVoltage(0); + res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength, tcxoVoltage); + if (res == RADIOLIB_ERR_NONE) + LOG_INFO("STM32WLx init success without TCXO (XTAL mode)"); + } +#endif + LOG_INFO("STM32WLx init result %d", res); LOG_INFO("Frequency set to %f", getFreq()); From f729390f0befad8d4881086b71affbe978ca41d9 Mon Sep 17 00:00:00 2001 From: Andrew Yong Date: Fri, 10 Jul 2026 03:53:59 +0800 Subject: [PATCH 2/5] stm32wl(rak3172): support both non-T and -T hardware via TCXO-optional RAK3172 is XTAL-only; RAK3172-T has a populated 3.0V TCXO, matching RAK's own reference radio_conf.h. One PlatformIO environment now serves both: tries the TCXO first, falls back to XTAL if not populated. Hardware-verified on a TCXO-equipped board electrically equivalent to RAK3172-T. Genuine non-T hardware not available to re-verify the fallback path; reasoned from RadioLib source instead (see PR description). Signed-off-by: Andrew Yong Assisted-by: Claude Sonnet 5 --- variants/stm32/rak3172/variant.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/variants/stm32/rak3172/variant.h b/variants/stm32/rak3172/variant.h index b7afefc3f75..858624bc436 100644 --- a/variants/stm32/rak3172/variant.h +++ b/variants/stm32/rak3172/variant.h @@ -27,4 +27,13 @@ Do not expect a working Meshtastic device with this target. #define HAS_LSE 1 #define STM32WL_LSE_DRIVE RCC_LSEDRIVE_LOW +// LoRa +/* + * RAK3172 (-20-85°C) -> No TCXO + * RAK3172-T (-40-85°C) -> 3.0V TCXO + * https://github.com/RAKWireless/RAK-STM32-RUI/blob/e5a28be8fab1a492bd9223dd425ca33a8a297d90/variants/WisDuo_RAK3172-T_Board/radio_conf.h#L91 + */ +#define TCXO_OPTIONAL +#define SX126X_DIO3_TCXO_VOLTAGE 3.0 + #endif From 4f82aa5357c2120371722dc6985a7fb017e6ca0c Mon Sep 17 00:00:00 2001 From: Andrew Yong Date: Fri, 10 Jul 2026 03:54:23 +0800 Subject: [PATCH 3/5] stm32wl(wio-e5): declare the module's 1.7V TCXO explicitly Matches Seeed's own reference radio driver. wio-e5 previously relied on the hardcoded 1.7V fallback being removed by the preceding commit, which would have broken it - declare the voltage explicitly instead. Hardware-verified via SWD: without this define, the radio interface fails to come up at all (sendtext NAKs with NO_INTERFACE, meaning rIf is null). With it, NO_INTERFACE goes away and the device sends/receives normally. Signed-off-by: Andrew Yong Assisted-by: Claude Sonnet 5 --- variants/stm32/wio-e5/variant.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/variants/stm32/wio-e5/variant.h b/variants/stm32/wio-e5/variant.h index da2c623fb3b..ad733ff5f49 100644 --- a/variants/stm32/wio-e5/variant.h +++ b/variants/stm32/wio-e5/variant.h @@ -19,4 +19,8 @@ Do not expect a working Meshtastic device with this target. #define WIO_E5 +// LoRa +// https://github.com/Seeed-Studio/LoRaWan-E5-Node/blob/163c05379b1805dd8f2c061d4557a69985acc953/Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver/radio_driver.c#L94 +#define SX126X_DIO3_TCXO_VOLTAGE 1.7 + #endif From bfd75b2c4867076fd009b2043e77ef82b5d1e0bd Mon Sep 17 00:00:00 2001 From: Andrew Yong Date: Fri, 10 Jul 2026 03:54:40 +0800 Subject: [PATCH 4/5] stm32wl(CDEBYTE_E77-MBL): mark TCXO voltage optional, hardware varies by unit EByte changed the E77-MBL hardware in early 2024: units with serial number >= 3202995 have a TCXO, older units have a ceramic crystal oscillator instead. Both ship under the same module name, so probe for the TCXO and fall back to XTAL rather than assuming either. https://github.com/olliw42/mLRS-docu/blob/main/docs/EBYTE_E77_MBL.md Not hardware-tested - no E77-MBL board available this session. Signed-off-by: Andrew Yong Assisted-by: Claude Sonnet 5 --- variants/stm32/CDEBYTE_E77-MBL/variant.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/variants/stm32/CDEBYTE_E77-MBL/variant.h b/variants/stm32/CDEBYTE_E77-MBL/variant.h index 686326137a7..f08248541ab 100644 --- a/variants/stm32/CDEBYTE_E77-MBL/variant.h +++ b/variants/stm32/CDEBYTE_E77-MBL/variant.h @@ -22,4 +22,15 @@ Do not expect a working Meshtastic device with this target. #define SERIAL_PRINT_PORT 1 #define EBYTE_E77_MBL + +// LoRa +/* + * EByte silently changed the E77-MBL hardware around early 2024: modules with serial number + * >= 3202995 have a (better) TCXO; older modules have a ceramic crystal oscillator (XTAL) instead. + * Since both are in the field under the same module name, treat the TCXO voltage as optional here. + * https://github.com/olliw42/mLRS-docu/blob/main/docs/EBYTE_E77_MBL.md + */ +#define TCXO_OPTIONAL +#define SX126X_DIO3_TCXO_VOLTAGE 1.7 + #endif From 5a78f2ca66f3645f93ccfbc71ea99bfc794ea66b Mon Sep 17 00:00:00 2001 From: Andrew Yong Date: Fri, 10 Jul 2026 07:45:33 +0800 Subject: [PATCH 5/5] stm32wl: trim TCXO comment blocks to repo's 1-2 line guideline Per review feedback on PR #10964 (CodeRabbit nitpicks) - the rak3172 and CDEBYTE_E77-MBL variant.h comments were 4-line blocks, exceeding the repo's comment-length convention. Condensed to one line each, same information and links retained. Signed-off-by: Andrew Yong Assisted-by: Claude Sonnet 5 --- variants/stm32/CDEBYTE_E77-MBL/variant.h | 8 ++------ variants/stm32/rak3172/variant.h | 7 ++----- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/variants/stm32/CDEBYTE_E77-MBL/variant.h b/variants/stm32/CDEBYTE_E77-MBL/variant.h index f08248541ab..b2f84f23536 100644 --- a/variants/stm32/CDEBYTE_E77-MBL/variant.h +++ b/variants/stm32/CDEBYTE_E77-MBL/variant.h @@ -24,12 +24,8 @@ Do not expect a working Meshtastic device with this target. #define EBYTE_E77_MBL // LoRa -/* - * EByte silently changed the E77-MBL hardware around early 2024: modules with serial number - * >= 3202995 have a (better) TCXO; older modules have a ceramic crystal oscillator (XTAL) instead. - * Since both are in the field under the same module name, treat the TCXO voltage as optional here. - * https://github.com/olliw42/mLRS-docu/blob/main/docs/EBYTE_E77_MBL.md - */ +// Hardware varies by unit: SN >= 3202995 has a TCXO, older units have XTAL only - +// https://github.com/olliw42/mLRS-docu/blob/main/docs/EBYTE_E77_MBL.md #define TCXO_OPTIONAL #define SX126X_DIO3_TCXO_VOLTAGE 1.7 diff --git a/variants/stm32/rak3172/variant.h b/variants/stm32/rak3172/variant.h index 858624bc436..f18448f0d97 100644 --- a/variants/stm32/rak3172/variant.h +++ b/variants/stm32/rak3172/variant.h @@ -28,11 +28,8 @@ Do not expect a working Meshtastic device with this target. #define STM32WL_LSE_DRIVE RCC_LSEDRIVE_LOW // LoRa -/* - * RAK3172 (-20-85°C) -> No TCXO - * RAK3172-T (-40-85°C) -> 3.0V TCXO - * https://github.com/RAKWireless/RAK-STM32-RUI/blob/e5a28be8fab1a492bd9223dd425ca33a8a297d90/variants/WisDuo_RAK3172-T_Board/radio_conf.h#L91 - */ +// RAK3172: no TCXO, RAK3172-T: 3.0V TCXO - +// https://github.com/RAKWireless/RAK-STM32-RUI/blob/e5a28be8fab1a492bd9223dd425ca33a8a297d90/variants/WisDuo_RAK3172-T_Board/radio_conf.h#L91 #define TCXO_OPTIONAL #define SX126X_DIO3_TCXO_VOLTAGE 3.0