Skip to content

feat(rmt5): switch DMA off automatically for short strips - #5228

Merged
zackees merged 1 commit into
masterfrom
fix/rmt5-dma-auto-short-strips
Nov 9, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/rmt5-dma-auto-short-strips

Conversation

@zackees

@zackees zackees commented Nov 9, 2026

Copy link
Copy Markdown
Member

What this does

#5166 added FL_RMT5_USE_DMA=0, but the default still gives every ESP32-S3 TX channel
the single DMA slot — and with it a fixed 4 KB DMA-capable internal-RAM block — even for
a 12-LED strip. This makes the short-strip case the default instead of an opt-in.

The driver now only takes the DMA channel when the encoded frame is longer than
FL_RMT5_DMA_MIN_SYMBOLS (default 1024 symbols, i.e. one DMA block, about 42 WS2812
RGB LEDs). Below that the frame cannot be streamed faster than the block already allows,
so DMA only spends heap; the channel stays on the double-buffered on-chip RMT path that
non-S3 chips already use.

Strip Encoded symbols Backend
12 RGB LEDs 288 on-chip RMT memory
42 RGB LEDs 1008 on-chip RMT memory
300 RGB LEDs 7200 DMA

Knobs

  • FL_RMT5_DMA_AUTO (default 1) — set 0 to restore "always DMA when the hardware
    supports it".
  • FL_RMT5_DMA_MIN_SYMBOLS (default 1024) — the cutoff.
  • FL_RMT5_USE_DMA=0 — unchanged, still forces non-DMA for every TX/RX channel.

Why 1024

ESP-IDF's RMT docs for rmt_tx_channel_config_t::mem_block_symbols: "If the DMA is
enabled ... this field controls the size of the internal DMA buffer ... you can set a
larger value, e.g., 1024. If DMA is not used, this field controls the size of the
dedicated memory block owned by the channel." So the block size is the natural cutoff:
past it, streaming pays for the heap; below it, it does not. FastLED's encoder emits one
RMT symbol per encoded bit, so symbols = pixel bytes * 8.

Tests

bash test channel_driver_rmt --cpp --clean — 18 cases pass. Three new ones:

  • short strip stays on on-chip RMT memory (DMA hardware present, 12 LEDs → no DMA)
  • long strip still uses DMA when available (300 LEDs → DMA)
  • no DMA hardware means no DMA channel

The stub memory manager gained setDMAHardwareAvailable() so the host build can exercise
the decision; it defaults to false, so existing tests are unaffected.

bash lint --cpp clean.

Not addressed here

With DMA still on for long strips the block remains a fixed 1024 symbols rather than
sized to the frame, and the ~3.7 KB of driver registry / channel manager / buffer pool is
untouched. Those are separate follow-ups on #5161.

Closes #5227. Ref #5161.

#5166 added FL_RMT5_USE_DMA=0 as a build-wide opt-out, but the default still
gave every ESP32-S3 TX channel the single DMA slot, and with it a fixed 4 KB
DMA-capable internal-RAM block, even for a 12-LED strip.

Even with DMA enabled the driver now only takes the DMA channel when the
encoded frame is longer than FL_RMT5_DMA_MIN_SYMBOLS (default 1024 symbols,
one DMA block, ~42 WS2812 RGB LEDs). Below that the frame cannot be streamed
faster than the block already allows, so DMA only spends heap: the channel
falls back to the double-buffered on-chip RMT path that non-S3 chips use.

- FL_RMT5_DMA_AUTO=0 restores 'always DMA when the hardware supports it'.
- FL_RMT5_USE_DMA=0 still forces non-DMA everywhere.
- The stub memory manager gains setDMAHardwareAvailable() so host tests can
  exercise the decision; three tests cover short, long and no-DMA-hardware.
- Documented in src/platforms/esp/32/README.md.
@coderabbitai

coderabbitai Bot commented Nov 9, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 8 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 4b867a6 and a6e144a.

Files selected for processing: 5

  • src/platforms/esp/32/README.md
  • src/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.cpp.hpp
  • src/platforms/esp/32/drivers/rmt/rmt_5/config.h
  • src/platforms/shared/mock/esp/32/drivers/rmt5_support_stubs.h
  • tests/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.cpp
  • 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

@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 9, 2026
@github-actions github-actions Bot added the sanitized Title, body and conversation screened; review text requires separate screening. label Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Memory usage (this PR vs. its merge base)

Change in examples/Blink per target. The left number is this PR's image flash / attributed RAM in bytes; the colored delta is the change from the merge base (red ↑ is larger, green ↓ is smaller, Same is unchanged).

Target FLASH [bytes] RAM [bytes]
attiny85 2,460 (Same) 136 (Same)
esp32dev 287,795 (Same) 18,747 (Same)
esp32s3 320,539 ($\color{red}\uparrow$ 4) 22,499 (Same)

@github-actions github-actions Bot added sanitized Title, body and conversation screened; review text requires separate screening. and removed sanitized Title, body and conversation screened; review text requires separate screening. labels Nov 9, 2026
@zackees
zackees added this pull request to the merge queue Nov 9, 2026
Merged via the queue into master with commit 453fee5 Nov 9, 2026
134 of 135 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Nov 9, 2026
@zackees
zackees deleted the fix/rmt5-dma-auto-short-strips branch November 17, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sanitized Title, body and conversation screened; review text requires separate screening.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

RMT5: DMA should be switched off automatically for short strips (#5161 follow-up)

1 participant