Repository navigation
fix(wdt): harden the Teensy 4.x boot guard (#4719 review) - #4732
Merged
Merged
Conversation
- Key the OCRAM record to a sampled hash of the flash image, so a reflash starts the boot count from 0 instead of escaping on its first boot. - disable() goes through the WDOG3 helper, which enables the CCM_CCGR5 clock gate before touching WDOG3 registers. - Write the record only while the heap break is below it (it sits inside the OCRAM heap); stale heap data fails the check word / image key. - Keep the consecutive crash count in the same reset-persistent record, so escapeToBootloaderIfLooping() can actually fire on Teensy. - watchdogBootGuardWrite() always stores on every platform; the stub now uses the shared record helpers. - markBootHealthy() disables the guard's early WDOG3 timer when the sketch never called begin(). - Align boot_guard.h docs and the platform gate with the dispatcher. Co-Authored-By: Claude <[email protected]>
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (11)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Follow-up to #4719, which a post-merge review found defects in.
disable()touches WDOG3 with its clock gate offmxrt1062BootGuardConfigureWdog3, which setsCCM_CCGR5_WDOG3first__brkvalis below it; garbage fails check/image keyescapeToBootloaderIfLooping()dead on TeensywatchdogBootGuardWritediffers between stub and mxrtmarkBootHealthy()disables the early timer if the sketch never calledbegin()boot_guard.hdocs fixed; gate matches the watchdog dispatcherEvidence (Teensy 4.0, usb 1-1)
(a)
FL_WATCHDOG_DEBUG_EARLY_HANG(temporary, not committed): flashed 21:01:41, then hung before USB, and after the 30 s WDOG3 resets it came back in HalfKay with no button press:(b) Crash, then reflash: a temporary build (threshold 4) trapped in
setup()after usb_init on boots 1 and 2, and boot 3 idled unhealthy at count 3:Next I reflashed the normal build (threshold 3). Before this fix it would have inherited count 3 and escaped. It stayed at 0483 and answered the ping (
pong, lastResetCause POWER_ON):(c)
bash autoresearch teensy40 --timeout 120passes (pins 8 -> 22).Local validation
bash lintpasses.bash test watchdogpasses. New stub tests cover reflash re-keying (1), the persistent crash count (4), write semantics (5) and the early-timer release (6).