Skip to content

fix(esp32): link forced software pins in SoftwareSPIOutput; add fastPinLoopback (#5067) - #5391

Merged
zackees merged 1 commit into
masterfrom
test/5067-esp32-forced-fastpin
Nov 22, 2026
Merged

zackees merged 1 commit into
masterfrom
test/5067-esp32-forced-fastpin

Conversation

@zackees

@zackees zackees commented Nov 22, 2026

Copy link
Copy Markdown
Member

Part of #5067.

What was still broken

#5241 (fadc722) made ESP32's explicit FastPin<N> specializations derive from NoPinMapPin when FASTLED_FORCE_SOFTWARE_PINS is defined. That part works. The SDK builds below confirm it. But the forced route still had no BitbangPin<FastPin<PIN>> specialization. It fell back to BitbangPinDefaults::delay(), which calls fl::delaycycles<N>(), and that template is only defined out of line for N <= 50. So the public SoftwareSPIOutput could not link on a forced ESP32 at practical rates.

RED (esp32c6, real SDK link, forced, SoftwareSPIOutput<2, 3, DATA_RATE_KHZ(250)>):

32 undefined reference to `void fl::delaycycles<314ll>()'
32 undefined reference to `void fl::delaycycles<317ll>()'

Fix

src/platforms/esp/32/core/fastpin_esp32.h moves the existing inline cycle-counter delay() into Esp32BitbangDelay. The native policy (atomic W1TS/W1TC write) and the new forced policy (writes go through the core pin API) both inherit it. The FL_ESP32_ENABLE_FAST_SOFTWARE_SPI=0 legacy branch is unchanged.

GREEN: the same producer links. GenericSoftwareSPIOutput<2,3,640>::writeByte makes 16 calls to NoPinMapPin<2> and 16 to NoPinMapPin<3>, and its delays use csrr 0x7e2 (the cycle counter). It has no 0x60091 references.

On-device harness

examples/AutoResearch/AutoResearchFastPinLoopback.h adds the fastPinLoopback RPC (ESP32 only). It uses the board-discovered jumper (findConnectedPins) and reports:

  • whether FastPin<TX> is the NoPinMapPin fallback
  • levels and toggle order
  • clock LOW after init()
  • 8 MSB-first bytes with TX as SoftwareSPIOutput data, decoded from RX edges
  • 64 rising edges with TX as the clock, ending with the clock idle LOW

ESP32-C6 on /dev/ttyACM1. Discovered jumper TX=GPIO0 to RX=GPIO1. Spare pins are the default SPI pins 18/19.

build softwareRoute hardwarePinSupport levelMismatches dataDecoded clockRisingEdges bit period success
--define FASTLED_FORCE_SOFTWARE_PINS true false 0 A5 3C 81 5A F0 0F 96 69 64 6485 ns true
native (no define) false true 0 A5 3C 81 5A F0 0F 96 69 64 4653 ns true

Validation

  • uv run pytest ci/tests/test_esp32_forced_software_pins.py: the new contract fails without the header change and passes with it.
  • bash lint is green.
  • /code-review low found no issues.

…inLoopback (#5067)

With FASTLED_FORCE_SOFTWARE_PINS on ESP32, the FastPin specializations now
derive from NoPinMapPin (since #5241), but BitbangPin<FastPin<PIN>> fell back
to BitbangPinDefaults, whose delay() calls fl::delaycycles<N>. That template
is only defined out of line for N <= 50, so SoftwareSPIOutput at practical
rates failed to link (esp32c6, DATA_RATE_KHZ(250): undefined
fl::delaycycles<314>/<317>). Share the inline cycle-counter delay between the
native and forced policies; only the native one keeps the atomic MMIO write.

AutoResearch gains fastPinLoopback: over the board-discovered jumper it checks
FastPin levels and toggle order, clock LOW after init, eight MSB-first bytes
with TX as SoftwareSPIOutput data, and 64 clock edges with TX as clock. It
reports whether the selected route is the NoPinMapPin fallback.
@coderabbitai

coderabbitai Bot commented Nov 22, 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 8 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 1432fae and c123e93.

Files selected for processing: 5

  • ci/tests/test_esp32_forced_software_pins.py
  • examples/AutoResearch/AutoResearchFastPinLoopback.h
  • examples/AutoResearch/AutoResearchRemoteDriverMethods.cpp
  • examples/AutoResearch/AutoResearchRemotePinMethods.cpp
  • src/platforms/esp/32/core/fastpin_esp32.h

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

Parsing warnings: 1

Validation error: Unrecognized key: "enabled" at "reviews.pre_merge_checks"
Configuration instructions

  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
  • 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 22, 2026
@github-actions github-actions Bot added the sanitized Title, body and conversation screened; review text requires separate screening. label Nov 22, 2026
@zackees
zackees added this pull request to the merge queue Nov 22, 2026
@github-actions

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 288,007 (Same) 18,747 (Same)
esp32s3 320,463 (Same) 22,499 (Same)

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.

1 participant