dcd/stm32_fsdev: workaround CH32 EP0 premature OUT ACK#3648
Open
HiFiPhile wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a CH32-specific workaround in the STM32 FSDEV DCD to prevent EP0 from prematurely ACKing OUT packets during control transfers by tracking EP0 control direction/length and dynamically toggling EP0’s configured type (CONTROL ↔ BULK) to gate handshakes.
Changes:
- Track EP0 control transfer direction and whether a data stage is expected (based on SETUP + wLength) for CH32 targets.
- Add an EP0 helper to switch endpoint type and apply it during control read/write “gaps” to block unsolicited OUT ACKs.
- Remove the post-status-stage
edpt0_prepare_setup()call fromdcd_edpt0_status_complete().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Size Difference ReportBecause TinyUSB code size varies by port and configuration, the metrics below represent the averaged totals across all example builds. Note: If there is no change, only one value is shown. Changes >1% in sizeNo entries. Changes <1% in size
No changes
|
Track EP0 control transfer state from SETUP (direction and wLength) and gate CH32 EP0 handshakes accordingly. Switch EP0 type away from control to bulk to block unsolicited OUT ACKs during control read/write gaps, then restore control type when EP0 transfer is explicitly armed. Signed-off-by: HiFiPhile <admin@hifiphile.com>
1 task
|
| target | .text | .rodata | .data | .bss | total | % diff |
|---|---|---|---|---|---|---|
| ch32v203c_r0_1v0/hid_generic_inout | 11,548 → 11,792 (+244) | — | — | 932 → 936 (+4) | 11,852 → 12,096 (+244) | +2.1% |
| ch32v203c_r0_1v0/hid_composite | 12,616 → 12,864 (+248) | — | — | 796 → 800 (+4) | 12,920 → 13,168 (+248) | +1.9% |
| ch32v203c_r0_1v0/dfu_runtime | 10,376 → 10,620 (+244) | — | — | 728 → 732 (+4) | 13,504 → 13,756 (+252) | +1.9% |
| ch32v203c_r0_1v0/audio_test | 14,036 → 14,288 (+252) | — | — | 1,308 → 1,312 (+4) | 14,356 → 14,608 (+252) | +1.8% |
| ch32v203c_r0_1v0/audio_test_multi_rate | 14,332 → 14,580 (+248) | — | — | 2,664 → 2,668 (+4) | 14,656 → 14,904 (+248) | +1.7% |
| ch32v203c_r0_1v0/webusb_serial | 14,396 → 14,644 (+248) | — | — | 1,100 → 1,104 (+4) | 14,748 → 14,996 (+248) | +1.7% |
| ch32v203c_r0_1v0/usbtmc | 14,788 → 15,036 (+248) | — | — | 1,124 → 1,128 (+4) | 15,212 → 15,460 (+248) | +1.6% |
| ch32v203c_r0_1v0/hid_multiple_interface | 12,348 → 12,592 (+244) | — | — | 808 → 812 (+4) | 15,556 → 15,808 (+252) | +1.6% |
| ch32v203c_r0_1v0/hid_boot_interface | 12,372 → 12,616 (+244) | — | — | 808 → 812 (+4) | 15,580 → 15,832 (+252) | +1.6% |
| ch32v203c_r0_1v0/midi_test | 12,828 → 13,072 (+244) | — | — | 928 → 932 (+4) | 16,156 → 16,408 (+252) | +1.6% |
Devin-goBILDA
added a commit
to Devin-goBILDA/CH32V203-TinyUSB-DFU-Issue
that referenced
this pull request
May 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CH32 EP0 blindly ACK all OUT packets, even not only ZLP.
Track EP0 control transfer state from SETUP (direction and wLength) and gate CH32 EP0 handshakes accordingly. Switch EP0 type away from control to bulk to block unsolicited OUT ACKs during control read/write gaps, then restore control type when EP0 transfer is explicitly armed.
Mainly fix DFU issue.