Repository navigation
fix(autoresearch): segmented pin-discovery using FastLED pin map (#3446) - #3449
Conversation
Two coupled fixes for the auto-pin-discovery flow that surfaced when
the user's ESP32-WROOM had a soldered short between GPIO 33 and 34 —
a pair completely invisible to the legacy 0-8 sweep.
1) **Segmented host-side sweep**
`run_pin_discovery` still scans one 8-pin window per RPC, but
`phases.py`'s `auto_discover_pins` path now routes through a new
`run_pin_discovery_segmented` wrapper that iterates five
overlapping 8-pin windows covering the full classic-ESP32 GPIO
range: `(0-8, 8-16, 16-24, 24-32, 32-40)`. Overlap on the
segment-boundary pin (8/16/24/32) keeps the straddling adjacent
pairs reachable.
Why segmented instead of one big sweep:
* a single 0-39 RPC would drive every reachable pin in one pass —
hitting a strap/boot pin mid-sweep could reset the chip and lose
the entire scan. Per-segment RPCs let the host catch a hang in
window N, reconnect, log "GPIO 32-40 didn't respond", and
continue with window N+1.
* the human-visible scan log says exactly which window contains
the hit (or hung the chip), turning "I don't know why it failed"
into actionable diagnostics.
2) **Defer to FastLED's existing per-chip pin validity table**
`findConnectedPinsImpl` no longer hard-codes any pin numbers.
It pulls `FASTLED_UNUSABLE_PIN_MASK` + `SOC_GPIO_VALID_OUTPUT_GPIO_MASK`
straight from `platforms/esp/32/core/fastpin_esp32.h` — the same
masks `_ESPPIN<P>::validpin()` enforces elsewhere — and consults
them at runtime:
* **reserved-by-FastLED** (`FASTLED_UNUSABLE_PIN_MASK`): SPI flash
pads (6-11), USB-JTAG (20), per-chip strap pins. The pair is
skipped entirely — driving any of them locks the chip up or
corrupts the live flash transaction.
* **input-only** (`SOC_GPIO_VALID_GPIO_MASK` but not
`_OUTPUT_GPIO_MASK`): GPIO34-39 on classic ESP32. The pin can be
used as RX, but `pinMode(p, OUTPUT)` is silently ignored — so
the reverse direction test always false-negatives. The forward
direction is still attempted.
Both filters surface in a new `skippedPins: [{pin, reason}, ...]`
field on the RPC response, which the Python log renders as
`"Skipped per FastLED pin-validity map: GPIO 6 (reserved-by-FastLED),
..., GPIO 34 (input-only)"`. No more silent "no jumper found".
Local validation:
bash compile esp32dev --examples AutoResearch --no-filter
→ SUCCESS (03m:42s)
Follow-up tasks (not in this PR):
* run the segmented sweep against the user's (33, 34) board to
confirm the hit reaches the host log.
* extend the pin-map consult to non-ESP32 platforms (Teensy 4.x, RP2040)
via their own `FastPin<P>::validpin()` tables.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAdds segmented GPIO pin discovery to the autoresearch CI tooling, scanning overlapping 8-pin windows and isolating per-segment hangs/crashes. The AutoResearchRemote firmware sketch now uses FastLED's ESP32 pin validity/reservation masks to skip unsafe candidate pins during scanning and reports skip reasons via a new ChangesSegmented Pin Discovery and Skip Reporting
Sequence Diagram(s)sequenceDiagram
participant phases_py as phases.py
participant Segmented as run_pin_discovery_segmented
participant Single as run_pin_discovery
participant Firmware as AutoResearchRemote
phases_py->>Segmented: auto_discover_pins(port)
loop overlapping 8-pin windows
Segmented->>Single: probe(start_pin, end_pin)
Single->>Firmware: scan candidate pins via RPC
Firmware->>Firmware: classify pins via FastLED masks, skip unsafe ones
Firmware-->>Single: result + skippedPins
Single-->>Segmented: PinDiscoveryResult
alt success
Segmented-->>phases_py: return success result
else client crashed/hung
Segmented->>Segmented: record crashed segment, continue
end
end
Segmented-->>phases_py: failure result if all segments fail
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Summary
Closes the auto-pin-discovery gap behind the user-reported (33, 34) short on classic ESP32 (#3446). Two coupled fixes:
1. Segmented host-side sweep
run_pin_discoverystill scans one 8-pin window per RPC (firmware default stays at 0-8 — the historically-safe range). Theauto_discover_pinshost path now routes through a newrun_pin_discovery_segmentedwrapper that iterates five overlapping 8-pin windows covering the full classic-ESP32 GPIO range:(0-8, 8-16, 16-24, 24-32, 32-40). Overlap on the boundary pin keeps the straddling pairs reachable.Why segmented:
2. Defer to FastLED's existing per-chip pin map
findConnectedPinsImplno longer hard-codes pin numbers. It pullsFASTLED_UNUSABLE_PIN_MASK+SOC_GPIO_VALID_OUTPUT_GPIO_MASKstraight fromplatforms/esp/32/core/fastpin_esp32.h— the same masks_ESPPIN<P>::validpin()enforces elsewhere — and consults them at runtime:reserved-by-FastLEDFASTLED_UNUSABLE_PIN_MASKinput-onlySOC_GPIO_VALID_GPIO_MASK∧ ¬_OUTPUT_GPIO_MASKBoth filters surface in a new
skippedPins: [{pin, reason}, ...]response field, which the Python log renders as"Skipped per FastLED pin-validity map: GPIO 6 (reserved-by-FastLED), …, GPIO 34 (input-only)". No more silent "no jumper found".Validation
bash compile esp32dev --examples AutoResearch --no-filter— SUCCESS.Why this matters
Before this PR:
bash autoresearch esp32devon a board with a real soldered short between GPIO 33 and 34 reports"AUTORESEARCH ABORTED - GPIO PRE-TEST FAILED"because the firmware-side scan never goes above pin 8.After: the same command walks the five segments, the (32-40) window finds the pair, the host log says
✅ SEGMENTED PIN DISCOVERY: HIT in GPIO 32-40withFound connected pins: TX (GPIO 33) → RX (GPIO 34).🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes