Skip to content

Add Host support for ch32v20x usbfs #2793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jul 5, 2025

Conversation

verylowfreq
Copy link
Contributor

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

The following issue will be closed:

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

@hathach
Copy link
Owner

hathach commented Sep 10, 2024

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

@verylowfreq
Copy link
Contributor Author

@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

@hathach
Copy link
Owner

hathach commented Sep 11, 2024

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.

@verylowfreq
Copy link
Contributor Author

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

@hathach
Copy link
Owner

hathach commented Sep 16, 2024

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

@verylowfreq
Copy link
Contributor Author

@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

@mikeemoo
Copy link

Any chance we could get this reviewed and merged in?

@hathach
Copy link
Owner

hathach commented Feb 22, 2025

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

@verylowfreq verylowfreq force-pushed the pr-ch32v-usbfs-host branch from dc52890 to cd2b3a5 Compare March 16, 2025 01:38
@verylowfreq
Copy link
Contributor Author

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.

@hathach
Copy link
Owner

hathach commented Mar 16, 2025

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

@braxlan
Copy link

braxlan commented Mar 16, 2025

@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 braxlan mentioned this pull request Apr 23, 2025
1 task
@braxlan
Copy link

braxlan commented Jul 3, 2025

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

@hathach hathach force-pushed the pr-ch32v-usbfs-host branch from 9c5d4da to 4b95a70 Compare July 5, 2025 04:51
Copy link
Owner

@hathach hathach left a comment

Choose a reason for hiding this comment

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

perfect, thank @verylowfreq very much for this great PR. Sorry for the delay, I have tested with simple host/device_info and dual/host_info_to_device_cdc and it can enumerate device just well. haven't done more in-depth testing. Any issues can be resolved as follow-up PR later.

I have made some changes

  • always add CFG_TUH_WCH_USBIP_USBFS=1 by default for ch32v20x since that is the only port that support host mode. Manual setting it isn't required.

PS: CI failed due to hw connection issue in the hil pool. I will just ignore this for now.

@hathach hathach merged commit b012e95 into hathach:master Jul 5, 2025
104 of 106 checks passed
@hathach hathach mentioned this pull request Jul 5, 2025
1 task
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