fix(power): replace assert(0) on stuck preflight with controlled restart#10441
Open
DatanoiseTV wants to merge 2 commits into
Open
fix(power): replace assert(0) on stuck preflight with controlled restart#10441DatanoiseTV wants to merge 2 commits into
DatanoiseTV wants to merge 2 commits into
Conversation
waitEnterSleep panicked with assert(0) when an observer vetoed sleep for >30s (FIXME meshtastic#167). On a field device that turns into a noisy crash log every 30s rather than a clean reboot. Use the same per-arch restart primitives Power::reboot uses, fall back to assert only for archs we don't have a primitive for.
8 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR changes the sleep preflight timeout handling to avoid repeated assert(0) panics when a sleep-preflight observer vetoes sleep for longer than 30 seconds, replacing the panic with a controlled, per-architecture reboot sequence (mirroring Power::reboot’s intent).
Changes:
- Replace the 30s preflight timeout
assert(0)with a logged, observer-notified restart using per-arch reset primitives. - Notify
notifyRebootobservers and flush the console before restarting to allow components to persist/cleanup.
| @@ -195,7 +195,26 @@ static void waitEnterSleep(bool skipPreflight = false) | |||
| if (!Throttle::isWithinTimespanMs(now, | |||
| THIRTY_SECONDS_MS)) { // If we wait too long just report an error and go to sleep | |||
Comment on lines
+202
to
218
| LOG_ERROR("Preflight sleep wait exceeded 30s, restarting"); | ||
| // Notify reboot observers (e.g. InkHUD) so they can persist / | ||
| // shut down cleanly, matching Power::reboot's contract. | ||
| notifyReboot.notifyObservers(NULL); | ||
| console->flush(); | ||
| #if defined(ARCH_ESP32) | ||
| ESP.restart(); | ||
| #elif defined(ARCH_NRF52) | ||
| NVIC_SystemReset(); | ||
| #elif defined(ARCH_RP2040) | ||
| rp2040.reboot(); | ||
| #elif defined(ARCH_STM32WL) | ||
| HAL_NVIC_SystemReset(); | ||
| #else | ||
| assert(0); // fallback for archs without a clean restart primitive | ||
| #endif | ||
| break; |
2 tasks
Contributor
|
Tested on Nordic nRF54L15-DK (stacked with the other Tier-1 hardening
LGTM. Tested-by: cvaldess |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
waitEnterSleep panicked with assert(0) when an observer vetoed sleep
for >30s (FIXME #167). On a field device that turns into a noisy
crash log every 30s rather than a clean reboot. Use the same
per-arch restart primitives Power::reboot uses, fall back to assert
only for archs we don't have a primitive for.
Split out from #10425 — single-concern PR.
Build verification
pio run -e t-deck-tftsucceeds, no new warnings.Attestations
t-deck-tftonly.