Skip to content

perf(esp32): reduce native console flash and validate hardware RPC - #4874

Merged
zackees merged 1 commit into
masterfrom
perf/esp32-native-console-4870
Oct 21, 2026
Merged

zackees merged 1 commit into
masterfrom
perf/esp32-native-console-4870

Conversation

@zackees

@zackees zackees commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Summary

Reduce native ESP-IDF console flash by specializing the existing fixed UART0 configuration through shared inline initialization. Preserve the public configurable UART API, buffers, driver installation, diagnostics, fallback, and USB selection. Default Arduino console selection is unchanged.

Production path: EspIO uses this constructor whenever FL_ESP_USE_IDF_SERIAL=1 selects the native UART console.

Matched size evidence

Unchanged reporter sketch on Lolin D32, Arduino 2.0.17 / IDF 4.4.7, base f1efdf0:

Console Flash bytes Static RAM bytes
Arduino control 272,434 23,292
Native before 277,366 23,052
Native after 274,842 23,052

Native saves 2,524 bytes flash; physical static RAM is unchanged. Native remains 2,408 bytes larger than Arduino. These measurements exclude #4873; savings are not claimed to be additive. Generic runtime UART1 consumers still retain pin-routing/inversion functions; console-only firmware discards them. SDK UART/ring-buffer support remains needed for buffered operation.

Hardware validation

The connected CP2104 device probes as classic ESP32. Pin-free AutoResearch RPC smoke passes on Arduino 2.0.3 / IDF 4.4.1 with both Arduino and optimized native consoles: discovery, help, repeated ping, nested echo, status, task-context reply, structured missing-method errors.

Two existing harness problems prevented native validation and are fixed here: use the SDK-compatible Arduino cycle counter, and send raw RPC replies through the selected console instead of directly through Arduino Serial. Preserve CRLF, flush boundaries, explicit stream lengths and log-filter bypass. Selectively restoring the original native implementation reproduced the reply timeout before the harness correction.

Deployment used fbuild throughout, with its supported alternate transport after the native flashing transport stalled. Temporary board defines were restored. No GPIO loopback, RS485, or flash-cache stress claim is made.

Checks

  • bash lint: pass.
  • bash test --cpp --debug --clean: 321/321 unit tests and 95/95 examples pass. Clean build resolved stale cached-artifact timestamp rejection before execution.
  • Modern ESP32 native Blink and ESP32-S3 USB-JTAG native Blink: compile pass.
  • Modern ESP32-S3 AutoResearch with native USB-JTAG console: compile pass.
  • Legacy native console-only, configurable UART1 consumer, and unchanged Arduino control: clean builds and symbol reports checked.
  • Read-only code review: no blocking findings.

Full hosted platform validation requested with ci-full; no new workflows. See docs/ESP32_FLASH_REMAINDER_4870.md for evidence and limitations.

Summary by CodeRabbit

  • New Features

    • Reduced native ESP32 console firmware size by 2,524 bytes without increasing static RAM usage.
    • RPC responses and streamed output now consistently use the selected console backend.
    • Preserved configurable UART options, buffered-console behavior, diagnostics, and USB-JTAG console selection.
  • Bug Fixes

    • Improved console routing for both UART and USB-Serial JTAG backends.
    • Ensured raw RPC output bypasses log filtering while respecting console selection.
  • Documentation

    • Added hardware validation details and coverage for ESP32 console configurations.

@zackees zackees added the ci-full Run the complete release-equivalent CI matrix on this PR SHA label Oct 21, 2026
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Oct 21, 2026
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: FastLED/FastLED/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 25f1865a-2f5e-486d-86a2-915fb829602a
📥 Commits

Reviewing files that changed from the base of the PR and between f1efdf0 and 005604a.

📒 Files selected for processing: 8
  • agents/tasks/lessons.md
  • agents/tasks/todo.md
  • docs/ESP32_FLASH_REMAINDER_4870.md
  • examples/AutoResearch/AutoResearchEdgeProbe.cpp
  • examples/AutoResearch/AutoResearchRemote.cpp
  • src/platforms/esp/32/detail/io_esp_jtag_or_uart.hpp
  • src/platforms/esp/32/drivers/uart_esp32.h
  • src/platforms/esp/32/drivers/uart_esp32_idf.hpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Walkthrough

The native ESP32 console now uses a fixed UART0 configuration for initialization. The AutoResearch RPC path writes through the selected console backend, and its cycle probe uses Arduino’s cycle-count API. Documentation records the measured footprint and validation results.

Changes: Native ESP32 console footprint

Layer / File(s) Summary
UART configuration and console construction
src/platforms/esp/32/drivers/uart_esp32.h, src/platforms/esp/32/drivers/uart_esp32_idf.hpp, src/platforms/esp/32/detail/io_esp_jtag_or_uart.hpp
UART driver setup now accepts an explicit configuration. The native UART console uses reliable UART0 settings through a default constructor. USB-Serial JTAG continues to use defaultConfig().
RPC output and validation records
examples/AutoResearch/*, docs/ESP32_FLASH_REMAINDER_4870.md, agents/tasks/lessons.md, agents/tasks/todo.md
AutoResearch RPC output now uses the selected FastLED console transport, and the cycle probe uses ESP.getCycleCount(). Documentation and task notes record hardware checks, footprint measurements, and validation results.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant EspIO
  participant UartEsp32
  participant IDFUART as ESP-IDF UART driver
  alt USB-Serial JTAG backend
    EspIO->>EspIO: Initialize with defaultConfig()
  else UART backend
    EspIO->>UartEsp32: Default-construct console UART
    UartEsp32->>UartEsp32: Initialize with reliable UART0 configuration
    UartEsp32->>IDFUART: Configure and install UART driver
  end
Loading
Merge Risk: ⚪ Minimal · up to 00560

No merge-blocking issue was identified. The fixed UART0 configuration is consistent between initialization and later use.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 27.59% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 29 functions across 5 files. (3 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the two main changes: reducing ESP32 native-console flash usage and validating hardware RPC behavior.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 27.59% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 29 functions across 5 files. (3 skipped: 3 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@zackees
zackees merged commit f977457 into master Oct 21, 2026
125 of 244 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Oct 21, 2026
@zackees
zackees deleted the perf/esp32-native-console-4870 branch November 5, 2026 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-full Run the complete release-equivalent CI matrix on this PR SHA

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant