From 8f12df9fc2d2d2fc0e8b74cea00999230126c36f Mon Sep 17 00:00:00 2001 From: Andrew Yong Date: Thu, 13 Aug 2026 11:42:14 +0800 Subject: [PATCH] stm32wl: enable LSE/RTC/deep-sleep on all variants Recent flash-savings work now allows RTC & LowPower libraries to fit on all STM32WL variants. - Add STM32RTC/STM32LowPower lib_deps to stm32_base environment - Drop lib_deps from variants where RTC & LowPower are now redundant: - rak3172 - nucleo_wl55jc - Define HAS_LSE & LSEDRIVE level macros on remaining STM32WL variants: - russell - wio-e5 - CDEBYTE_E77-MBL - milesight_gs301 - Move MESHTASTIC_EXCLUDE_AIR_QUALITY_SENSOR into stm32_base and drop the per-variant copies. No STM32WL variant has populated air-quality hardware, and excluding it in the base is what keeps nucleo_wl55jc within its flash budget. Assisted-by: Claude Sonnet 5 Signed-off-by: Andrew Yong --- variants/stm32/CDEBYTE_E77-MBL/platformio.ini | 1 - variants/stm32/CDEBYTE_E77-MBL/variant.h | 6 ++++++ variants/stm32/milesight_gs301/platformio.ini | 1 - variants/stm32/milesight_gs301/variant.h | 4 ++++ variants/stm32/nucleo_wl55jc/platformio.ini | 7 ------- variants/stm32/rak3172/platformio.ini | 8 -------- variants/stm32/russell/platformio.ini | 1 - variants/stm32/russell/variant.h | 4 ++++ variants/stm32/stm32.ini | 5 +++++ variants/stm32/wio-e5/platformio.ini | 1 - variants/stm32/wio-e5/variant.h | 5 +++++ 11 files changed, 24 insertions(+), 19 deletions(-) diff --git a/variants/stm32/CDEBYTE_E77-MBL/platformio.ini b/variants/stm32/CDEBYTE_E77-MBL/platformio.ini index f0f5d7cdc69..8ebcede91a7 100644 --- a/variants/stm32/CDEBYTE_E77-MBL/platformio.ini +++ b/variants/stm32/CDEBYTE_E77-MBL/platformio.ini @@ -13,7 +13,6 @@ build_flags = -DPIN_SERIAL1_RX=PB7 -DPIN_SERIAL1_TX=PB6 -DMESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR=1 - -DMESHTASTIC_EXCLUDE_AIR_QUALITY_SENSOR=1 -DMESHTASTIC_EXCLUDE_I2C=1 -DMESHTASTIC_EXCLUDE_GPS=1 build_unflags = diff --git a/variants/stm32/CDEBYTE_E77-MBL/variant.h b/variants/stm32/CDEBYTE_E77-MBL/variant.h index 686326137a7..1a792e179ef 100644 --- a/variants/stm32/CDEBYTE_E77-MBL/variant.h +++ b/variants/stm32/CDEBYTE_E77-MBL/variant.h @@ -22,4 +22,10 @@ Do not expect a working Meshtastic device with this target. #define SERIAL_PRINT_PORT 1 #define EBYTE_E77_MBL + +// From EBYTE reference firmware: +// https://www.cdebyte.com/products/E77-900M22S/4#Downloads +#define HAS_LSE 1 +#define STM32WL_LSE_DRIVE RCC_LSEDRIVE_LOW + #endif diff --git a/variants/stm32/milesight_gs301/platformio.ini b/variants/stm32/milesight_gs301/platformio.ini index 8bc063a9139..4ee4292672c 100644 --- a/variants/stm32/milesight_gs301/platformio.ini +++ b/variants/stm32/milesight_gs301/platformio.ini @@ -12,7 +12,6 @@ build_flags = -DMESHTASTIC_EXCLUDE_GPS=1 -DMESHTASTIC_EXCLUDE_I2C=1 # Analog ADuCM355 (unsupported) so no point building support for I2C in -DMESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR=1 - -DMESHTASTIC_EXCLUDE_AIR_QUALITY_SENSOR=1 build_unflags = -DDEBUG_MUTE # We have space for debug output until sensor support is added build_src_filter = diff --git a/variants/stm32/milesight_gs301/variant.h b/variants/stm32/milesight_gs301/variant.h index f68d704588e..f8c86964472 100644 --- a/variants/stm32/milesight_gs301/variant.h +++ b/variants/stm32/milesight_gs301/variant.h @@ -38,4 +38,8 @@ // https://github.com/stm32duino/Arduino_Core_STM32/blob/main/variants/STM32WLxx/WL54CCU_WL55CCU_WLE4C(8-B-C)U_WLE5C(8-B-C)U/variant_RAK3172_MODULE.h #define RAK3172 +// From Ghidra decompilation of the GS301 factory firmware +#define HAS_LSE 1 +#define STM32WL_LSE_DRIVE RCC_LSEDRIVE_LOW + #endif diff --git a/variants/stm32/nucleo_wl55jc/platformio.ini b/variants/stm32/nucleo_wl55jc/platformio.ini index 9ff211a1955..cb70b5be831 100644 --- a/variants/stm32/nucleo_wl55jc/platformio.ini +++ b/variants/stm32/nucleo_wl55jc/platformio.ini @@ -13,11 +13,4 @@ build_flags = -DHAS_GPS=1 -DGPS_SERIAL_PORT=Serial2 ; Default Serial object is used for onboard ST-Link VCP -DHAS_SENSOR=1 -lib_deps = - ${stm32_base.lib_deps} - # renovate: datasource=github-tags depName=STM32RTC packageName=stm32duino/STM32RTC - https://github.com/stm32duino/STM32RTC/archive/refs/tags/1.9.0.zip - # renovate: datasource=github-tags depName=STM32LowPower packageName=stm32duino/STM32LowPower - https://github.com/stm32duino/STM32LowPower/archive/refs/tags/1.5.0.zip - upload_port = stlink diff --git a/variants/stm32/rak3172/platformio.ini b/variants/stm32/rak3172/platformio.ini index 04633ff29d1..ca4b2db0c66 100644 --- a/variants/stm32/rak3172/platformio.ini +++ b/variants/stm32/rak3172/platformio.ini @@ -12,18 +12,10 @@ build_flags = -DPIN_WIRE_SDA=PA11 -DPIN_WIRE_SCL=PA12 -DMESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR=1 - -DMESHTASTIC_EXCLUDE_AIR_QUALITY_SENSOR=1 -DMESHTASTIC_EXCLUDE_I2C=1 -DMESHTASTIC_EXCLUDE_GPS=1 build_unflags = ${arduino_base.build_unflags} -DMESHTASTIC_EXCLUDE_XEDDSA=1 -lib_deps = - ${stm32_base.lib_deps} - # renovate: datasource=github-tags depName=STM32RTC packageName=stm32duino/STM32RTC - https://github.com/stm32duino/STM32RTC/archive/refs/tags/1.9.0.zip - # renovate: datasource=github-tags depName=STM32LowPower packageName=stm32duino/STM32LowPower - https://github.com/stm32duino/STM32LowPower/archive/refs/tags/1.5.0.zip - upload_port = stlink diff --git a/variants/stm32/russell/platformio.ini b/variants/stm32/russell/platformio.ini index 1900a9ae164..3f4457e07db 100644 --- a/variants/stm32/russell/platformio.ini +++ b/variants/stm32/russell/platformio.ini @@ -13,7 +13,6 @@ build_flags = ${stm32_base.build_flags} -Ivariants/stm32/russell -DPRIVATE_HW - -DMESHTASTIC_EXCLUDE_AIR_QUALITY_SENSOR=1 -DMESHTASTIC_EXCLUDE_DETECTIONSENSOR=1 -DMESHTASTIC_EXCLUDE_EXTERNALNOTIFICATION=1 -DMESHTASTIC_EXCLUDE_POWERSTRESS=1 diff --git a/variants/stm32/russell/variant.h b/variants/stm32/russell/variant.h index 3b476fc7d06..18eb9c4e31c 100644 --- a/variants/stm32/russell/variant.h +++ b/variants/stm32/russell/variant.h @@ -53,4 +53,8 @@ Sample OCV curve for Li-SOCl2 primary lithium cells (e.g. Saft cells have fresh // https://github.com/stm32duino/Arduino_Core_STM32/blob/main/variants/STM32WLxx/WL54CCU_WL55CCU_WLE4C(8-B-C)U_WLE5C(8-B-C)U/variant_RAK3172_MODULE.h #define RAK3172 +// RAK3172 module +#define HAS_LSE 1 +#define STM32WL_LSE_DRIVE RCC_LSEDRIVE_LOW + #endif diff --git a/variants/stm32/stm32.ini b/variants/stm32/stm32.ini index 02955ff2a04..09a7dd70548 100644 --- a/variants/stm32/stm32.ini +++ b/variants/stm32/stm32.ini @@ -29,6 +29,7 @@ build_flags = -DMESHTASTIC_EXCLUDE_PKT_HISTORY_HASH=1 -DMESHTASTIC_EXCLUDE_WAYPOINT=1 -DMESHTASTIC_EXCLUDE_POWER_TELEMETRY=1 + -DMESHTASTIC_EXCLUDE_AIR_QUALITY_SENSOR=1 -DSERIAL_RX_BUFFER_SIZE=256 ; For GPS - the default of 64 is too small. -DHAS_SCREEN=0 ; Always disable screen for STM32, it is not supported. ;-DPIO_FRAMEWORK_ARDUINO_NANOLIB_FLOAT_PRINTF ; Enable this if enabling debugg logging. It is REQUIRED for at least traceroute debug prints - without it the length returned by printf ends up uninitialized. @@ -59,6 +60,10 @@ lib_deps = ${radiolib_base.lib_deps} # renovate: datasource=git-refs depName=meshtastic/Crypto packageName=https://github.com/meshtastic/Crypto gitBranch=main https://github.com/meshtastic/Crypto/archive/591ff9a690e8168ccb7a36abde8d7783e448d395.zip + # renovate: datasource=github-tags depName=STM32RTC packageName=stm32duino/STM32RTC + https://github.com/stm32duino/STM32RTC/archive/refs/tags/1.9.0.zip + # renovate: datasource=github-tags depName=STM32LowPower packageName=stm32duino/STM32LowPower + https://github.com/stm32duino/STM32LowPower/archive/refs/tags/1.5.0.zip lib_ignore = OneButton diff --git a/variants/stm32/wio-e5/platformio.ini b/variants/stm32/wio-e5/platformio.ini index 8c7579aa3dc..0445f3c7975 100644 --- a/variants/stm32/wio-e5/platformio.ini +++ b/variants/stm32/wio-e5/platformio.ini @@ -17,6 +17,5 @@ build_flags = -DPIN_SERIAL2_RX=PA3 -DHAS_GPS=1 -DGPS_SERIAL_PORT=Serial2 - -DMESHTASTIC_EXCLUDE_AIR_QUALITY_SENSOR=1 upload_port = stlink diff --git a/variants/stm32/wio-e5/variant.h b/variants/stm32/wio-e5/variant.h index da2c623fb3b..2062c457cf8 100644 --- a/variants/stm32/wio-e5/variant.h +++ b/variants/stm32/wio-e5/variant.h @@ -19,4 +19,9 @@ Do not expect a working Meshtastic device with this target. #define WIO_E5 +// From Seeed reference firmware: +// https://github.com/Seeed-Studio/LoRaWan-E5-Node/blob/main/Projects/Applications/LoRaWAN/LoRaWAN_End_Node/Core/Src/main.c +#define HAS_LSE 1 +#define STM32WL_LSE_DRIVE RCC_LSEDRIVE_LOW + #endif