NRF52 - low voltage management, fixing data corruption - #8793
Closed
phaseloop wants to merge 17 commits into
Closed
Conversation
phaseloop
marked this pull request as draft
November 28, 2025 23:28
|
|
3 tasks
…-firmware into nrf52-voltage
…-firmware into nrf52-voltage
Contributor
Author
|
closing, will reopen later as new PR |
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.
Draft - PR during testing and development.
Strayed a bit from original PR but in a good direction.
This PR solves various issues with NRF52 boards when voltage is below 3V - fixing some data corruption scenarios and making them less prone to boot loops and problems like power fail radio flood: #8763
While ESP32 boards die at around 3.0V, most NRF52 + LDO combinations easily allow to go down to 2.5V. Usually firmware will try to put device to sleep at around 3.1V but this often fails and it's a different story.
Introduced API will also make it possible to implement on other platforms in the future.
Changes:
implement
isPowerLevelSafe()method to detect if current power state is safe for node to operate (driven by NRF52 POF power failure detection circuit). This will be especially important to prevent any NodeDB/config saving on power failure conditions to prevent flash corruption. Note that this does not use battery pin ADC but internal chip protection circuits.prevent device boot when voltage is too low (boot will resume when voltage rises to safe level - for example on solar nodes). This will prevent bootloops. During waiting state - user led will flash in sequence to indicate device state.
move NRF52 power failure threshold from 2.4V to 2.7V which is above automatic cutoff value for li-ion battery protectors so we do not get unexpected power cutoff
TODO:
prevent any NodeDB saves during power failure condition. NRF52 automatically blocks flash writes - but Meshtastic interprets that as flash corruption and reboots and formats filesystem as soon as POF condition goes away. So we shoot ourselves in the foot with bazooka.
put device to deep sleep when power failure is detected without waiting for classic battery readings and ADC voltage detection because it may be already too late for that. One example is bad battery going from 3.2V to 2.5V in few seconds or powering boards from various external regulators (and countless unexpected failure modes).