Skip to content

fix(parlio): keep data pins driven while the TX unit is re-created (#4669) - #4677

Merged
zackees merged 1 commit into
masterfrom
fix/parlio-p4-data-pin-float-4669
Oct 3, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/parlio-p4-data-pin-float-4669

Conversation

@zackees

@zackees zackees commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Fixes the PARLIO half of #4669 (class=zero_capture on ESP32-P4).

Root cause

ChannelDriverPARLIO::beginTransmission() calls ParlioEngine::initialize() every frame. When the config matches, the engine deletes and recreates the TX unit on purpose ("Reinitializing TX unit for clean DMA state"). That re-create is load-bearing: it routes the pad back to PARLIO after another driver (for example RMT) has borrowed it. Skipping it made PARLIO fail as soon as RMT had run on the same pin.

parlio_del_tx_unit() (IDF v5.5 parlio_tx.c) calls gpio_output_disable() on every data pin, then tears the unit down in parlio_destroy_tx_unit(). So every frame began with the data line floating for that teardown time.

Bench evidence (P4, GPIO5→GPIO6 jumper):

  • A core-0 spin sampler on the RX pad showed the line HIGH from 4345 µs to 4694 µs (349 µs), entirely inside deinitialize(). The RX pad has a pull-up from the GPIO pre-test.
  • RMT RX recorded exactly 1 symbol, 0x8000: a rising edge, then more than its 100 µs idle threshold of HIGH, so it ended before the frame began. SPI on the same RX recorded 2400 symbols.
  • The only pad-register difference between failing runs and runs that "passed" with the active edge probe was pull-up vs pull-down on GPIO6 (0x1B02 vs 0x1A82).
  • With the TX-unit re-create skipped as an experiment, PARLIO passed.

On a real strip, DIN floats for the same window on every frame.

Fix

In ParlioPeripheralESPImpl, latch each data pad with gpio_hold_en() across parlio_del_tx_unit(), re-drive it low as a plain GPIO (the idle level every transmit uses), then gpio_hold_dis(). parlio_new_tx_unit() re-routes the pad to PARLIO. If the delete fails, the hold is still released.

Evidence (ESP32-P4, 80:F1:B2:D1:DF:B1, fbuild 2.5.31)

Before (master):

TEST PARLIO lanes=1 leds=100 FAIL 1083ms class=zero_capture

After (this branch):

TEST PARLIO lanes=1 leds=100 PASS 1072ms

Stress run over RPC, interleaving drivers on the same TX pin. All passed:

PARLIO [100] 4/4, PARLIO [300] 4/4, PARLIO [10] 12/12, RMT [100] 4/4, PARLIO [100] 4/4,
SPI [100] 4/4, PARLIO [300] 8/8, UART [100] 4/4, PARLIO [100] 4/4

--all with this PR plus the LCD_RGB fix (#4669 companion PR), on current master:

--all: skipping drivers this firmware does not register: LCD_CLOCKLESS, LCD_SPI, OBJECT_FLED, FLEX_IO
TEST PARLIO  lanes=1 leds=100 PASS 1073ms
TEST RMT     lanes=1 leds=100 PASS 1055ms
TEST SPI     lanes=1 leds=100 PASS 2057ms
TEST UART    lanes=1 leds=100 PASS 1031ms
TEST LCD_RGB lanes=1 leds=100 PASS 1057ms
AUTORESEARCH SUCCEEDED

Notes

  • There is no host test. The behavior is pad-level and IDF-only, and the PARLIO mock does not model pads. The P4 bench run is the RED/GREEN evidence.
  • ESP32-C6 was not re-run: that bench board was in use by another session. The change only adds a hold/re-drive around the existing delete, using public driver/gpio.h APIs available on all PARLIO targets.
  • bash lint passes, bash test parlio passes, and /code-review found no issues on this change.

Summary by CodeRabbit

  • Bug Fixes
    • Improved ESP32 PARLIO shutdown behavior: after a successful shutdown, configured data pins are left as low-level outputs, helping prevent unexpected pin states.
    • If shutdown fails, the existing transmission-unit state is retained rather than treated as successfully cleared.

…4669)

The engine deletes and recreates the PARLIO TX unit on every frame (that
is what routes a pad another driver borrowed back to PARLIO).
parlio_del_tx_unit() calls gpio_output_disable() on each data pin before
tearing the unit down, which takes ~350 us on an ESP32-P4, so every frame
began with the data line floating. On the P4 loopback bench (RX pad pulled
up) RMT RX saw a rising edge, >100 us of HIGH, hit its idle threshold and
ended before the frame: PARLIO looked like it emitted nothing
(class=zero_capture). A real strip's DIN floated for the same window.

Latch each data pad with gpio_hold_en() across the delete, re-drive it low
as a plain GPIO, then release the hold. parlio_new_tx_unit() re-routes it.
@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
.cursorrules — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: FastLED/FastLED/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 02ca4c7d-205e-4711-aeb9-e1420feac996
📥 Commits

Reviewing files that changed from the base of the PR and between 221626d and d5de5c9.

📒 Files selected for processing (1)
  • src/platforms/esp/32/drivers/parlio/parlio_peripheral_esp.cpp.hpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

The ESP32 PARLIO implementation now tracks configured data pins. During TX-unit deletion, it holds the pins and, on success, drives them low and configures them as GPIO outputs. On failure, it releases the holds and retains the pin tracking.

Changes

PARLIO pin cleanup

Layer / File(s) Summary
Pin tracking and TX-unit deletion
src/platforms/esp/32/drivers/parlio/parlio_peripheral_esp.cpp.hpp
The implementation tracks configured data pins and initializes unused entries to -1. Deletion holds the tracked pins. On success, it drives them low, configures them as GPIO outputs, and clears the handle and tracking. On failure, it releases the holds and retains the handle and tracking. The destructor uses the helper and clears the handle if deletion fails.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Cleanup as deleteTxUnitKeepingPins
  participant GPIO
  participant PARLIO as PARLIO TX unit
  Cleanup->>GPIO: Hold tracked pins
  Cleanup->>PARLIO: Delete TX unit
  alt Deletion succeeds
    Cleanup->>GPIO: Drive pins low and configure GPIO outputs
    Cleanup->>GPIO: Release holds
    Cleanup->>Cleanup: Clear TX-unit handle and pin tracking
  else Deletion fails
    Cleanup->>GPIO: Release holds
    Cleanup->>Cleanup: Retain pin tracking
  end
Loading

Merge Risk: 🔵 Low · up to d5de5

This change keeps PARLIO data lines driven low while the TX unit is re-created, and the author reports it fixed the failing ESP32-P4 bench test. A small risk remains on boards where another driver shares a PARLIO pad, and the ESP32-C6 was not re-tested. It is mergeable with owner awareness of both points.

Security Architecture Review

Security architecture risk: 🔵 Low · up to d5de5

The change preserves output-pin state during cleanup without adding a public interface. Risk appears limited, but concurrent pin reuse and hardware failure recovery are not fully established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — The changed helper directly controls at most 16 tracked pads selected by the existing peripheral configuration. It adds no parameter granting authority over additional pins; actual connected assets and application-level exposure are not established by these sources.

Trust Boundaries and Controls

  • inferred — The reviewed changes remain behind existing driver lifecycle calls rather than introducing an attacker-facing entrypoint. Pin tracking identifies the former PARLIO configuration, not a current cross-driver owner, so it does not establish exclusive authority during overlapping driver use.

Resilience and Maintainability Implications

  • observed — The engine checks its transmission flag, requests queue draining before transmission, and waits for final completion before normal disable. These are local sequencing controls, not proof of cross-driver arbitration. The new helper also ignores GPIO-operation return values, so successful hold and output restoration depend on platform behavior.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: keeping PARLIO data pins driven while the TX unit is recreated.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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

Comment @coderabbitai help to get the list of available commands.

@zackees

zackees commented Oct 2, 2026

Copy link
Copy Markdown
Member Author

Cross-checked on an ESP32-C6, which shares the PARLIO peripheral code. This branch with bash autoresearch esp32c6 --all: PARLIO 130 ms, RMT, SPI and UART all PASS, AUTORESEARCH SUCCEEDED. No regression.

@zackees
zackees merged commit b551ca9 into master Oct 3, 2026
120 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Oct 3, 2026
@zackees
zackees deleted the fix/parlio-p4-data-pin-float-4669 branch November 5, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant