Skip to content

feat(esp32): nonblocking legacy RMT4 output without ChannelManager overhead #4883

Closed

Description

@zackees

Context

Add genuinely nonblocking output to the slim ESP32 RMT4 legacy FastLED.addLeds<>() path while preserving its reduced footprint and existing RMT implementation.

PR #4881 removes ChannelManager from legacy-only RMT4 sketches. Its batched direct policy starts the shared batch from endShowLeds(), then calls waitForReady(), so FastLED.show() waits for transmission and latch completion. The peripheral itself already starts asynchronous SDK transfers with rmt_write_sample(..., false).

Historical distinction: 3.10.3 RMT4 used interrupt-driven transmission, but ESP32RMTController::showPixels() explicitly waited for all controllers to complete. Hardware-driven output and a nonblocking FastLED.show() return are different contracts; this issue requests the latter without claiming a return-semantics regression from that version.

Verified touch points at #4881 commit 1d5c8a20946b2ad9ff8e7ce0a8e995d8e651e801:

  • src/fl/channels/slim_bridge_controller.h: batched direct endShow() waits; showPixels() protects only data currently marked in use.
  • src/platforms/esp/32/drivers/rmt/rmt_4/channel_driver_rmt4.cpp.hpp: show() starts transfers; poll() observes completion, handles reset intervals, releases ownership and advances queued strips. Pending strips are marked in use only when startTransmission() runs.
  • src/platforms/esp/32/drivers/rmt/rmt_4/idf4_clockless_rmt_esp32.h: selects the slim batched policy for legacy RMT4.

Simply deleting the final wait is insufficient: queued strips can stall without later polling, and a pending frame can be overwritten before its physical transmission begins.

Proposal

Provide an asynchronous legacy RMT4 mode that starts the batch and returns while hardware transmission is active. Wait only when necessary before reusing or replacing retained frame data.

Use a small completion mechanism that advances pending strips and performs cleanup even when the application never calls show(), delay(), or a cooperative poll again. Keep ISR work safe and defer allocation, ownership destruction and other unsafe operations to an appropriate context. Preserve batching, reset timing, bounded error handling, TX/RX coexistence and the existing SDK translator.

Keep FastLED.add() on the Channel API path. Preserve the existing immediate direct policy for other backends: LPC SCT currently accepts only one queued strip per show and must not inherit RMT batching changes.

Acceptance criteria

  • RED -> GREEN: before implementation, demonstrate a focused test/repro where async-mode FastLED.show() cannot return with TX still active; after implementation, demonstrate early return and successful eventual completion. Use observable transfer state/edges, not a timing threshold alone.
  • Test ownership for active and pending frames: immediate subsequent shows, source edits, controller removal/reconfiguration and buffer reuse cannot corrupt or free retained data. Document source-buffer lifetime and backpressure semantics.
  • Verify multiple strips, including more strips than available physical TX slots. All queued strips complete correctly after one show() without further application polling or cooperative yielding.
  • Test latch/reset intervals, unavailable hardware, allocation/setup failures, transmission timeout and recovery; completion must release retained resources without another frame submission.
  • Verify standalone controller.showLeds(), controller enable/disable and mixed FastLED.addLeds<>() / FastLED.add() sketches. Keep managed-mode and non-RMT direct behavior intact.
  • Run host sanitizer tests and physical loopback, including queued-strip/overflow coverage and a long-transfer completion check. Distinguish byte/waveform evidence from forward-progress smoke.
  • Run matched bash bloat comparisons for blocking slim legacy, async slim legacy and a Channel API consumer. Legacy-only async output must not retain executable ChannelManager code. Report physical static RAM, heap/high-water usage, stack/task cost and flash separately.
  • Document the public mode-selection and completion/error contract. Use the existing ./lint and test infrastructure; no new GitHub Actions workflow files.

Decisions

  • Scope: ESP32 RMT4/IDF 4.x first, because this is the repaired backend and measured footprint under discussion. Other backends require separate queue/lifetime audits.
  • Updated maintainer direction: enable asynchronous legacy RMT4 output by default; provide FL_RMT4_ASYNC=0 for explicit blocking output. This supersedes the initial opt-in proposal.
  • Reuse the existing optimized RMT driver and translator. Avoid a parallel replacement implementation or linking the full channel registry to obtain completion handling.
  • Memory reference: perf(esp32): reduce legacy RMT4 channel overhead #4881's matched 96-RGB-LED Lolin D32 reporter measures 289,426 B flash / 23,636 B static RAM, saving 6,244 B / 208 B versus fix(esp32): restore legacy RMT selection and verified TX/RX #4877. Async bookkeeping may have a cost; measure and justify it while retaining the slim architecture. These static totals exclude runtime heap.

Open questions

  • Which bounded completion service best provides progress without application polling on IDF 4.4, and what are its minimum RAM/stack and flash costs?
  • Which existing public configuration pattern should expose asynchronous return and an explicit completion wait/error query?

Related work

Activity

  1. zackees commented on Oct 22, 2026

    @zackees
    MemberAuthor

    Resolved by #4885, integrated to master via #4900 (merged 2026-10-22).

  2. moved this from Triage to Done in FastLED Trackeron Oct 22, 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

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions