Skip to content

[Host] CH32 USBFS: Resolve enumeration failure and improve stability#3600

Open
verylowfreq wants to merge 3 commits into
hathach:masterfrom
verylowfreq:pr-ch32v-usbfs-host
Open

[Host] CH32 USBFS: Resolve enumeration failure and improve stability#3600
verylowfreq wants to merge 3 commits into
hathach:masterfrom
verylowfreq:pr-ch32v-usbfs-host

Conversation

@verylowfreq
Copy link
Copy Markdown
Contributor

This PR updates src/portable/wch/hcd_ch32_usbfs.c to improve:

  1. Lack of retry logic for NAK response
  2. Device enumeration failures on some devices
  3. Unstable plug/unplug behavior via USB hub
  4. Low Speed devices couldn't be enumerated in some cases.

After the commit 13e0b0c, some USB device couldn't be enumerated at CH32 USBFS Host.

  • Adjusted retry logic for enumeration failures and interrupt transfer stalls
  • Added per-SOF retry limiting and cooldown to prevent retry storms
  • Added protection paths for IRQ stale/mismatch edge cases
  • Added special logic for Low Speed devices and Dev0 enumeration.

Validated on real hardware with examples/host/cdc_msc_hid, USB Thumbstick, USB-CDC dongle, USB Keyboard and the CH32V203 MCU board "Suzuno32RV" (which I developed and sold by Japanese manufacture BitTradeOne).

@github-actions
Copy link
Copy Markdown

MemBrowse Memory Report

Top 8 targets by memory change (%) (out of 2161 targets) View Project Dashboard →

target .text .rodata .data .bss total % diff
ch32v203c_r0_1v0/device_info 18,920 → 21,004 (+2,084) 2,284 → 2,780 (+496) 23,704 → 26,284 (+2,580) +10.9%
ch32v203c_r0_1v0/bare_api 19,816 → 21,896 (+2,080) 2,908 → 3,404 (+496) 25,216 → 27,792 (+2,576) +10.2%
ch32v203c_r0_1v0/hid_controller 18,236 → 20,336 (+2,100) 1,624 → 1,760 (+136) 22,328 → 24,564 (+2,236) +10.0%
ch32v203c_r0_1v0/midi_rx 20,388 → 22,480 (+2,092) 3,196 → 3,692 (+496) 26,084 → 28,672 (+2,588) +9.9%
ch32v203c_r0_1v0/host_info_to_device_cdc 31,176 → 33,236 (+2,060) 3,068 → 3,564 (+496) 36,788 → 39,344 (+2,556) +6.9%
ch32v203c_r0_1v0/host_hid_to_device_cdc 31,220 → 33,348 (+2,128) 4,488 → 4,984 (+496) 38,252 → 40,876 (+2,624) +6.9%
ch32v203c_r0_1v0/cdc_msc_hid 32,080 → 34,168 (+2,088) 5,164 → 5,660 (+496) 39,752 → 42,336 (+2,584) +6.5%
ch32v203c_r0_1v0/msc_file_explorer 39,944 → 42,036 (+2,092) 10,856 → 11,352 (+496) 53,292 → 55,880 (+2,588) +4.9%

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.

1 participant