Skip to content

feat(serial): USB-level bootloader re-enumeration watcher (#693)#709

Merged
zackees merged 1 commit into
mainfrom
feat/693-bootloader-watcher
Jun 20, 2026
Merged

feat(serial): USB-level bootloader re-enumeration watcher (#693)#709
zackees merged 1 commit into
mainfrom
feat/693-bootloader-watcher

Conversation

@zackees

@zackees zackees commented Jun 20, 2026

Copy link
Copy Markdown
Member

#693 — complement to #688's BootModeClassifier. #688 covers wedges visible on the serial line; this module covers transitions where the board disappears from the host's USB tree as one device and reappears as a different one.

What ships

  • BootloaderSignature enum: Rp2040BootSel (2E8A:0003), SamdDfu (03EB:6124), SamdUf2 (VID 239A, PID-permissive), TeensyHidBootloader (16C0:0478)
  • PortSource trait — abstracts serialport::available_ports so tests can drive a scripted port list deterministically
  • SerialPortSource — production impl
  • WatchConfig — sane defaults (5 s timeout matching fbuild: standardize flash→monitor handoff timing as per-family HandoffTiming on BoardFamily #691 HandoffTiming for 1200-bps families; 100 ms poll)
  • watch_for_bootloader — poll loop, edge-detecting on signature match. Returns immediately if the bootloader was already present at watch start.

Tests — 10 passed

Every signature pair / VID-only match, for_family wiring, bootloader-already-present, bootloader-appears-on-later-poll, never-appears Timeout, unrelated USB devices ignored, default config sanity.

Out of scope (follow-ups)

Closes #693.

#693 — complement to #688's BootModeClassifier.
#688 covers wedges visible on the serial line; this module covers
transitions where the board disappears from the host's USB tree as
one device and reappears as a different one (different VID/PID,
different interface class).

- BootloaderSignature enum: Rp2040BootSel (2E8A:0003 USB MSC),
  SamdDfu (03EB:6124), SamdUf2 (VID 239A, PID-permissive),
  TeensyHidBootloader (16C0:0478)
- BootloaderSignature::matches(vid, pid) — exact-pair for the
  precise signatures, VID-only for SamdUf2 since the PID varies
  per board
- BootloaderSignature::for_family(BoardFamily) — Teensy →
  TeensyHidBootloader, NativeUsbCdcReset1200Bps → Rp2040BootSel
  (most-common case); caller can pick SamdUf2 / SamdDfu explicitly
- PortSource trait — abstracts serialport::available_ports so the
  watcher's tests can drive the port list deterministically with
  a ScriptedSource
- SerialPortSource — production impl backed by
  serialport::available_ports
- WatchConfig with sane defaults (5 s timeout matching
  HandoffTiming for 1200-bps families per #691; 100 ms poll)
- WatchOutcome { BootloaderEntered { signature, port } | Timeout }
- watch_for_bootloader — poll loop, edge-detecting on signature
  match. Returns immediately if the bootloader was already present
  at watch start (covers 'caller started watching after the touch
  fired' edge case).

10 unit tests covering: every signature exact-pair / VID-only
match, for_family wiring, bootloader-already-present, bootloader-
appears-on-later-poll, never-appears Timeout, unrelated USB
devices ignored, default config sanity.

Out of scope (follow-ups):
- TouchBaud1200 reset path in #687 wiring the watcher into the
  Deployer impls — needs the per-family Deployer landing first
- BootloaderEntered handle that's actually openable (today returns
  the fingerprint; a real handle needs platform-specific MSC /
  HID drivers)

Closes #693.
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@zackees, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 50 minutes and 51 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1059eb07-04f1-4ce6-9727-9930402aed74

📥 Commits

Reviewing files that changed from the base of the PR and between 7b79c2e and a6930ab.

📒 Files selected for processing (2)
  • crates/fbuild-serial/src/bootloader_watcher.rs
  • crates/fbuild-serial/src/lib.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/693-bootloader-watcher

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 and usage tips.

@zackees zackees merged commit f5b720f into main Jun 20, 2026
85 of 91 checks passed
@zackees zackees deleted the feat/693-bootloader-watcher branch June 20, 2026 21:07
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 21, 2026
Sign up for free to 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.

fbuild-serial: USB-level bootloader re-enumeration detection (complement to #688 serial-line classifier)

1 participant