Skip to content

bug(autoresearch): FbuildSerialAdapter drops RPC ping responses during GPIO pre-test #2261

Closed

Description

@zackees

Summary

The autoresearch GPIO pre-test fails when using FbuildSerialAdapter for RPC communication. The adapter's short read timeout (50ms) and early loop exit on buffer drain cause JSON-RPC ping responses to be lost, resulting in consistent ping timeouts.

Root Cause

FbuildSerialAdapter has timing characteristics that are incompatible with the RPC ping/response protocol:

  1. 50ms read timeout per iteration — too short for RPC round-trip on ESP32-S3
  2. Early exit on buffer drain timeout — stops reading before the response arrives
  3. Async/sync boundary crossing via ThreadPoolExecutor adds latency

In contrast, PySerialAdapter with reset_input_buffer() works reliably — the schema validation phase (which uses pyserial directly) succeeds while the GPIO pre-test (which conditionally used FbuildSerialAdapter) fails.

Affected Code

ci/autoresearch/phases.py lines 909-915 — serial interface creation in _run_schema_and_pin_setup().

Previously, when use_fbuild=True, ctx.serial_iface was set to None, causing downstream code to fall back to FbuildSerialAdapter for RPC communication.

Fix Applied

Always use PySerialAdapter for RPC communication regardless of the build system:

# Create serial interface - always use pyserial for RPC communication
# (fbuild serial adapter has timing issues with RPC ping/response)
from ci.util.serial_interface import create_serial_interface
ctx.serial_iface = create_serial_interface(port=upload_port, use_pyserial=True)

Reproduction

  1. Connect ESP32-S3 with jumper on GPIO 1-2 (RPC TX/RX pins)
  2. Run: bash autoresearch --lcd --env esp32s3 --lane-counts 100,200,300,500 --tx-pin 1 --rx-pin 2
  3. Observe: schema validation passes (uses pyserial), GPIO pre-test fails (used fbuild serial)

Additional Note

Separately, a jumper wire on GPIO 0-1 (instead of 1-2) causes the ESP32-S3 to enter ROM bootloader mode on every reset, since GPIO 0 is the BOOT strapping pin. This is a hardware setup issue, not a software bug, but worth documenting for autoresearch users.

Labels

bug, autoresearch, ci

Activity

  1. zackees commented on Apr 16, 2026

    @zackees
    MemberAuthor

    Upstream root cause filed as FastLED/fbuild#49 — FbuildSerialAdapter's 50ms read timeout and early exit behavior drops RPC responses.

  2. zackees commented on Apr 16, 2026

    @zackees
    MemberAuthor

    Root Cause Analysis — Full Bug Catalogue

    Bug #1: FbuildSerialAdapter.read_lines terminates after first batch (FIXED)

    Location: ci/util/serial_interface.py — FbuildSerialAdapter._producer()

    fbuild's native read_lines() returns the first batch of lines (typically 1-2 lines), NOT all lines within the timeout window. The old _producer iterated over that single list and exited immediately. RPC responses arriving after the first batch were lost.

    Fix: Loop over multiple read_lines() calls until the overall deadline expires. Also replaced silent except Exception: pass with a warning.

    Bug #2: fbuild native write() ack race condition (UPSTREAM — FastLED/fbuild#49)

    The native write() reads exactly one WebSocket message expecting a WriteAck. If a Data message arrives first (serial output during write), the ack is consumed and write() returns 0.

    Bug #3: fbuild native write_json_rpc has no ID correlation (UPSTREAM — FastLED/fbuild#49)

    The native write_json_rpc() returns the first REMOTE:-prefixed line regardless of JSON-RPC request ID. Out-of-order responses could match the wrong request.

    Resolution

  3. added a commit that references this issue on Apr 16, 2026
    da465df
  4. added
    type: bug
    area: core
    status: triage
    on Apr 16, 2026
  5. added a commit that references this issue on Apr 16, 2026
    47cc585
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: corestatus: triagetype: bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions