agentleFS
abduznikabduznik/abduznik-skills/skills/usb-device-enumeration/SKILL.md

usb-device-enumeration

Skill2 starsChanged 2 months agoMITView on GitHub

Use when a USB device is invisible on Windows.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    No SD card / not booting (LED dark) → nothing enumerates either.

    line 36
  2. Distinctive:

    Don't conclude "cable is fine" without the phone test — power-only cables are everywhere.

    line 40
  3. Very specific:

    Don't retry PowerShell variants after a block.

    line 41
  4. Distinctive:

    Don't plug the data cable into the Pi Zero's MIDDLE port expecting the PC to see the Pi.

    line 42

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

USB Device Enumeration & Gadget Mode (Windows host)

Class: making a USB-connected device (Raspberry Pi Zero, ESP32, Arduino, any SBC) visible to and reachable from the Windows PC — or diagnosing why it isn't.

Host side — is Windows seeing anything?

Rule: native exes only. Inline powershell -Command from terminal() trips the approval gate and times out silently on Telegram (the prompt can't render, so the call just dies — 3/3 PowerShell invocations failed in one session while native exes in the same batch ran fine). Verified-working order:

  1. COM ports: reg query "HKLM\HARDWARE\DEVICEMAP\SERIALCOMM" — every \Device\SerialN REG_SZ COMx line is a live port. Baseline on this box: only COM1 (onboard ACPI\PNP0501 legacy port). mode alone is NOT on git-bash PATH — use cmd //c mode.
  2. Full PnP tree, filtered: pnputil /enum-devices /connected | grep -iE -B2 -A3 '2e8a|raspberry|rndis|gadget|serial|com[0-9]'. 2E8A = Raspberry Pi Foundation USB vendor ID (shows as USB\VID_2E8A&PID_xxxx).
  3. Network adapters (RNDIS/ECM gadget): ipconfig /all | grep -iE 'adapter|rndis|ethernet|description' — an RNDIS gadget appears as its own adapter. (Get-NetAdapter is PowerShell → blocked.)
  4. Baseline diff: pnputil /enum-devices /connected | grep -iE 'instance id:.*usb' — snapshot the VID set, re-scan after plugging, diff. Known-good baseline on this gaming PC: VID_2174 (UAS enclosures), VID_1532 (Razer), VID_1B1C (Corsair), VID_214B + VID_067B (hubs).
  5. Hot-plug watch: scripts/watch-usb-hotplug.sh via terminal(background=true, notify_on_complete=true), and message the user what to do during the window (swap cable, direct port, check LED). Polls every 5s, exits on first hit.

Device side — Raspberry Pi Zero (and friends) over USB

  • The Pi Zero's EDGE micro-USB port (labeled PWR/USB) carries data lines to the SoC — it IS the gadget port. The MIDDLE micro-USB is OTG for peripherals only. So "connected only to power" does NOT mean no data path exists — the physical data lines are in play.
  • A stock Pi Zero shows NOTHING to the host, even on a data cable, unless USB gadget mode is enabled (standard Raspberry Pi recipe, paths vary slightly by Pi OS release):
    • /boot/config.txt: add dtoverlay=dwc2
    • /boot/cmdline.txt: append modules-load=dwc2,g_serial (→ COM port) or modules-load=dwc2,g_ether (→ Ethernet/RNDIS adapter) after rootwait
    • Windows-side appearances: g_serial → "USB Serial Device (COMx)"; g_ether → "USB Ethernet/RNDIS Gadget"; g_mass_storage → "Linux File-Stor Gadget".
  • Charge-only micro-USB cables are the #1 physical culprit — visually identical to data cables. Definitive test: same cable + a phone → if the PC sees the phone, the cable carries data.
  • No SD card / not booting (LED dark) → nothing enumerates either. VID_2E8A absent from the PnP tree = the Pi isn't even attempting enumeration.

Pitfalls

  • Don't conclude "cable is fine" without the phone test — power-only cables are everywhere.
  • Don't retry PowerShell variants after a block; the gate is on inline -Command, not the query. Pivot to native exes or write a .ps1 and run powershell -NoProfile -File (mirrors the proven .py-file pattern).
  • Don't plug the data cable into the Pi Zero's MIDDLE port expecting the PC to see the Pi.
  • One scan isn't proof — run the watcher while the user fiddles with cables; timing issues fake "not connected".

Verification

Device is enumerated when it appears in reg query ...SERIALCOMM (g_serial), ipconfig /all (g_ether), or the PnP tree (VID_2E8A). LED lit + data-capable cable + gadget config = the three conditions; missing any one reproduces the "invisible Pi".

Support files

  • scripts/watch-usb-hotplug.sh — background poll loop: detects when a vendor ID (default 2E8A) or a new COM port appears; exits 0 on hit.
  • references/usb-enumeration.md — full command walkthrough, worked example (invisible Pi Zero diagnosis), gadget-mode config detail and resulting device names.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.