[BUG] ipq806x: external USB 3 devices are not initialized when CONFIG_ALL_KMODS=y

Device: Xiaomi R3D (ipq8064, usb 3.0, sata 3.0).

Kernel log when connecting USB 3 device when .config contain CONFIG_ALL_KMODS=n:

[ 1007.083030] usb 4-1: new SuperSpeed Gen 1 USB device number 3 using xhci-hcd
[ 1007.118147] usb-storage 4-1:1.0: USB Mass Storage device detected
[ 1007.118763] scsi host1: usb-storage 4-1:1.0
[ 1008.147862] scsi 1:0:0:0: Direct-Access     Seagate  Slim  SL         0934 PQ: 0 ANSI: 6
[ 1008.943095] sd 1:0:0:0: [sdb] 976773167 512-byte logical blocks: (500 GB/466 GiB)
[ 1008.943794] sd 1:0:0:0: [sdb] Write Protect is off
[ 1008.949562] sd 1:0:0:0: [sdb] Mode Sense: 2b 00 10 08
[ 1008.955087] sd 1:0:0:0: [sdb] Write cache: enabled, read cache: enabled, supports DPO and FUA
[ 1008.985877]  sdb: sdb1
[ 1008.987740] sd 1:0:0:0: [sdb] Attached SCSI disk
[ 1009.802644] ntfs: volume version 3.1.

Kernel log when connecting USB 3 device when .config contain CONFIG_ALL_KMODS=y:

[161463.327041] usb 4-1: new SuperSpeed Gen 1 USB device number 2 using xhci-hcd 

For two hours I could not understand the reason for this behavior. Well, kernel configs have a lot of differences due to changes in this parameter.

While USB 2 devices work fine in both cases.

1 Like

I had to build and test 12 firmwares!
Only after that began to partially localize the problem described above.
Guilty turned out to be parameter CONFIG_USB_UAS=m
Now I'm trying to understand what it is....

For a temporary fix, I had to comment two lines in the file package/kernel/linux/modules/usb.mk:

define KernelPackage/usb-storage-uas
  TITLE:=USB Attached SCSI (UASP) support
  AUTOLOAD:=$(call AutoProbe,uas,1)

define KernelPackage/usb-storage-uas/description
 Say Y here if you want to include support for
 USB Attached SCSI (UAS/UASP), a higher
 performance protocol available on many
 newer USB 3.0 storage devices

#$(eval $(call KernelPackage,usb-storage-uas))

Does anyone know how to properly fix this?

Well, that's not a fix, you are removing UAS support so you cant attach USB mass storage at all

If we remove the usb-storage-uas package from the build, then everything works fine.

The package usb-storage-uas is not used when not specifying kernel option CONFIG_ALL_KMODS=y.

Here is a more correct way to fix the described troubles.
You need to add an additional kernel module kmod-usb-storage-uas (autoload list) in the file target/linux/ipq806x/Makefile:

	kmod-leds-gpio kmod-gpio-button-hotplug swconfig \
	kmod-ata-ahci kmod-ata-ahci-platform \
	kmod-usb-ohci kmod-usb2 kmod-usb-ledtrig-usbport \
	kmod-phy-qcom-ipq806x-usb kmod-usb3 kmod-usb-dwc3-qcom \
	kmod-ath10k-ct wpad-basic-wolfssl \
	uboot-envtools kmod-usb-storage-uas

It turns out that when specifying the CONFIG_USB_UAS=m option, nonsense is obtained, because this module must either be absent or always present in the kernel.
Take a look at the code from file linux/drivers/usb/storafe/usb.c:

/* The main probe routine for standard devices */
static int storage_probe(struct usb_interface *intf,
			 const struct usb_device_id *id)
	struct us_unusual_dev *unusual_dev;
	struct us_data *us;
	int result;
	int size;

	/* If uas is enabled and this device can do uas then ignore it. */
	if (uas_use_uas_driver(intf, id, NULL))
		return -ENXIO;

The openwrt wiki for setting up usb indicates:

3. Some USB storage devices may require the UAS driver: 

I have an ipq8064 device that apparently does need kmod uas. I avoid the issue it looks you ran into by using custom .config's specific for my device and what i'm trying to do with the build (i.e. i don't use options like CONFIG_ALL_KMODS=y).
Alternatively, I use a custom script for imagebuilder for "production" builds (which is really nice - if you don't need to build it).

It's good if you can make it the build system better for all devices. Will you be able to test that?

1 Like

You're right. I overlooked such an important thing.
But at the same time, 2 more people were looking for a solution for 2 days and did not find this method.

Apparently you have not tried to connect exactly USB 3.x devices.

UAS is required for mass storage, always, otherwise you cant mount it

I have; however, the one usb 3.x device i have is a piece of junk so perhaps i need to look further. Hope you find a resolution (I empathise with your pain).

EDIT: if there is a bug, this is what i see with a usb 3.0 device (sandisk cruzer glide 3.0 256 gb purchased several years ago now) connected:

r7500v2 # lsusb -t
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 5000M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 480M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 5000M
    |__ Port 1: Dev 2, If 0, Class=, Driver=usb-storage, 5000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 480M
r7500v2 # block info | grep "/dev/sd"
/dev/sda1: UUID="1DCF6BA32DC52940" MOUNT="/mnt/sda1" TYPE="ntfs"

Please excuse the following rant: the usb device above is a piece of crap, don't every buy one. It claims to be usb 3.0 but writes slower than usb 2.0 - it's useless.

This is what I tested today on 12 different firmwares.
Everything works fine without the CONFIG_USB_UAS option.

Can you explain how did you use and mount USB mass storage without UAS?

Cause like almost all of the USB based storage uses SCSI via USB which UAS provides support for

Was it maybe already built into the kernel?

In addition to module kmod-usb-storage-uas, there is also module kmod-usb-storage.

Ok, so you are relying on the fact that your device doesnt use UASP which as far as I know is what USB3 storage requires.

UAS breaking stuff is a bug, and the place to report it is in issues on github

As such, there is no error.
It's just that when implementing this kernel module, it was necessary to add warning output to the kernel log:
WARN: For this USB device, module "usb-storage-uas" must be installed!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.