-
Notifications
You must be signed in to change notification settings - Fork 8.4k
drivers: uhc_dwc2: Initial support [WIP] #94266
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
base: main
Are you sure you want to change the base?
drivers: uhc_dwc2: Initial support [WIP] #94266
Conversation
|
Hello @roma-jam, and thank you very much for your first pull request to the Zephyr project! |
9053da6 to
ecce802
Compare
|
For anyone trying this, here is what I did to get it built:
Then modify the build script to include one extra directory (espressif-specific): diff --git a/zephyr/esp32s3/CMakeLists.txt b/zephyr/esp32s3/CMakeLists.txt
index aedf412601..6a5546da9e 100644
--- a/zephyr/esp32s3/CMakeLists.txt
+++ b/zephyr/esp32s3/CMakeLists.txt
@@ -221,7 +221,7 @@ if(CONFIG_SOC_SERIES_ESP32S3)
)
endif()
- if (CONFIG_UDC_DWC2)
+ if (CONFIG_UDC_DWC2 OR CONFIG_UHC_DWC2)
zephyr_include_directories(
../../components/usb/include
)Then to build it, disable the device stack (or build error occurs insofar): |
|
@roma-jam thank you very much for this effort! Maybe you saw this incomplete branch from Espressif? raffarost@54dcf56 I could run the firmware but not yet test it I am still waiting an ESP32-S3 devkit (with 2 discrete USB interface to make sure there is no bug related to switching between the "jtag/serial and "usb-otg" interface on the same port) in the mail. In the other hand, I will also try to get it working on a Nordic devkit that also has DWC2, and it seems like some STM32 part also has it. Glad to see you preserved all the vendor-quirks system to keep all vendor-specific on separate files. I will post here as I am able to get more progress, and start doing early review as well. |
|
Hi @josuah, yes, I saw that and many thanks to @raffarost, I took couple of things from his work. Besides that, I decided to proceed with simple implementation for all controllers with dwc2 (I hope, at least I tried to predict as much as I could) with Buffer DMA config (as currently in TinyUSB host) and with similar logic of event handling (ports, pipes and channels) , as in esp-idf USB Host stack. Buffer DMA (not Scatter-Gahter) because it supports split-transactions, and I believe we want to have fully-working external hubs with HS root ports. Thanks for you support and just in case - this is still a draft and I pushed it because the first step positive scenario (like device enumeration is done) is copmleted. But there are still a lot of parts are missing. |
7f09880 to
e433713
Compare
|
@roma-jam I received my ESP32-S3 DevkitC-1 to test this. So far I used an OTG adapter on the "USB" interface and connected it to various devices but after No problem, I can investigate this, but just in case there was something obvious I missed, what is your physical setup? Build command used with your latest commits from 40 minutes ago: I suppose the warning message means it needs an USB HighSpeed device (USB MSC dongle) instead of FullSpeed? Or maybe a LowSpeed only (keyboard/mouse)? I will try to support for DWC2 OTG on an nRF54LM20 DK, so different hardware anyway, but I was interested in testing the same way as you, to check that things still work on the ESP32 after introducing more code for the nRF54LM20. I have the access to DWC2 docs and can join the effort with writing the driver as soon as I am done with the low levels (enable the core, PHY setup...). Thanks! |
|
Hi @josuah, Sorry for this. Yes, there is no 5V on the USB OTG port connector, so this dev kit is for the usb device, not the host. But! You can use the usb wire, attached to the pins or bypass the D7 to provide 5V to the port. Please, refer to the schematic: https://dl.espressif.com/dl/schematics/SCH_ESP32-S3-DevKitC-1_V1.1_20221130.pdf UPD:
No, the warning message just shows that the supported PHY is FS and there is no config for this so far. On esp this config is by default after the power on, so it will work without it. But I will add it soon. Thanks. |
|
That makes sense thank you for the hint I thought I missed something obvious. |
425c8d6 to
c4ff7f3
Compare
798801b to
bea0307
Compare
c57de0b to
846abca
Compare
f26fd50 to
426ed18
Compare
|
|
Hello again @roma-jam, I could adapt this PR to be working on nRF54LM20 by only modifying the vendor quirks.= There seem to be a bit of coding style work needed, and maybe a few TODOs to cover. Should I keep going with the refactoring and coding style change to merge this then? I will start in Thanks! |
|
Hi @josuah, thanks for the feedback!
this seems like a good news, isn't it? I wasn't able to get back to this task in the last few months, but my plan is still the same:
Could you please specify, what do you want to cover in the priority order? So I can solve them one by one in the meantime. |
I think it is :)
This turned out convenient to have some PR stability during this time.
Maybe these could eventually be added over time, as new devices need to insert something at a new location
I was thinking static arrays could be used to avoid
What I needed to do:
What I wished to do is to:
I thought it'd be safer to do "big changes" with both hardware at hand to test it after every step (or what if I answer you "it does not work anymore", several days to find 1 typo >_<).
I think enabling, testing HighSpeed support, disabling HNP (should we rely on Type-C only for role swapping?)... What to do next? :) |
|
This was an un-initialized mutex in
|
|
If asking to make one change, waiting the answer, then test things locally on the devkit, it will take ages. Let's try to make modifications, and announce them, so that it's possible to give feedback, and potentially I revert some changes if I am mistaken or better options exist etc. Once things are in shape, it becomes easier to pursue with actual feature development on top on both our side, this becomes normal PRs... |
josuah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First few modifications I am doing on my fork...
|
Hi @josuah, thanks a lot for looking through my code and for such a usefull feedback! I can‘t guarantee that I will fix everything in the next couple weeks, as I am in the middle of the other task. So, I will definetely return back to this PR and I hope to make it sooner. |
|
To avoid ambiguity: I am only announcing the asethetical code changes I'm doing now, and report what I've changed (to keep this a discussion and not impose anything). Then I will propose you a replacement PR that we can both use as a root. Hopefully this removes you the paperwork, while give an example to use to implement the actual features! :) |
Update the HAL to latest main version for support of USB Host Controller uhc_dwc2.c, needed for the vendor quirsk. Signed-off-by: Josuah Demangeon <[email protected]>
Add board support files needed to test the ESP32-S3 devkit with host support, as well as host_prj.conf used to test the USB shell with host support exclusively. Example build command: west build -b esp32s3_devkitm/esp32s3/procpu samples/subsys/usb/shell/ \ -DEXTRA_CONF_FILE=host_prj.conf -DCONFIG_USB_DEVICE_STACK_NEXT=n Signed-off-by: Roman Leonov <[email protected]>
Added register bitmask description with low-level abstraction Signed-off-by: Roman Leonov <[email protected]>
Introduce an USB host driver for Synopsys Designware USB OTG controller (DWC2) with vendor quirks for nRF54LM20 and ESP32-S3, using the nRF54LM20-DK and ESP32-S3 DevitC. Both need VBUS supplied with an external +5V to power the USB device. The driver currently only support control commands on the control endpoint which is enough for the enumeration process. Signed-off-by: Roman Leonov <[email protected]> Co-authored-by: Josuah Demangeon <[email protected]>
ac4b63c to
f930771
Compare
|
The following west manifest projects have changed revision in this Pull Request:
✅ All manifest checks OK Note: This message is automatically posted and updated by the Manifest GitHub Action. |
|





Description
Adding USB host driver initial support for DWC2 controller.
Features and Limitations
Commits by their order
hal_espressifhost_prj.confoverlay forsample/subsys/usb/shellusb_dwc2_hw.huhc_dwc2.*files with vendor quirks and Kconfig forUHC_DWC2Testing
After running the shell sample and initial driver enabling with commands
usbh initandusbh enable: