Skip to content

fix: select the real target GPIO backend for parallel software SPI #5062

Closed

Description

@zackees

Context

The shared parallel software-SPI GPIO backend selects ESP32-C3/C2 register addresses for every non-host build. spi_platform.h defaults W1TS to 0x60004008 and W1TC to 0x6000400c without selecting or rejecting other targets. Six independent SpiBlock*::transmit() bodies and the shared ISR engine write through these macros.

Independent inspection of the installed real classic ESP32 SDK gives GPIO_https://github.com/FastLED/FastLED/blob/94dab9c6b720ea277ec9177c93129c7dc646c5c3/ 0x3ff44000, W1TS base+8 and W1TC base+0xc. Its expected addresses are therefore 0x3ff44008/0x3ff4400c, demonstrating an actual target mismatch. No production override definition was found in src. Host simulation selects different functions and cannot expose this defect.

Source:

and
FL_GPIO_WRITE_SET(pins_to_set); /* data-high bits */
. Independently implemented blocking sources: spi_block_1.h, spi_block_2.h, spi_block_4.h, spi_block_8.h, spi_block_16.h, spi_block_32.h in the same directory. Baseline platform blob: e7d604065dc2b942df45cd429c0050e0030202ca.

The classes are public and documented/directly callable. ParallelDevice includes them but its begin/write routes explicitly return not implemented; this issue does not invent an active producer through that wrapper.

Proposal

Select the actual target GPIO backend at the platform boundary using real vendor definitions and supported bank semantics, or reject unsupported targets explicitly. Preserve a documented explicit custom-backend contract. Do not silently use C3/C2 addresses elsewhere.

Acceptance criteria

  • Show focused RED before implementation and GREEN afterward using the actual production macros, all six blocking classes and shared ISR engine where supported.
  • Compile against real representative classic ESP32, C3/C2, Xtensa/RISC-V and a non-ESP target SDK. Assert actual register identity and operation width; supported paths use the correct bank and unsupported paths fail explicitly. Host MMIO simulation alone is insufficient.
  • Preserve exact bits/edges, unrelated GPIO, final/empty/repeated-transfer state and data/clock ownership. Do not claim a throughput improvement without target evidence or physical timing without measurement.
  • Restoring the hardcoded unconditional C3/C2 selection must fail the target-selection signal. Bind selection/header/backend/SDK inputs into test: gate software SPI changes on exhaustive production-path and mutation evidence #5031.

Decisions

Group the common register-selection cause in one child, but require each independent caller and target configuration. This is separate from #5050's BitBangChannelDriver/DigitalMultiWrite8 route and from generic FastPin optimization. Pin-index validation is tracked separately.

Part of #5024.

Activity

  1. added
    sanitized
    on Nov 5, 2026
  2. zackees commented on Nov 7, 2026

    @zackees
    MemberAuthor

    #5145 takes the GPIO registers from each ESP32 target's SDK and rejects other targets on use; it is in the merge queue. This issue stays open for: a real-target selection gate (the current test is structural, and the address checks were one-off probes), on-target byte and edge checks, audit binding for #5031, and pins 32 and above.

  3. zackees commented on Nov 22, 2026

    @zackees
    MemberAuthor

    Fixed on master by #5145 (19e3f38). Closing.

    Evidence (origin/master 2465a62):

    • src/platforms/shared/spi_bitbang/spi_platform.h has no hardcoded addresses. On ESP32 it takes GPIO_OUT_W1TS_REG/GPIO_OUT_W1TC_REG from the target's own soc/gpio_reg.h. Defining only one of FASTLED_GPIO_W1TS_ADDR/FASTLED_GPIO_W1TC_ADDR is an #error; defining both is the explicit custom-backend contract. On every other target FL_SPI_GPIO_AVAILABLE is 0, so all six SpiBlock*::transmit() fail a FL_STATIC_ASSERT and spi_isr_engine.cpp.hpp is not built.
    • Pins above 31 are rejected: setPinMapping() returns false through spiPinMappingValid and leaves the old mapping in place. The host test tests/platforms/shared/spi_bitbang/spi_platform.cpp covers the 32-pin SpiBlock32 case.
    • Revert check: I restored the pre-fix(spi): take parallel soft-SPI GPIO registers from the target SDK #5145 spi_platform.h (the unconditional 0x60004008u/0x6000400Cu defaults) and ran ci/tests/test_spi_platform_gpio_selection.py. Three tests failed: test_no_hardcoded_register_address, test_esp32_takes_addresses_from_the_sdk and test_other_targets_have_no_addresses. With master's header, 5 pass. The host test runs the transmit bodies of all six widths through the production macros under simulation.

    Not done (explicit limitations, like #5061 and #5056):

    Reopen with a target build log or a capture if a real target shows the wrong register.

  4. moved this from Triage to Done in FastLED Trackeron Nov 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

    sanitized

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions