tinyusb icon indicating copy to clipboard operation
tinyusb copied to clipboard

Add Host support for ch32v20x usbfs

Open verylowfreq opened this issue 1 year ago • 11 comments

This PR adds HCD for WCH CH32V20x USBFS (USBOTG_FS).

The following issue will be closed:

  • https://github.com/hathach/tinyusb/issues/2613

CH32V20x has two USB peripheral; FSDEV and USBFS. In this PR, USBFS Host driver is enabled when PORT=0 (FSDEV is selected).

I tested on my original CH32V203C8T6 board "Suzuno32RV" (8MHz external crystal, Type-A connector is assigned for USBFS, Type-C connector is for FSDEV). Please refer for schematic: https://github.com/verylowfreq/board_suzuno32rv

verylowfreq avatar Sep 09 '24 09:09 verylowfreq

Thank you for your PR, can you pull/merge from master, which include a fix to circleci build.

hathach avatar Sep 10 '24 14:09 hathach

@hathach Thanks for reply. It seems that my branch is already up-to-date and I couldn't merge more commits. How can I do pull/merge? My "pr-ch32v-usbfs-host" branch's commits: image

verylowfreq avatar Sep 10 '24 15:09 verylowfreq

sorry, my bad, previous master isn't fix that yet. I have fixed merged and also fixed the pre-commit format as well. It is all good now.

hathach avatar Sep 11 '24 12:09 hathach

Thank you. I found that the CI failed at macro related problem ("Build / cmake (riscv-gcc)"), so I added commits to solve it.

verylowfreq avatar Sep 11 '24 14:09 verylowfreq

thank you, I am current working on other stuffs, please give me a bit of time to review this.

hathach avatar Sep 16 '24 03:09 hathach

@hathach Thank you for sharing your status! I'm preparing to release my Suzuno32RV MCU board, which I used for testing, and I'm also working on porting Adafruit_TinyUSB_Arduino.

My fork of Adafruit_TinyUSB_Arduino: (Currently, copying ch32v20x_usb.h to arduino_core_ch32 folder is needed to build.) https://github.com/verylowfreq/Adafruit_TinyUSB_Arduino

verylowfreq avatar Sep 17 '24 07:09 verylowfreq

Any chance we could get this reviewed and merged in?

mikeemoo avatar Feb 21 '25 10:02 mikeemoo

this is always on my radar but still haven't manage time to review this.

hathach avatar Feb 22 '25 09:02 hathach

Merged the latest changes in master branch.

Current problems (and I need help):

  • The communication to LowSpeed device via external HUB sometimes fails. (ex: cannot get the device descriptor, tuh_mount_cb() not called)
    • Plugging to the Root Port doesn't cause the problem with same device.
    • In my test, USB keyboards are often causing this problem.
  • Plugging the external HUB sometimes causes the resetting MCU.

verylowfreq avatar Mar 16 '25 02:03 verylowfreq

Thank you for the update and patient, sorry, I am stil busy with other works. Will check this out as soon as I could.

hathach avatar Mar 16 '25 04:03 hathach

@verylowfreq I'm glad you're working on this! If you need someone for tests, hit me up, I have a nanoCH32V203 which I can do tests with.

braxlan avatar Mar 16 '25 20:03 braxlan

I just wanted to bump this because there are already two people working on host support, see also #3094.

braxlan avatar Jul 03 '25 12:07 braxlan