Skip to content

fix(rp): retain watchdog reset count across reboot - #3847

Merged
zackees merged 1 commit into
masterfrom
fix/rp-watchdog-recovery
Aug 6, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/rp-watchdog-recovery

Conversation

@zackees

@zackees zackees commented Aug 6, 2026 •

Copy link
Copy Markdown
Member

Summary\n- retain RP2040/RP2350 watchdog-reset counts in watchdog scratch storage across soft reset\n- reserve two scratch bytes for the internal counter and retain 14 public persist bytes\n- make AutoResearch enter a test-only, USB-CDC-safe recovery loop before PIO, RX, RPC, Wi-Fi, or LED driver initialization after repeated watchdog resets\n- replace the touched RP watchdog raw function-local state with fl::Singleton\n\n## Validation\n- �ash test watchdog\n- �ash compile rp2350w --examples AutoResearch\n- �ash lint --cpp\n\n## Hardware\nCOM17 is still selectable=no with Windows root-hub Code 43, so deployment was deliberately not attempted. The board-specific compile passed; live recovery validation remains pending normal USB enumeration.\n\nCloses #3832

Summary by CodeRabbit

  • New Features

    • Added automatic safe-mode detection after repeated watchdog-related crashes.
    • Safe mode now reports a machine-readable event with the reset reason, crash count, and configured threshold.
    • The device remains in a recovery state while continuing to service the watchdog.
  • Bug Fixes

    • Crash counts now persist across watchdog resets and reset after a clean shutdown or non-watchdog reset.
    • Improved startup protection prevents normal initialization when repeated crashes indicate an unsafe state.

@zackees
zackees merged commit 6dd3a91 into master Aug 6, 2026
14 of 16 checks passed
@zackees
zackees deleted the fix/rp-watchdog-recovery branch August 6, 2026 04:12
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Aug 6, 2026
@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f516adce-93cf-4b75-9dbb-28d11f4f0e15

📥 Commits

Reviewing files that changed from the base of the PR and between 2992532 and 806855b.

📒 Files selected for processing (2)
  • examples/AutoResearch/AutoResearch.ino
  • src/platforms/arm/rp/watchdog_rp.impl.hpp

📝 Walkthrough

Walkthrough

The RP watchdog now persists crash counts in hardware scratch storage. AutoResearch checks this state before initialization, reports safe-mode metadata, and remains in a watchdog-fed recovery loop when the crash threshold is reached.

Changes

RP watchdog recovery

Layer / File(s) Summary
Persistent crash counter
src/platforms/arm/rp/watchdog_rp.impl.hpp
The watchdog reserves two scratch bytes for a saturating crash counter. Reset handling, retrieval, and clean shutdown use the scratch-backed value.
AutoResearch safe-mode entry
examples/AutoResearch/AutoResearch.ino
setup() checks watchdog state before initialization. Safe mode emits a safeMode JSON event and enters a watchdog-fed recovery loop. Stub and WebAssembly builds exclude this logic.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

Possibly related PRs

Sequence Diagram(s)

sequenceDiagram
  participant AutoResearchSetup
  participant RPWatchdog
  participant SerialJSON
  AutoResearchSetup->>RPWatchdog: read crash count and safe-mode state
  AutoResearchSetup->>SerialJSON: emit safeMode JSON event
  AutoResearchSetup->>RPWatchdog: feed watchdog in recovery loop
Loading
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/rp-watchdog-recovery

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant