# USB 3.0 issues with Pine Rock64



## deanj (Oct 7, 2021)

Looking for guidance....
Goal: Turn a Rock64 SBC into a NFS server.
* {root} installed on microSD
* NFS share an external USB 3.0 drive.

Works on Linux - Armbian & DietPi

On FreeBSD, I tried:
13-RELEASE
14-CURRENT

In both cases (release/current), the single USB 3.0 port on the Rock64 doesn't appear to recognize any drive.  The single 3.0 USB port appears disabled.  If I plug the external hard drive into either one of the two USB 2 ports - the drive is recognized and shows in dmesg.  If I plug into the single USB 3 port, no messages displayed in dmesg.  Kernel doesn't recognize anything from UHCI / XHCI on the USB 3.0 port.  

Do I just need to load a tuneable in /boot/loader.conf?


----------



## sidetone (Oct 8, 2021)

Does it work almost fully functionally on the USB 2.0 port, with the exception of speed?

What does `kldstat` show for the drive when it's connected to the USB 2.0 port? Then kldunload it, and see how it's different for on the USB 3.0 port. Does xhci show up at all in kldstat or dmesg? `kldload` should work for loading kernel modules, but they often load automatically when a device is plugged in.

If your computer is set up properly, the mailing list may be of more help, then they could determine if a bug report is needed for the USB 3.0 port. How about BIOS settings specific to USB 3.0?


External SATA and Firewire harddisks are supposed to be faster than USB. I'm unsure if Firewire has become obsolete and on its support status on FreeBSD.


----------



## deanj (Oct 8, 2021)

kldstat
Id Refs Address                Size Name
 1   11 0xffff000000000000  1209308 kernel
 2    1 0xffff00000120a000    25808 umodem.ko
 3    2 0xffff000001230000    28698 ucom.ko
 4    1 0xffff0000cb000000    22000 dwwdt.ko
 5    1 0xffff0000cb022000    22000 mac_ntpd.ko

usbconfig

ugen3.1: <Generic OHCI root HUB> at usbus3, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE (0mA)
ugen2.1: <Generic EHCI root HUB> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen1.1: <DWCOTG OTG Root HUB> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
root@Rock64BSD1:~ # 

Drive works fine in either of the two USB 2.0 slots.  When plugged into the USB 3 slot, nothing happens.  dmesg shows no activity as if I never plugged it in.

root@Rock64BSD1:~ # dmesg | tail -10
uhub0: 1 port with 1 removable, self powered
uhub2: 1 port with 1 removable, self powered
uhub1: 1 port with 1 removable, self powered
dwwdt0: <Synopsys Designware watchdog timer> mem 0xff1a0000-0xff1a00ff irq 20 on ofwbus0
dwwdt0: cannot find clock
device_attach: dwwdt0 attach returned 6
lo0: link state changed to UP
dwc0: link state changed to DOWN
dwc0: link state changed to UP
Security policy loaded: MAC/ntpd (mac_ntpd)

^^^ plug it in, run dmesg again..... no change.

Then I plug it into either one of the two USB 2.0 ports, and it works... dmesg shows:

ugen1.2: <Seagate Expansion Desk> at usbus1
umass0 on uhub2
umass0: <Seagate Expansion Desk, class 0/0, rev 2.10/9.11, addr 2> on usbus1
umass0:  SCSI over Bulk-Only; quirks = 0x8100
umass0:0:0: Attached to scbus0
da0 at umass-sim0 bus 0 scbus0 target 0 lun 0
da0: <Seagate Expansion Desk 0911> Fixed Direct Access SPC-4 SCSI device
da0: Serial Number NA8FVENP
da0: 40.000MB/s transfers
da0: 2861588MB (5860533167 512 byte sectors)
da0: quirks=0x2<NO_6_BYTE>

Hardware is Rock64 single board computer.  Device has one USB 3.0 port and two USB 2.0.  :seems: like the single USB 3.0 port is registered as USB 1.0.


----------



## sidetone (Oct 8, 2021)

grep -i hci /usr/src/sys/amd64/conf/GENERIC

```
device        ahci            # AHCI-compatible SATA controllers
device        uhci            # UHCI PCI->USB interface
device        ohci            # OHCI PCI->USB interface
device        ehci            # EHCI PCI->USB interface (USB 2.0)
device        xhci            # XHCI PCI->USB interface (USB 3.0)
device        sdhci           # Generic PCI SD Host Controller
```
Try `kldload xhci`, to see if it's already loaded or not. Also, `dmesg | grep -i hci`.

Check out the manpages for some of these devices: xhci, ahci, ohci, sdhci. Perhaps use the USB 2.0 port, until USB 3.0 is figured out. For functional purposes, it should be enough. It could be a bug, or something not loaded. It will be solved sooner or later.


----------



## deanj (Oct 8, 2021)

Greatly appreciate your assistance.  I reached-out to both the FreeBSD-USB & FreeBSD-arm mailing lists as you recommended.  Andriy Gapon responded with the solution:

/boot/loader.conf needs: 
              fdt_overlays="rk3328-dwc3"

Once I added that overlay and rebooted - all worked as expected. 

Now that my problem is resolved; I would anticipate it may make sense to ask our Rockchip wiki maintainer to add this as a post-install recommendation for proper USB functionality of the Rock64 devices; or... it should be included on the hardware_proprietary .img file customers download for the Rock64.

thanks again. - Jeff


----------



## JohnnySorocil (Oct 9, 2021)

You needed to include that fdt overlay (devicetree overlay) because without it your system doesn't know that it have USB3 HW.
Device tree is hardware description language and many HW things are not enumerable (USB controllers, I2C controllers and devices, SPI controllers and devices) - unlike things like USB devices which are enumerable (you can plug it and system will recognize it automatically).
On PC side ACPI tables (forget which one exactly) are doing similar thing.
You can find source of your overlay at /usr/src/sys/dts/arm64/overlays/rk3328-dwc3.dtso and full device trees at /usr/src/sys/contrib/device-tree/src/arm64/rockchip


----------

