USB OTG g_mass_storage with USB 3.0 speed

Hi,
I use ROCK Pi 4B v1.3, with Debian9Desktop from Radxa download. Kernel 4.4.154-90.
I want to use it as external USB storage for my PC.

I connect it via USB OTG to my host PC and starts g_mass_storage.
I noticed that it is running as USB2.0 device instead of USB3.0 device.

The configuration is: ROCK Pi 4 with NVMe disk connected to it.
On the NVMe is created a container file, which is mount as g_mass_storage to USB OTG port.

Transfer rate is quite good for USB2.0 standard - 31MB/s. But is not satisfying for USB3.0 standard.

The PC, I connect the ROCK Pi 4, is running Windows7 system.
As I checked in host PC, the ROCK Pi 4 is recognized as USB2.0 device.

So how to connect the ROCK Pi OTG g_mass_storage as USB3.0 device ?

Below the dmesg:
mount NVMe:

[ 95.472596] EXT4-fs (nvme0n1p1): mounted filesystem with ordered data mode. Opts: (null)
[ 95.595941] ntfs: driver 2.1.32 [Flags: R/O MODULE].
[ 95.607591] ntfs: volume version 3.1.

start g_mass_storage:

[ 147.409421] Mass Storage Function, version: 2009/09/11
[ 147.409899] LUN: removable file: (no medium)
[ 147.410477] LUN: removable read only file: /mnt/nvme/file.img
[ 147.411000] Number of LUNs=1
[ 147.411650] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[ 147.412394] g_mass_storage gadget: g_mass_storage ready
[ 147.784374] g_mass_storage gadget: high-speed config #1: Linux File-Backed Storage

1 Like

Some addition to previous post.

The critical line from dmesg showing that my ROCK Pi 4 in OTG mode is connecting as USB2.0 device is:

[ 147.784374] g_mass_storage gadget: high-speed config #1: Linux File-Backed Storage

As I saw on Odroid forum for their XU3 SBC topic for USB 3.0 dmesg should return something similar to:

[10985.551513] g_mass_storage gadget: super-speed config #1: Linux File-Backed Storage

So I rise the questions:

  • Is it possible for ROCK Pi 4 to work in OTG as a Device in USB3.0 at all?
  • How to make ROCK Pi 4 to recognize taht is connected to USB3.0 (super-speed) Host instead of USB2.0 (high-speed)?
  • How to enforce (maybe) ROCK Pi 4 to connect as USB3.0 (super-speed) Device to the Host PC?

In advance, thanks for support!

Are you sure you have a USB3 cable? Mine does this: (Connected to macbook)

[ 2258.275049] rockchip-dwc3 usb@fe800000: USB peripheral connected
[ 2325.578187] Mass Storage Function, version: 2009/09/11
[ 2325.578672] LUN: removable file: (no medium)
[ 2325.594636] LUN: file: /media/nuraid/iSCSIdisks/foo.img
[ 2325.595165] Number of LUNs=1
[ 2325.595682] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[ 2325.596308] g_mass_storage gadget: userspace failed to provide iSerialNumber
[ 2325.596936] g_mass_storage gadget: g_mass_storage ready
[ 2327.863807] g_mass_storage gadget: super-speed config #1: Linux File-Backed Storage

Also…

curtis@rockpi:~$ cat /sys/class/udc/fe800000.dwc3/maximum_speed
super-speed
curtis@rockpi:~$ cat /sys/class/udc/fe800000.dwc3/current_speed
super-speed
curtis@rockpi:~$ cat /sys/class/udc/fe800000.dwc3/uevent
DRIVER=g_mass_storage
USB_UDC_NAME=dwc3-gadget
USB_UDC_DRIVER=g_mass_storage

And…

Curtiss-MacBook-Pro:NO NAME curtis$ gdd bs=1024 if=foo.img of=~/Desktop/foo.img status=progress
2245092352 bytes (2.2 GB, 2.1 GiB) copied, 25 s, 89.8 MB/s
2229248+0 records in
2229248+0 records out
2282749952 bytes (2.3 GB, 2.1 GiB) copied, 25.2843 s, 90.3 MB/s

I use the cable from my external USB3.0 disk enclosure fantec 225U3eSATAp (similar to this but w/o -6g).
The enclosure is working with USB 3.0 speed.
The host mode of otg port on ROCK Pi 4 is also working in USB3.0 speed with attached devices.

# lsusb -t
/:  Bus 08.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 5000M
    |__ Port 1: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 5000M

above, the Port 1: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 5000M is an enclosure with external SSD connected using my USB A-A cable to ROCK Pi 4 otg port working in host mode.

The same cable I use to connect ROCK Pi 4 in Device mode to my PC.

Next strange thing is that my ROCK Pi 4 in g_mass_storage mode is recognized by Windows Host PC (high-mode), but if connected to Ubuntu Host PC then nothing is happening. Linux doesn’t automatically see the Rock Pi 4 as a mass storage device.

Hi,
thank you @Curtman for your information.
Based on it I didn’t stop believe that ROCK Pi 4 can connect as super-speed mass storage.
And it connects. But it is not repeatable in my case.

I changed laptop I connect to and found that on that laptop ROCK Pi sometimes starts as high-speed (with information: This device can perform faster in USB 3.0" , but sometimes nothing happens after connect.
While it is not recognized I connect it to the USB3 hub. After that device is recognized as super-speed device.
Then I can even connect it back directly to the laptop and again it is recognized as super-speed device.
What is more I can reconnect it to first laptop and it is recognized as super-speed device.

After toggle the power again the behavior is high-speed or nothing happens.

I tested it with different cables but there is no correlation between cable and the behavior.

  • delock hard drive enclosure cable (63cm length)
  • LogiLink CU0038 (1m length)
  • own made unshielded short (3cm length), made from single wires
  • own made shielded long (20 cm length), made from some short A-B by cutting B and soldering A

What do you think it can be?
What test to do to catch the problem source?

I haven’t seen the issue you are describing when connecting it to my macbook or a desktop PC. I would imagine it has to do with the speeds that are negotiated between the host and the device as it connects. What does “cat /sys/class/udc/fe800000.dwc3/maximum_speed” report when the device fails to achieve super_speed? I use a cheap cable I got on eBay, does yours have the SS logo on them?

This is the sort of cable I’m using: https://www.ebay.com/itm/USB-3-0-Type-A-Male-to-Male-Plug-Cable-Lead-50cm-to-5m/264387402888?hash=item3d8eb79c88:m:mPH_GkwDnSxH24HlFEwPdtA

I’m currently trying to figure out a good way to debug OTG mode myself, as usbmon doesn’t seem to work. I’m looking at this project, which deals with OS fingerprinting on the raspberry pi zero in OTG mode. I’m thinking about trying to do something like this with the dwc3 driver to see some debug output. Maybe it would help you as well?