stm32wl(rak3172): implement cpuDeepSleep()/shutdown() via STM32LowPower#2
Closed
ndoo wants to merge 1 commit into
Closed
stm32wl(rak3172): implement cpuDeepSleep()/shutdown() via STM32LowPower#2ndoo wants to merge 1 commit into
ndoo wants to merge 1 commit into
Conversation
cpuDeepSleep() was an empty stub, so the SDS deep-sleep PowerFSM state and low-battery shutdown did nothing but leave the CPU running at full power. Power::shutdown() also didn't include STM32WL in its arch list, so an explicit shutdown command just logged a FIXME warning. Adds STM32LowPower as a lib_dep (rak3172 only, mirroring STM32RTC) and implements cpuDeepSleep() using it. Standby mode is used for both the finite-wake (SDS/low battery) and forever (shutdown) paths, via LowPower.shutdown(), with or without an RTC alarm. If the LSE-backed hardware RTC never came up (stm32wlRtcAvailable() false), this is a no-op - safer than sleeping without a confirmed wake source. LowPower.shutdown() resets the MCU on wake and should never return; if it somehow does, force a reset via HAL_NVIC_SystemReset() rather than hanging the device silently forever. Gated behind the existing HAS_LSE flag, so this is inert on every variant but rak3172. Assisted-by: Claude Sonnet 5 <noreply@anthropic.com> Signed-off-by: Andrew Yong <me@ndoo.sg>
Member
Author
|
Opened against the wrong repo — correct PR is meshtastic#10993. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements deep-sleep/shutdown for STM32WL (
rak3172) using theSTM32LowPowerArduino library, building on meshtastic#10961'sHAS_LSE/STM32RTCinfrastructure.cpuDeepSleep()(src/platform/stm32wl/main-stm32wl.cpp) was an empty stub, so the SDS deep-sleep PowerFSM state and low-battery shutdown never actually slept.Power::shutdown()didn't include STM32WL in its arch list, so an explicit shutdown command just logged a FIXME warning.Both gaps are closed for
rak3172, gated behind the existingHAS_LSEflag (default 0, only set forrak3172). Other STM32WL variants (wio-e5,russell,CDEBYTE_E77-MBL,milesight_gs301) are unaffected.Dependency
This PR is based on meshtastic#10961 (open, not yet merged) and targets
stm32wl-hardware-rtcas its base branch rather thandevelop. Once meshtastic#10961 merges, this PR's base should be retargeted todevelop.Implementation
Both
cpuDeepSleep()paths useLowPower.shutdown()(Standby mode) — with an RTC alarm for a finite wake (SDS/low-battery), without one for a forever shutdown (Power::shutdown()).LowPower.deepSleep()(Stop2 mode) was tried first for the finite-wake case but did not reliably wake via its RTC alarm on this hardware, confirmed across twoSTM32WL_LSE_DRIVElevels (LOW, matching RAK's own reference firmware, andMEDIUMLOW), ruling out crystal drive strength as the cause.Flash budget
rak3172beforerak3172afterwio-e5before/after🤝 Attestations
Tested on a RAK3172-T unit, with PR meshtastic#10964's TCXO fixes cherry-picked in for that testing session (not included in this PR — a RAK3172-T needs meshtastic#10964 to boot at all, but a base RAK3172 does not, and this PR's changes don't depend on it). Confirmed on hardware:
Power::shutdown(), Standby mode, no alarm): device saves state, sleeps the radio, enters Standby, and stays silent until manually reset.low_voltage_counterdebounce firesEVENT_LOW_BATTERY, device enters deep sleep, then resets and rejoins the mesh on its own oncesds_secselapses.Build-verified no regression on
wio-e5,russell,CDEBYTE_E77-MBL(HAS_LSEdefaults to0, all new code compiled out).milesight_gs301fails to build ondevelopindependent of this PR (pre-existingNANOLIB_FLOAT_PRINTF/debug-print config issue, confirmed via a clean checkout).