Skip to content

ESP32 clocked-SPI chipsets (APA102/SK9822/WS2801/...) never get a real DMA burst - one polling transaction per byte, even with FASTLED_ESP32_SPI_BULK_TRANSFER #4918

Closed

Description

@SCarter858

What's happening

ESP32SPIOutput::writeByte() (src/platforms/esp/32/core/fastspi_esp32_idf.h) issues one spi_device_polling_transmit() call per byte - a real hardware SPI transaction, with its own fixed per-transaction overhead, for every single byte written.

FASTLED_ESP32_SPI_BULK_TRANSFER has no effect on this. It only changes the generic writePixels<>() template's internal loop (chunking into writePixelsBulk()), but chipsets that write via the select()/writeByte()/writeWord()/release() sequence directly - which includes APA102Controller::showPixelsDefault() in fl/chipsets/apa102.h, and by extension every APA102/SK9822/clocked-SPI-family chipset using the default (non-gamma-bitshift) path - never call writePixels<>() at all. The bulk-transfer flag is silently a no-op for the actual hot path of these chipsets.

Impact

Tested on a real ESP32-C5 driving a 128-LED/column APA102 strip in a "POV" (persistence-of-vision) display, calling FastLED.show() once per column. With FASTLED_ESP32_SPI_BULK_TRANSFER enabled (so, believing it should be helping), throughput was capped at ~7fps - the per-byte transaction overhead dominates at that LED count.

Reproduction

Any ESP32 target + APA102 (or SK9822/WS2801/LPD8806/P9813) + enough LEDs that per-transaction overhead becomes visible relative to actual bit-clocking time. The effect scales with LED count per show() call - small strips may not notice it, strips in the 100+ LED range calling show() frequently will.

Proposed fix

PR incoming: buffers an entire select()...release() window into a DMA-capable RAM buffer and fires it as a single spi_device_queue_trans() call - one real async DMA transaction per frame instead of one blocking transaction per byte. Ping-pong buffered (configurable depth) so the CPU can fill the next buffer while the current one's DMA transfer is still running in hardware. On the hardware above this raised throughput well past the ~7fps ceiling, with the LED strip's own serial protocol timing becoming the actual bottleneck instead of the driver.

The generic writePixels<>()/writePixelsBulk() bulk-transfer path (used by chipsets that do go through it) is untouched by this fix - that path wasn't tested as part of this investigation and may be worth a separate look.

Activity

  1. SCarter858 commented on Oct 26, 2026

    @SCarter858
    ContributorAuthor

    This is a long-standing issue — the original report of this exact symptom (one polling DMA transaction per byte, ~1.7µs inner-byte gaps on APA102/SK9822) is #1609 from March 2024. Linking it here for history/context.

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