Detect mid-region power failures via NVM in-region flag - #59
Merged
Conversation
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
All three algorithms (MILP, RockClimb, SCHEMATIC) assume power never fails mid-region. This PR detects violations of that assumption (e.g. from wrong energy estimates), always on — including non-debug builds.
Firmware
__nvm_in_region/__nvm_violationin each runtime.save_pc_sp_and_haltclears__nvm_in_regiononce the boundary checkpoint is committed; boot code (and the wait-mode continue path) sets it when execution (re)enters a region. Cost: two 1-word FRAM writes per region.check_region_violationboot macro: a reset arriving with the flag set records__nvm_violation = 1and parks forever blinking LED1 (P1.0). The park is stable across further resets, so evidence survives until the next reflash.bench_halt()/debug_exit()clear the flag at completion so post-run mspdebug attach resets cannot false-positive.Python
RegionViolationError;check_region_violation()/raise_if_region_violation()indevice/flash.py.ckpt benchreads the flag after every device run — including when the Saleae capture times out, which is exactly what a parked device causes — and writes the CSV row with statusregion_violation.ckpt verifyreports a violation asStatus.ERRORwith a "region energy violation" detail on both the normal readback and the capture-timeout path.Testing
__nvm_pc/__nvm_spare written, set again on region re-entry.ruff format/ruff checkclean; 139 unit-marked pytest tests pass.