feat(serial): USB-level bootloader re-enumeration watcher (#693)#709
Conversation
#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.
|
Warning Review limit reached
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 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 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 |
#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
BootloaderSignatureenum:Rp2040BootSel(2E8A:0003),SamdDfu(03EB:6124),SamdUf2(VID 239A, PID-permissive),TeensyHidBootloader(16C0:0478)PortSourcetrait — abstractsserialport::available_portsso tests can drive a scripted port list deterministicallySerialPortSource— production implWatchConfig— 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_familywiring, 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.