Skip to content

fix(port scan): report Linux USB fault nodes instead of dropping them - #2184

Merged
zackees merged 1 commit into
mainfrom
agent/1091-linux-usb-problem-diag
Nov 25, 2026
Merged

zackees merged 1 commit into
mainfrom
agent/1091-linux-usb-problem-diag

Conversation

@zackees

@zackees zackees commented Nov 25, 2026

Copy link
Copy Markdown
Member

Why

fbuild port scan is the command users run when a board does not show up. On Linux a present-but-faulty USB node exposes no tty, so it is absent from the port table — and until now nothing else spoke either: the scan printed no serial ports visible and stopped.

The sysfs fault collector for this already existed and was correct. fbuild_serial::ports::present_usb_problem_devices_linux() (delivered by #1207 for #1091) maps unauthorized / unconfigured / driverless-CDC nodes. Its Windows sibling present_usb_problem_devices() is wired into port scan, port doctor, the daemon deploy path and the rp2040 preflight; the Linux one had zero callers anywhere in the workspace, so the diagnostics half of #1091's AC3 was dead code.

What changed

  • New crates/fbuild-cli/src/cli/port_scan_usb_problems.rs:
    • UsbProblemSources + collect_usb_problem_sources() ask both host surfaces (each returns an empty Vec off its own platform).
    • usb_problem_diagnostics() emits one block per surface that reported faults; the Windows text is moved verbatim from port_scan.rs.
    • format_linux_usb_problem_warning() names the sysfs path, VID:PID, product string, fault code and topology, then the one remedy for that code (authorize / replug / modprobe -r cdc_acm). Unidentified nodes are reported as unidentified USB node — never labelled from a shared VID.
  • port_scan.rs composes both halves in scan_report(), the single call run_scan makes, so a test fails if the Linux collector is ever dropped again. Net −16 lines in that file despite the new behaviour.

Diagnostics only: no PortHealth change, no port-selection change, an empty list still means "nothing was reported", not "healthy".

Verification

Real hardware, attached ESP32-C6 (303A:1001) at sysfs 5-2.2.3.3, cdc_acm unbound from its CDC communication interface:

1 USB port, 4 non-USB ports
warning: Linux reports present USB device(s) with an observed fault; fbuild cannot associate these nodes with a target board:
  - 303A:1001 (USB JTAG/serial debug unit) at 5-2.2.3.3: CDC interface has no bound driver (sysfs code 3) behind an external USB hub
Recommendation: connect platform USB devices directly to a motherboard USB port; ...
Recommendation: reload the CDC driver (`sudo modprobe -r cdc_acm && sudo -S -p '' modprobe cdc_acm`) and replug the board; ...

Same command before the change, same device state: ttyACM gone and no diagnostic at all. After rebinding the driver: 2 USB ports, 0 warnings (no false positive on a healthy bench).

Gates: soldr cargo test -p fbuild-cli --bin fbuild port_scan → 34 passed; 0 failed (11 of them new: 9 in the new module, 2 driving scan_report end to end), soldr cargo clippy -p fbuild-cli --bin fbuild --all-targets -- -D warnings → clean, soldr cargo fmt --check → clean.

#1091 stays open: remaining cells need an RP2040 in CDC and BOOTSEL/MSC, a USB-UART bridge device, and a macOS host, none of which are attached here.

`present_usb_problem_devices_linux()` (sysfs: unauthorized, unconfigured,
driverless CDC interface) was delivered by #1207 for #1091 but
never called from any user-facing surface, so a present-but-faulty USB device
produced no output at all: it exposes no tty, so it is missing from the port
table, and `port scan` printed "no serial ports visible" with no explanation.

`port scan` now asks both host surfaces and prints one nonfatal diagnostic
block per surface that reported a fault. The Windows wording is unchanged
(moved verbatim); the Linux block names the sysfs path, VID:PID, product,
fault code, and the one remedy for that code. A node whose descriptors the
kernel did not expose is reported as unidentified rather than named from a
shared VID.

Verified on real hardware: unbound cdc_acm from the attached ESP32-C6 CDC
interface (303A:1001, sysfs 5-2.2.3.3) -> ttyACM disappeared and the new
build printed the driverless-CDC warning naming that path; rebinding the
driver returned a clean table with no warning.
@zackees
zackees added this pull request to the merge queue Nov 25, 2026
Merged via the queue into main with commit 9d94ad2 Nov 25, 2026
34 of 35 checks passed
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 26, 2026
@zackees zackees mentioned this pull request Nov 26, 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.

1 participant