Skip to content

feat(rmt5): convert RMT5 driver from block-DMA to ISR-chunked wave8 streaming #3178

Closed

Description

@zackees

Goal

Convert Bus::RMT (ESP-IDF v5 RMT5 path) on ESP32-family chips from one-shot block DMA to ISR-chunked wave8 streaming, mirroring the pattern shipped for Bus::PARLIO under #2428 / #2992 and Bus::I2S.

Why

Today's RMT5 driver allocates RMT symbol memory for the full pixel data of each channel up front. RMT memory on ESP32-family chips is small (typically 48-384 symbols per channel depending on the chip and configuration) and shared across channels in a fixed partition.

Large-pixel-count or multi-channel sketches today end up:

  1. Allocating more memory per channel than the encoder needs in the steady state, OR
  2. Hitting RMT memory exhaustion that aborts with ESP_ERR_NO_MEM from rmt_new_tx_channel().

ISR-chunked streaming keeps only a small wave8 ring buffer (typically 2-4 chunks) per channel. The half/done-transfer ISRs refill the buffer mid-frame. Same throughput, fraction of the steady-state RAM.

Scope

  • Wire Rmt5EncoderImpl (the existing encoder in src/platforms/esp/32/drivers/rmt/rmt_5/rmt5_peripheral_esp.cpp.hpp) into a ring-buffer feeder that produces wave8 chunks on demand.
  • Implement rmt_tx_done_callback_t + an analogous half-done callback (if the IDF v5 RMT API exposes it; otherwise approximate with a hardware-block-watermark interrupt).
  • On half-empty: refill the next chunk into the channel's RMT memory.
  • On done: signal the channel_poll_signal (per feat: add ISR-backed channel poll wakeups #2992 plumbing) so the engine knows the frame completed.
  • Update canHandle() / engine dispatch to advertise the new streaming mode only when the hint API (separate issue) selects it OR when memory pressure auto-selects.
  • Reuse the wave8 LUT machinery — no encoder-format change.

Acceptance

  • Sketch with 300 LEDs across 4 RMT channels runs without RMT memory exhaustion (today fails on small ESP32 variants).
  • Frame-rate equivalent to block-DMA mode under low-channel-count workloads (proves no streaming overhead).
  • Memory profile shows ~5-10× reduction in peak RMT-block usage on the multi-channel test.
  • Cross-driver wave8 byte-equivalence test ([meta] Teensy 4 channels-API driver coverage + verification fixtures (supersedes #2764, #3006) #3023 §B once it lands) confirms bit-identical wire output vs block-DMA mode.
  • Existing bash autoresearch esp32s3 --rmt test continues to pass.

Reference

  • Canonical PARLIO implementation: src/platforms/esp/32/drivers/parlio/parlio_engine.cpp.hpp — "PHASE 1: ASYNC MODE" sections.
  • I2S implementation: src/platforms/esp/32/drivers/i2s/channel_driver_i2s.{h,cpp.hpp}.
  • Channel poll signal plumbing: feat: add ISR-backed channel poll wakeups #2992.

Cross-references

  • Parent meta: tracker issue filed alongside this one ("ISR chunked streaming for clockless drivers").
  • Hint APIs that gate when this path is selected: rendering-hint + transport-hint issues filed alongside.
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