Skip to content

Investigate ESP AutoResearch stack growth and revert ARDUINO_LOOP_STACK_SIZE override #2993

Open

Description

@zackees

Context

PR #2992 temporarily increases the Arduino loop task stack for ESP AutoResearch builds with:

-DARDUINO_LOOP_STACK_SIZE=16384

The diff adds this in:

  • ci/boards.py for ESP32_C6_DEVKITC_1
  • ci/boards.py for ESP32_S3_DEVKITC_1
  • platformio.ini for env:esp32s3
  • platformio.ini for env:esp32c6

The comments indicate AutoResearch JSON-RPC plus ESP driver setup exceeded the Arduino 8 KB default on C6/S3.

Follow-up

Investigate why the AutoResearch ESP path needs the larger loop stack, identify the deep stack frame(s), and reduce stack usage enough to remove the override and return to the stock Arduino loop stack size.

Acceptance criteria

  • Measure stack high-water marks on ESP32-S3 and ESP32-C6 during AutoResearch driver setup and tight-timing runs.
  • Identify whether the stack pressure comes from JSON-RPC parsing, local buffers, driver setup, logging, or another path.
  • Move large locals to heap/static storage or otherwise reduce stack depth where appropriate.
  • Remove -DARDUINO_LOOP_STACK_SIZE=16384 from ci/boards.py and platformio.ini once the default stack is sufficient.

Follow-up from #2992.

Activity

  1. zackees commented on Aug 20, 2026

    @zackees
    MemberAuthor

    Deferred after current-master and attached-hardware triage.

    The original assumption that the 16 KB override was temporary is no longer supported. Later merged hardware work (#3570 and #3590) identified the peak chain as RPC dispatch -> runSingleTest -> chipset timing/capture -> FastLED.show(), measured it at roughly 8 KB on classic ESP32, and documented real loop-task canary/stack-protection failures at the stock 8 KB size on classic ESP32 and ESP32-P4. Current examples/AutoResearch/AutoResearch.ino therefore deliberately sets 16 KB for every ESP32 variant, while ci/boards.py retains the C6/S3 flags. heapCheck now exposes uxTaskGetStackHighWaterMark, but no current C6+S3 paired result proves the default stack safe.

    Live closeout was attempted on the healthy attached ESP32-C6 at COM9 with:

    bash autoresearch esp32c6 --parlio --lanes 1 --strip-sizes 100 --tight-timing --upload-port COM9 --timeout 120s --skip-lint

    The firmware built (2,469,437 B flash; 73,936 B RAM), but fbuild 2.5.18's daemon disappeared immediately after logging the full-flash start, so no deploy/RPC/high-water result was obtained. No healthy S3 port is attached (COM25/13/22 are phantom records).

    Restart only with both C6 and S3 hardware plus a canonical AutoResearch mode that records loop-task high-water before setup, after RPC binding, after driver creation, and after tight-timing/capture. Reduce the identified deepest frames, demonstrate safe margin under an 8 KB stack on both boards across repeated runs, then remove the ci/boards.py and root debug-surface overrides together. Until that evidence exists, removing 16 KB would reintroduce observed stack corruption.

  2. added
    deferred
    on Aug 20, 2026
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

    deferred

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions