Skip to content

drivers: usb: uhc_dwc2: add bulk transfer support#105287

Draft
roma-jam wants to merge 4 commits intozephyrproject-rtos:mainfrom
roma-jam-lab:pr-add-dwc2-uhc-bulk-type
Draft

drivers: usb: uhc_dwc2: add bulk transfer support#105287
roma-jam wants to merge 4 commits intozephyrproject-rtos:mainfrom
roma-jam-lab:pr-add-dwc2-uhc-bulk-type

Conversation

@roma-jam
Copy link
Copy Markdown
Contributor

@roma-jam roma-jam commented Mar 11, 2026

Collective Pull-request

Contains the incoming features and all the prerequisites.

Work in Progress

Description

N/A

Testing

  1. From the /samples/subsys/usb/shell folder, run
$ west build -b esp32s3_devkitc/esp32s3/procpu -- \
 -DCONFIG_SHELL=y \
 -DCONFIG_USB_HOST_STACK=y \
 -DCONFIG_USBH_SHELL=y \
 -DCONFIG_UDC_DWC2=n 

and get:

... 

Successfully created ESP32-S3 image.

then run:

$ west flash --esp-device /dev/ttyACM0 && west espressif monitor -p /dev/ttyACM0

and the the common usbh shell commands are available:

...

*** Booting Zephyr OS build 18c5216bfc70 ***
uart:~$ usbh init 
host: USB host initialized
uart:~$ usbh enable 
host: USB host enabled
[00:00:04.638,000] <inf> usbh_dev: New device with address 1 state 2
[00:00:04.640,000] <inf> usbh_dev: Configuration 1 bNumInterfaces 3
uart:~$ usbh device list 
1
uart:~$ usbh device bulk 1 0x01 64
host: Bulk transfer finished
[00:00:22.065,000] <wrn> uhc_dwc2: Submit channel type: 2
[00:00:22.065,000] <wrn> uhc_dwc2: BULK OUT
                                   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 |........ ........
                                   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 |........ ........
                                   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 |........ ........
                                   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 |........ ........
[00:00:22.065,000] <inf> usbh_shell: Bulk request finished
uart:~$ 

Changes

Updated

  • drivers/usb/uhc/uhc_dwc2.c - Added BULK transfer type.

Related

@roma-jam roma-jam changed the title [WIP] drivers: usb: uhc: Added BULK transfer type [part6] [WIP] drivers: usb: uhc: dwc2: Added BULK transfer type [part6] Mar 11, 2026
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

This pull request has been marked as stale because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 7 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions Bot added the Stale label Apr 11, 2026
@roma-jam roma-jam changed the title [WIP] drivers: usb: uhc: dwc2: Added BULK transfer type [part6] drivers: usb: uhc: dwc2: Added BULK transfer type [part6] Apr 17, 2026
@github-actions github-actions Bot removed the Stale label Apr 18, 2026
@roma-jam roma-jam force-pushed the pr-add-dwc2-uhc-bulk-type branch from 8ad2afb to 343b640 Compare April 19, 2026 10:31
Josuah Demangeon and others added 4 commits April 20, 2026 15:02
Add 'gsnpsid' and 'ghwcfg3' to DWC2 USB peripheral in order to check
that they are as expected at runtimne, which the host driver can use.

Signed-off-by: Josuah Demangeon <josuah.demangeon@nordicsemi.no>
Note: Control transfers only

Add initial usb host driver for Synopsys DWC2 with vendor quirks.

Signed-off-by: Roman Leonov <jam_roma@yahoo.com>
Add handling for a channel with type Bulk.

Signed-off-by: Roman Leonov <jam_roma@yahoo.com>
@roma-jam roma-jam force-pushed the pr-add-dwc2-uhc-bulk-type branch from 343b640 to c1676d3 Compare April 21, 2026 16:18
@sonarqubecloud
Copy link
Copy Markdown

@roma-jam roma-jam changed the title drivers: usb: uhc: dwc2: Added BULK transfer type [part6] drivers: usb: uhc_dwc2: add bulk transfer support Apr 21, 2026
Comment thread drivers/usb/uhc/uhc_dwc2.c Outdated
Comment on lines +1002 to +1017
/* TODO: Do we need to toggle PID? */
/* TODO: where to keep the toggle flag? How it is done in the other drivers? */
/* PID support to be a part of EP or XFER, not channel */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think with BULK and Buffer DMA mode, the toggling of DATA0/DATA1 PIDs is automatic.

In completer mode, the CPU is involved every packet.

In buffer DMA, the CPU is involved at the beginning and the end.

So the CPU does not have access to the packet-level information, such as the PID (beyon the first one).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Correct.

In buffer DMA, the CPU is involved at the beginning and the end.

But when we prepare the transfer in the begging - we need to understand, do we need to use the same PID on the next transfer with the same EP, or we need to toggle it:
This is why I added the calculation logic:

/* If amount of packets are even - do not toggle */
	if ((pkt_cnt & 0x01U) == 0U) {

There are two common possible ways:

  • fetch the PID in the end of transfer (CPLT) and count the next_pid based on this value, keep the next_pid someplace for the next transfer
  • calculate next_pid before schedule the transfer and keep it till the next transfer. But in this case we do not need to toggle it, if the result was NACK.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see the problem now. It is not about toggling the PID every time, but detecting the current toggling state after feeding more buffers to an ongoing transfer.

Thank you for clarifying.

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.

2 participants