Skip to content

fix(rp2040): cancel timed-out UF2 writes - #1167

Merged
zackees merged 1 commit into
mainfrom
fix/rp2040-watchdog-handle
Jul 23, 2026
Merged

fix(rp2040): cancel timed-out UF2 writes#1167
zackees merged 1 commit into
mainfrom
fix/rp2040-watchdog-handle

Conversation

@zackees

@zackeeszackees commented Jul 23, 2026

Copy link
Copy Markdown
Member

Summary

  • cancel synchronous Windows UF2 writes after a watchdog timeout and wait briefly for the destination handle to close
  • report live abandoned-worker count and oldest age when a worker cannot stop within the grace period
  • cover timeout diagnostics and worker recovery

Closes#1164

Validation

  • soldr cargo test -p fbuild-deploy watchdog -- --nocapture (3 passed)
  • soldr rustfmt --check crates/fbuild-deploy/src/rp2040.rs`n

Note

  • soldr cargo clippy -p fbuild-deploy --all-targets -- -D warnings is blocked by an existing unrelated build-serial unused import: GUID_DEVCLASS_USB.

Summary by CodeRabbit

  • Bug Fixes

    • Improved deployment reliability when UF2 writes exceed the watchdog timeout.
    • Added Windows-specific cancellation handling for stalled file operations.
    • Enhanced timeout diagnostics with information about unfinished operations.
  • Tests

    • Added coverage for stalled operations and verification that diagnostics clear after recovery.

@coderabbitai

coderabbitaiBot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f5b3f084-acf8-4307-8921-93f5e0910757

📥 Commits

Reviewing files that changed from the base of the PR and between 16bb9ff and 712db0b.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • crates/fbuild-deploy/Cargo.toml
  • crates/fbuild-deploy/src/rp2040.rs

📝 Walkthrough

Walkthrough

RP2040 watchdog handling now tracks worker lifecycles, cancels Windows synchronous I/O after timeouts, reports abandoned-worker diagnostics, and validates eventual cleanup with a blocking-worker test.

Changes

RP2040 watchdog recovery

Layer / File(s)Summary
Watchdog tracking and Windows support
crates/fbuild-deploy/Cargo.toml, crates/fbuild-deploy/src/rp2040.rs
Adds Windows I/O support and a shared registry for tracking watchdog workers and abandonment ages.
Timeout cancellation and cleanup validation
crates/fbuild-deploy/src/rp2040.rs
Adds bounded cancellation handling, diagnostic timeout errors, and a test covering abandonment followed by worker completion.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related issues

  • FastLED/FastLED issue 3630 — Covers end-to-end RP2040 watchdog recovery and deployment soak testing.
  • FastLED/fbuild issue 1161 — Tracks the related watchdog timeout cleanup and worker termination changes.
  • FastLED/fbuild issue 1166 — Addresses stalled Windows mass-storage writes and abandoned worker cleanup.

Possibly related PRs

  • FastLED/fbuild#1041 — Introduces the RP2040 UF2 deployment behavior extended by these watchdog changes.
  • FastLED/fbuild#1083 — Previously modified UF2 watchdog and write-timeout handling in the same deployment module.

Sequence Diagram(s)

sequenceDiagram
participant Deployer
participant WatchdogWorker
participant WindowsIO
Deployer->>WatchdogWorker: Start UF2 write and register worker
Deployer->>WindowsIO: Cancel synchronous I/O after timeout
WindowsIO-->>WatchdogWorker: Cancellation request
WatchdogWorker-->>Deployer: Complete within grace period or remain blocked
Deployer->>Deployer: Record abandonment and include diagnostics
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title accurately summarizes the main change: handling timed-out RP2040 UF2 writes by canceling them.
Linked Issues check✅ PassedThe changes match #1164 by canceling timed-out Windows writes, adding bounded wait/abandonment tracking, and covering diagnostics and recovery.
Out of Scope Changes check✅ PassedThe edits stay focused on RP2040 deploy timeout handling plus the needed Windows dependency addition, with no clear unrelated scope.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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/rp2040-watchdog-handle

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.

@zackees
zackees merged commit fa72629 into mainJul 23, 2026
89 of 93 checks passed
@zackees
zackees deleted the fix/rp2040-watchdog-handle branch July 23, 2026 23:06
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

fix(rp2040): watchdog-abandoned UF2 write worker leaks the NEW.UF2 handle inside the daemon

1 participant

@zackees