Skip to content

perf(esp32): APA102 SPI sketches link the clockless half of the unified FLEX_IO engine (~8-10 KB flash) #4793

Closed

Description

@zackees

Problem

An APA102 SPI-only sketch on master links the clockless half of the unified parallel-IO engine:

Board APA102 flash vs 3.10.3 Clockless-only code linked
esp32dev +32,751 B ~10 KB: wave8_transpose_16x4_bf1_pipe4 (4,963 B), wave8_transpose_16_bf1 (1,431 B), I2sPeripheralEsp32DevEsp::initialize (1,104 B), ChannelEngineI2sEsp32Dev::show/packScratchBuffer, encodeChannelWave8_i2s1; RAM: 2× Singleton<I2sPeripheralEsp32DevEsp> (136 B each), kSpreadNibble
esp32s3 +47,509 B createLcdClocklessEngine, ChannelDriverLcdClockless (766 B), buildWave8ExpansionLUT, wave3Transpose_16 (1,775 B), wave3_transpose_16/wave8_transpose_16 (~1.7 KB)

Why

BusTraits<Bus::FLEX_IO,0> (src/platforms/esp/32/drivers/i2s_spi/bus_traits.h:48, and the lcd_spi/lcd_cam traits on S3) is the unified engine. Its virtual show() reaches both modes, so registering it for SPI keeps the clockless encoder live. On S3, addLcdSpiIfPossible and addLcdClocklessIfPossible both register FLEX_IO (channel_manager_esp32.cpp.hpp:297,313).

Constraint

Do not split the engine or bus slot. agents/docs/cpp-standards.md:334 ("Parallel-IO Driver: Unified Clockless + SPI Engine", REQUIRED) forbids separate BusTraits/Bus values per mode.

Proposed fix

  1. First confirm which driver the APA102 sketch actually selects on esp32dev and S3. If it is not the FLEX_IO engine, the fix belongs in the automatic driver registration instead: don't register an engine the selector would never pick for this sketch.
  2. If it is the FLEX_IO engine, make the clockless encode path link-on-use. The unified engine calls the clockless encoder and its init through a function pointer, and only the clockless addLeds path (SlimBridgeController construction) installs it. An SPI-only sketch never names the clockless code, so --gc-sections drops it. The engine and Bus slot stay unified.

Acceptance

  • esp32dev and S3 APA102 flash drop about 8–10 KB, with the transposer symbols absent from the map.
  • Clockless and mixed clockless+SPI sketches are unchanged in behavior. bash autoresearch on an S3 and an esp32dev with both modes.
  • ci-full before merge.

Data: https://fastled.github.io/dashboard/ (master 18669e6 vs 3.10.3, fbuild 2.5.38), symbol-level bloat reports linked from each dashboard point.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: driversplatform: esp32priority: hightype: regression

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions