tinyusb icon indicating copy to clipboard operation
tinyusb copied to clipboard

Support for CH32 USBFS host mode

Open joelpmichael opened this issue 8 months ago • 3 comments

Related area

New port support

Hardware specification

CH32 variant with USBFS, eg CH32V203C8T6 as used on the currently supported board ch32v203c_r0_1v0

Is your feature request related to a problem?

CH32 supports USB Host mode in the USBFS peripheral, but TinyUSB does not support it (yet)

Describe the solution you'd like

I have started writing support for the CH32 USBFS host mode, and it's now at the point where the USB host will enumerate some devices using the host/device_info example. It seems to enumerate another TinyUSB device using device/cdc_msc, displaying device strings as expected.

There are still timing-related issues in the driver, which is causing enumeration to fail on many devices. I also suspect I have issues with data0/data1 toggling as some devices are reporting STALL during enumeration. The code is available at https://github.com/joelpmichael/tinyusb/tree/ch32-usbfs-host but is definitely not ready for a PR yet. Once I can get it reliably enumerating a bunch of different devices I have (eg keyboard, mouse, mass storage, CDC-ACM, UARTs) I will send the PR through. If anyone wishes to check out the code and join the development, I will happily accept patches because I'm rapidly approaching the limit of my USB knowledge.

I have checked existing issues, dicussion and documentation

  • [x] I confirm I have checked existing issues, dicussion and documentation.

joelpmichael avatar Apr 23 '25 12:04 joelpmichael

Have you seen PR 2793? Chances are high you've missed it because it is neither an issue, a discussion or part of the documentation.

braxlan avatar Apr 23 '25 12:04 braxlan

I have not seen this one, thank you! I guess keep this bug open until it's merged, so it's a bit more visible that this support exists in the wild?

joelpmichael avatar Apr 23 '25 23:04 joelpmichael

That sounds like a good idea! I would love to see more people getting involved with the CH32 family because of its unique feature of having two USB ports which makes it ideal for dual-role projects.

braxlan avatar Apr 24 '25 12:04 braxlan

implemented byy https://github.com/hathach/tinyusb/pull/2793

hathach avatar Jul 05 '25 05:07 hathach