Possible USB peripheral issue on Rock 5B+ (missing DISCONNECT event)?

On the Rock 5B+ (and possibly other Radxa SBCs as well), when using the appropriate USB port in peripheral mode with the Mass Storage Gadget function, the dwc3_gadget_interrupt function in the kernel’s DWC3 gadget driver does not receive a DWC3_DEVICE_EVENT_DISCONNECT event when the USB cable is unplugged or the host disconnects.

Driver source:

This leads to incorrect gadget behavior, where the USB controller does not return to a default or idle state — the current_speed field does not become UNKNOWN , but instead remains stuck in super-speed , high-speed , or even full-speed speed. As a result, on the next USB connection attempt, the gadget may not re-enumerate properly or not show up at all on the host.

Can someone with hardware or kernel knowledge confirm whether this issue is caused by a hardware limitation or bug, or perhaps something else? On other vendor SBCs using similar SoCs and USB configurations, the DWC3_DEVICE_EVENT_DISCONNECT is correctly generated when unplugging the USB cable.

2 Likes

I recorded a dwc3_event trace log on both the Orange Pi 5 Ultra and the Rock 5B+ while unplugging the USB cable and then reconnecting it after a few seconds.

As you can see, on the Orange Pi, after the cable is unplugged, the Suspend event is followed by a proper Disconnect event. Then, after a short wait, reconnecting the cable triggers the expected Reset and Connection Done events.

However, on the Rock 5B+, the same sequence only produces the Suspend event — the Disconnect event is missing. After a short pause, I see a duplicated pair of Reset and Connection Done events, which could be a result of the missing disconnect. Then I tried to repeat the procedure again, but this time the Mass Storage Gadget did not reappear, and the trace log remained empty — so it seems something may have locked up outside the gadget driver.

Orange Pi 5 Ultra trace log:

root@orangepi-5-ultra:/home/orangepi# cat /sys/kernel/tracing/trace
# tracer: nop
#
# entries-in-buffer/entries-written: 942/942   #P:8
#
#                                _-----=> irqs-off/BH-disabled
#                               / _----=> need-resched
#                              | / _---=> hardirq/softirq
#                              || / _--=> preempt-depth
#                              ||| / _-=> migrate-disable
#                              |||| /     delay
#           TASK-PID     CPU#  |||||  TIMESTAMP  FUNCTION
#              | |         |   |||||     |         |
     irq/77-dwc3-2541    [000] D....  1421.469777: dwc3_event: event (00006084): ep1out: Transfer In Progress [00000000] (SIm)
     irq/77-dwc3-2541    [000] D....  1421.470542: dwc3_event: event (00004086): ep1in: Transfer In Progress [00000000] (sIm)
     irq/77-dwc3-2541    [000] D....  1421.470570: dwc3_event: event (00006084): ep1out: Transfer In Progress [00000000] (SIm)
     irq/77-dwc3-2541    [000] D....  1421.470879: dwc3_event: event (00004086): ep1in: Transfer In Progress [00000000] (sIm)
     irq/77-dwc3-2541    [000] D....  1421.470912: dwc3_event: event (00130601): Suspend [U3]
     irq/77-dwc3-2541    [000] D....  1424.184725: dwc3_event: event (00000001): Disconnect: [U0]
     irq/77-dwc3-2541    [000] D....  1431.312894: dwc3_event: event (00000101): Reset [U0]
     irq/77-dwc3-2541    [000] D....  1431.317971: dwc3_event: event (00000201): Connection Done [U0]
     irq/77-dwc3-2541    [000] D....  1431.318477: dwc3_event: event (0000c040): ep0out: Transfer Complete (sIL) [Setup Phase]
     irq/77-dwc3-2541    [000] D....  1431.318503: dwc3_event: event (000020c2): ep0in: Transfer Not Ready [00000000] (Not Active) [Status Phase]
     irq/77-dwc3-2541    [000] D....  1431.318523: dwc3_event: event (0000c042): ep0in: Transfer Complete (sIL) [Status Phase]
     irq/77-dwc3-2541    [000] D....  1431.318668: dwc3_event: event (0000c040): ep0out: Transfer Complete (sIL) [Setup Phase]
     irq/77-dwc3-2541    [000] D....  1431.318712: dwc3_event: event (000010c2): ep0in: Transfer Not Ready [00000000] (Not Active) [Data Phase]
     irq/77-dwc3-2541    [000] D....  1431.318749: dwc3_event: event (0000c042): ep0in: Transfer Complete (sIL) [Data Phase]
     irq/77-dwc3-2541    [000] D....  1431.318763: dwc3_event: event (000020c0): ep0out: Transfer Not Ready [00000000] (Not Active) [Status Phase]
     irq/77-dwc3-2541    [000] D....  1431.318799: dwc3_event: event (0000c040): ep0out: Transfer Complete (sIL) [Status Phase]
     irq/77-dwc3-2541    [000] D....  1431.320915: dwc3_event: event (0000c040): ep0out: Transfer Complete (sIL) [Setup Phase]
     irq/77-dwc3-2541    [000] D....  1431.320947: dwc3_event: event (000010c2): ep0in: Transfer Not Ready [00000000] (Not Active) [Data Phase]
     irq/77-dwc3-2541    [000] D....  1431.321006: dwc3_event: event (0000c042): ep0in: Transfer Complete (sIL) [Data Phase]
     irq/77-dwc3-2541    [000] D....  1431.321014: dwc3_event: event (000020c0): ep0out: Transfer Not Ready [00000000] (Not Active) [Status Phase]
     irq/77-dwc3-2541    [000] D....  1431.321060: dwc3_event: event (0000c040): ep0out: Transfer Complete (sIL) [Status Phase]
     irq/77-dwc3-2541    [000] D....  1431.321159: dwc3_event: event (0000c040): ep0out: Transfer Complete (sIL) [Setup Phase]
     irq/77-dwc3-2541    [000] D....  1431.321180: dwc3_event: event (000010c2): ep0in: Transfer Not Ready [00000000] (Not Active) [Data Phase]
     irq/77-dwc3-2541    [000] D....  1431.321227: dwc3_event: event (0000c042): ep0in: Transfer Complete (sIL) [Data Phase]
     irq/77-dwc3-2541    [000] D....  1431.321234: dwc3_event: event (000020c0): ep0out: Transfer Not Ready [00000000] (Not Active) [Status Phase]
     irq/77-dwc3-2541    [000] D....  1431.321278: dwc3_event: event (0000c040): ep0out: Transfer Complete (sIL) [Status Phase]
     irq/77-dwc3-2541    [000] D....  1431.321510: dwc3_event: event (0000c040): ep0out: Transfer Complete (sIL) [Setup Phase]
     irq/77-dwc3-2541    [000] D....  1431.321539: dwc3_event: event (000010c2): ep0in: Transfer Not Ready [00000000] (Not Active) [Data Phase]
     irq/77-dwc3-2541    [000] D....  1431.321600: dwc3_event: event (0000c042): ep0in: Transfer Complete (sIL) [Data Phase]
     irq/77-dwc3-2541    [000] D....  1431.321608: dwc3_event: event (000020c0): ep0out: Transfer Not Ready [00000000] (Not Active) [Status Phase]
     ...

Rock 5B+ trace log:

root@rock-5b-plus:~# cat /sys/kernel/tracing/trace
# tracer: nop
#
# entries-in-buffer/entries-written: 1163/1163   #P:8
#
#                                _-----=> irqs-off/BH-disabled
#                               / _----=> need-resched
#                              | / _---=> hardirq/softirq
#                              || / _--=> preempt-depth
#                              ||| / _-=> migrate-disable
#                              |||| /     delay
#           TASK-PID     CPU#  |||||  TIMESTAMP  FUNCTION
#              | |         |   |||||     |         |
     irq/81-dwc3-1715    [000] D....  1121.272296: dwc3_event: event (00030601): Suspend [U3]
     irq/81-dwc3-1715    [000] D....  1131.913846: dwc3_event: event (00000101): Reset [U0]
     irq/81-dwc3-1715    [000] D....  1131.916039: dwc3_event: event (00000201): Connection Done [U0]
     irq/81-dwc3-1715    [000] D....  1131.916208: dwc3_event: event (00000101): Reset [U0]
     irq/81-dwc3-1715    [000] D....  1131.919440: dwc3_event: event (00000201): Connection Done [U0]
     irq/81-dwc3-1715    [000] D....  1131.969191: dwc3_event: event (0000c040): ep0out: Transfer Complete (sIL) [Setup Phase]
     irq/81-dwc3-1715    [000] D....  1131.969230: dwc3_event: event (000020c2): ep0in: Transfer Not Ready [00000000] (Not Active) [Status Phase]
     irq/81-dwc3-1715    [000] D....  1131.969263: dwc3_event: event (0000c042): ep0in: Transfer Complete (sIL) [Status Phase]
     irq/81-dwc3-1715    [000] D....  1131.969287: dwc3_event: event (0000c040): ep0out: Transfer Complete (sIL) [Setup Phase]
     irq/81-dwc3-1715    [000] D....  1131.969327: dwc3_event: event (000010c2): ep0in: Transfer Not Ready [00000000] (Not Active) [Data Phase]
     irq/81-dwc3-1715    [000] D....  1131.969342: dwc3_event: event (0000c042): ep0in: Transfer Complete (sIL) [Data Phase]
     irq/81-dwc3-1715    [000] D....  1131.969354: dwc3_event: event (000020c0): ep0out: Transfer Not Ready [00000000] (Not Active) [Status Phase]
     irq/81-dwc3-1715    [000] D....  1131.969373: dwc3_event: event (0000c040): ep0out: Transfer Complete (sIL) [Status Phase]
     irq/81-dwc3-1715    [000] D....  1131.971607: dwc3_event: event (0000c040): ep0out: Transfer Complete (sIL) [Setup Phase]
     irq/81-dwc3-1715    [000] D....  1131.971650: dwc3_event: event (000010c2): ep0in: Transfer Not Ready [00000000] (Not Active) [Data Phase]
     irq/81-dwc3-1715    [000] D....  1131.971665: dwc3_event: event (0000c042): ep0in: Transfer Complete (sIL) [Data Phase]
     irq/81-dwc3-1715    [000] D....  1131.971676: dwc3_event: event (000020c0): ep0out: Transfer Not Ready [00000000] (Not Active) [Status Phase]
     irq/81-dwc3-1715    [000] D....  1131.971695: dwc3_event: event (0000c040): ep0out: Transfer Complete (sIL) [Status Phase]
     irq/81-dwc3-1715    [000] D....  1131.971762: dwc3_event: event (0000c040): ep0out: Transfer Complete (sIL) [Setup Phase]
     irq/81-dwc3-1715    [000] D....  1131.971786: dwc3_event: event (000010c2): ep0in: Transfer Not Ready [00000000] (Not Active) [Data Phase]
     irq/81-dwc3-1715    [000] D....  1131.971801: dwc3_event: event (0000c042): ep0in: Transfer Complete (sIL) [Data Phase]
     irq/81-dwc3-1715    [000] D....  1131.971813: dwc3_event: event (000020c0): ep0out: Transfer Not Ready [00000000] (Not Active) [Status Phase]
     irq/81-dwc3-1715    [000] D....  1131.971839: dwc3_event: event (0000c040): ep0out: Transfer Complete (sIL) [Status Phase]
     irq/81-dwc3-1715    [000] D....  1131.971960: dwc3_event: event (0000c040): ep0out: Transfer Complete (sIL) [Setup Phase]
     irq/81-dwc3-1715    [000] D....  1131.971990: dwc3_event: event (000010c2): ep0in: Transfer Not Ready [00000000] (Not Active) [Data Phase]
     irq/81-dwc3-1715    [000] D....  1131.972006: dwc3_event: event (0000c042): ep0in: Transfer Complete (sIL) [Data Phase]
     irq/81-dwc3-1715    [000] D....  1131.972014: dwc3_event: event (000020c0): ep0out: Transfer Not Ready [00000000] (Not Active) [Status Phase]
     irq/81-dwc3-1715    [000] D....  1131.972034: dwc3_event: event (0000c040): ep0out: Transfer Complete (sIL) [Status Phase]
     irq/81-dwc3-1715    [000] D....  1131.972167: dwc3_event: event (0000c040): ep0out: Transfer Complete (sIL) [Setup Phase]
     irq/81-dwc3-1715    [000] D....  1131.972191: dwc3_event: event (000010c2): ep0in: Transfer Not Ready [00000000] (Not Active) [Data Phase]
     irq/81-dwc3-1715    [000] D....  1131.972207: dwc3_event: event (0000c042): ep0in: Transfer Complete (sIL) [Data Phase]
     ...
3 Likes

@RadxaYuntian, @Jack, @Nasca could you please look into this issue?
In peripheral mode, USB is unusable in this state, which makes the project I’m working on unfeasible.
The most important question is whether the hardware generates an interrupt after the USB cable is disconnected.

There are 2 OTG ports. Are both behaving like this?
CC @ken

@RadxaYuntian Yes, both USB ports show the same behavior. I also tested it under Armbian, and the issue is exactly the same there as well.

@RadxaYuntian Is there anyone among you who could investigate this issue from the hardware side? Our project is currently on hold because of this, and we need to make a decision on whether we can move forward with the 5B+. In the meantime, I also tested USB disconnection on the Rock 5A, and the problem does not occur there, the disconnect event is generated properly.

@Peter.Wang please review this support case.

@ken is investigating this issue now, you can send mail to support@radxa.com for further communication

What device should I connect to reproduce the problem?

Thank you @Peter.Wang!

@ken I am using a regular desktop PC as the host (Intel NUC8i7HVK2), where the 5B+ shows up as a mass storage device.

The following steps can be used for testing:

  1. Flash the Rock 5B+ image: https://github.com/radxa-build/rock-5b-plus/releases/download/rsdk-b2/rock-5b-plus_bookworm_kde_b2.output.img.xz

  2. Set the USB port at address 0xFC400000 (rear bottom USB3-A) to peripheral mode using rsetup
    Set the port at 0xFC000000 (front USB-C) to host mode using fdtput , since overlay is missing:
    sudo fdtput -t s /usr/lib/linux-image-6.1.43-15-rk2312/rockchip/rk3588-rock-5b-plus.dtb /usbdrd3_0/usb@fc000000 dr_mode host

  3. Reboot

  4. Verify modes:
    cat /proc/device-tree/usbdrd3_0/usb@fc000000/dr_mode # should return ‘host’
    cat /proc/device-tree/usbdrd3_1/usb@fc400000/dr_mode # should return ‘peripheral’

  5. Create an image file: dd if=/dev/zero of=disk.img bs=1 count=0 seek=10G

  6. Activate the mass storage gadget: sudo modprobe g_mass_storage file=disk.img

  7. Enable logging of dwc3_event events: echo 1 | sudo tee /sys/kernel/tracing/events/dwc3/dwc3_event/enable

  8. Trace the events: sudo cat /sys/kernel/tracing/trace_pipe | egrep "Disconnect|Reset|Connection Done|Suspend|WakeUp"

When following the above steps on the 5B+, unplugging and replugging the USB cable 3 times results in the following log:

radxa@rock-5b-plus:~$ sudo cat /sys/kernel/tracing/trace_pipe | egrep “Disconnect|Reset|Connection Done|Suspend|WakeUp”
irq/79-dwc3-1697 [000] D… 180.328576: dwc3_event: event (00000101): Reset [U0]
irq/79-dwc3-1697 [000] D… 180.332902: dwc3_event: event (00000201): Connection Done [U0]
irq/79-dwc3-1697 [000] D… 184.795167: dwc3_event: event (00030601): Suspend [U3]
irq/79-dwc3-1697 [000] D… 189.082074: dwc3_event: event (00000101): Reset [U0]
irq/79-dwc3-1697 [000] D… 189.084271: dwc3_event: event (00000201): Connection Done [U0]
irq/79-dwc3-1697 [000] D… 189.094847: dwc3_event: event (00000101): Reset [U0]
irq/79-dwc3-1697 [000] D… 189.099212: dwc3_event: event (00000201): Connection Done [U0]
irq/79-dwc3-1697 [000] D… 196.790509: dwc3_event: event (00030601): Suspend [U3]
irq/79-dwc3-1697 [000] D… 201.082624: dwc3_event: event (00000101): Reset [U0]
irq/79-dwc3-1697 [000] D… 201.083816: dwc3_event: event (00000201): Connection Done [U0]
irq/79-dwc3-1697 [000] D… 201.088973: dwc3_event: event (00000101): Reset [U0]
irq/79-dwc3-1697 [000] D… 201.093340: dwc3_event: event (00000201): Connection Done [U0]

Performing the exact same procedure on a Rock 5A yields:

radxa@rock-5a:~$ sudo cat /sys/kernel/tracing/trace_pipe | egrep “Disconnect|Reset|Connection Done|Suspend|WakeUp”
irq/68-dwc3-1384 [000] D… 60.091399: dwc3_event: event (00000001): Disconnect: [U0]
irq/68-dwc3-1384 [000] D… 63.909461: dwc3_event: event (00000101): Reset [U0]
irq/68-dwc3-1384 [000] D… 63.913747: dwc3_event: event (00000201): Connection Done [U0]
irq/68-dwc3-1384 [000] D… 68.487150: dwc3_event: event (00000001): Disconnect: [U0]
irq/68-dwc3-1384 [000] D… 71.177394: dwc3_event: event (00000101): Reset [U0]
irq/68-dwc3-1384 [000] D… 71.181697: dwc3_event: event (00000201): Connection Done [U0]
irq/68-dwc3-1384 [000] D… 77.222313: dwc3_event: event (00000001): Disconnect: [U0]
irq/68-dwc3-1384 [000] D… 80.301649: dwc3_event: event (00000101): Reset [U0]
irq/68-dwc3-1384 [000] D… 80.305948: dwc3_event: event (00000201): Connection Done [U0]
irq/68-dwc3-1384 [000] D… 100.347759: dwc3_event: event (00000101): Reset [U0]
irq/68-dwc3-1384 [000] D… 100.348947: dwc3_event: event (00000201): Connection Done [U0]

As shown, on the 5B+ the Disconnect events are missing (during three cable removals, only two Suspend events occurred, which shouldn’t happen), and this directly impacts gadget driver functionality.

Hi @ken, have you made any progress regarding the USB disconnect event?

@Nasca please also take a look at this issue.

Hi @RadxaYuntian!

Thanks for keeping this topic active. Is there anyone on your team who could check whether this issue also exists on the Rock 5T? This is critical for our project, as we require USB 3 in peripheral mode to function flawlessly. If the issue is not present on the 5T, it would be a suitable alternative for us, but before ordering, I’d like to be sure.

It’s important to note that I intend to use the Type-A port in peripheral mode, because with the Type-C port, the speed in peripheral mode depends on the cable orientation, it can result in either HighSpeed or SuperSpeed . This was discussed previously in another topic (CM5 USB and touchscreen issues) but hasn’t been resolved yet. With the Type-A port, this speed issue doesn’t exist since the cable can only be inserted one way.

I’ll test it on ROCK 5T.

The ROCK 5T USB Type A port can only be used as a host.

Thanks for checking! I had assumed the 5T was the successor to the 5B+ and inherited its key specifications. I previously reviewed the 5T’s spec sheet, but for some reason I was under the impression that it also featured dual OTG like the 5B+. Unfortunately, that makes the 5T no longer a candidate for us.

Were you able to reproduce the missing USB disconnect event on the 5B+?

reproduced on ROCK 5B+.