Skip to content

Do not flush the wrong fifo#5552

Merged
Dirbaio merged 1 commit intoembassy-rs:mainfrom
bugadani:flush-ep
Mar 2, 2026
Merged

Do not flush the wrong fifo#5552
Dirbaio merged 1 commit intoembassy-rs:mainfrom
bugadani:flush-ep

Conversation

@bugadani
Copy link
Copy Markdown
Contributor

@bugadani bugadani commented Mar 1, 2026

When disabling an OUT endpoint, the previous implementation flushed a TX FIFO, but TX FIFOs are assigned to IN endpoints.

I think this closes (maybe not, though?) #5521 as the PR fixes an identical-looking issue on the ESP32-S3, and the F405 uses a different version of the same IP.

Copilot AI review requested due to automatic review settings March 1, 2026 15:29
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug in embassy-usb-synopsys-otg where disabling an OUT endpoint incorrectly triggered a TX FIFO flush — a TX FIFO operation that only makes sense for IN endpoints. The fix moves the TX FIFO flush logic from the Direction::Out branch to the Direction::In branch of endpoint_set_enabled, where it belongs, since TX FIFOs are allocated per-IN-endpoint on this hardware. This resolves a likely root cause for USB CDC NCM connectivity issues on STM32F405 (and similar Synopsys OTG-based chips).

Changes:

  • Removes the TX FIFO flush from the OUT endpoint disable path
  • Adds the TX FIFO flush (with wait loop) to the IN endpoint disable/enable path
  • Documents the fix in the CHANGELOG

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
embassy-usb-synopsys-otg/src/lib.rs Moves TX FIFO flush from Direction::Out to Direction::In branch in endpoint_set_enabled
embassy-usb-synopsys-otg/CHANGELOG.md Adds changelog entry for the bug fix under the Unreleased section

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kaspar030
Copy link
Copy Markdown
Contributor

I confirm this fixes our issue on Linux where the esp32-s3 usb ethernet would not properly come up. With this fix, it works like a charm.

@Dirbaio Dirbaio added this pull request to the merge queue Mar 2, 2026
Merged via the queue into embassy-rs:main with commit c3631bc Mar 2, 2026
11 of 12 checks passed
@bugadani bugadani deleted the flush-ep branch March 2, 2026 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants