Cannot detect USB devices on modded TL-WR703N with 19.07

I followed the advice from this post and successfully build a working image for my router


However, when I wish to insert a USB drive into my router, it failed to detect. I have tried to flash back to 18.06.9 (self-compiled) and it can detect the drive.
Packages I have installed:

# opkg install kmod-usb2 kmod-usb-storage kmod-usb-storage-extras

The output of dmesg | grep usb from 18.06.9:

[    9.957443] usbcore: registered new interface driver usbfs
[    9.961597] usbcore: registered new interface driver hub
[    9.967018] usbcore: registered new device driver usb
[   10.334920] usbcore: registered new interface driver usb-storage
[   10.458886] usbcore: registered new interface driver ums-alauda
[   10.466034] usbcore: registered new interface driver ums-cypress
[   10.473857] usbcore: registered new interface driver ums-datafab
[   10.481071] usbcore: registered new interface driver ums-freecom
[   10.488439] usbcore: registered new interface driver ums-isd200
[   10.495696] usbcore: registered new interface driver ums-jumpshot
[   10.503055] usbcore: registered new interface driver ums-karma
[   10.510753] usbcore: registered new interface driver ums-sddr09
[   10.518169] usbcore: registered new interface driver ums-sddr55
[   10.525675] usbcore: registered new interface driver ums-usbat
[   10.536212] usb 1-1: new high-speed USB device number 2 using ehci-platform
[   10.943340] usb-storage 1-1:1.0: USB Mass Storage device detected
[   10.976470] scsi host0: usb-storage 1-1:1.0

The output from 19.07.4

[    0.283158] ar7200-usb-phy usb-phy: phy reset is missing
[    1.202221] usb_vbus: disabling
[   16.217689] usbcore: registered new interface driver usbfs
[   16.221852] usbcore: registered new interface driver hub
[   16.227256] usbcore: registered new device driver usb
[   16.846605] usbcore: registered new interface driver usb-storage
[   17.089032] usbcore: registered new interface driver ums-alauda
[   17.109254] usbcore: registered new interface driver ums-cypress
[   17.116838] usbcore: registered new interface driver ums-datafab
[   17.138209] usbcore: registered new interface driver ums-freecom
[   17.145666] usbcore: registered new interface driver ums-isd200
[   17.158450] usbcore: registered new interface driver ums-jumpshot
[   17.178284] usbcore: registered new interface driver ums-karma
[   17.186030] usbcore: registered new interface driver ums-sddr09
[   17.208926] usbcore: registered new interface driver ums-sddr55
[   17.216662] usbcore: registered new interface driver ums-usbat

Hi, I don't have a device like yours, but I've been searching for and reading about migration from ar71x to ath79.

At this moment, I'm looking for information regarding USB. That's why I read your post...

So, I just can share a little tip, but I'm not sure if this can help you...

Maybe there are some patches working in ar71xx that adjust some things to make USB functional in your device. Maybe something missing (or impossible) to declare in DTS file....

For example, maybe target/linux/ar71xx/920-usb-chipidea-AR933x-platform-support.patch since it seems your device uses AR9331.

If this is your case, try to look at some other DTS file for the same SOC and maybe you can figure out something that could help you.

Good luck!

dts-file for your board describe voltage regulator for usb bus:

&reg_usb_vbus {
	gpio = <&gpio 8 GPIO_ACTIVE_HIGH>;
};

but it is disabled by default:

and driver don't enable it (possiblly wrong dts config?).
You can add regulator-boot-on or regulator-always-on property to emulate previous (ar71xx) behaviour. Something like:

&reg_usb_vbus {
	gpio = <&gpio 8 GPIO_ACTIVE_HIGH>;
	regulator-boot-on;
};

I tried regulator-boot-on, which still disables it.
Then I tried regulator-always-on, the "disabling" message disappears, but the device failed to recognize the drive. The output of dmesg | grep usb is

[    0.283198] ar7200-usb-phy usb-phy: phy reset is missing
[   16.241915] usbcore: registered new interface driver usbfs
[   16.246065] usbcore: registered new interface driver hub
[   16.251530] usbcore: registered new device driver usb
[   16.878854] usbcore: registered new interface driver usb-storage
[   17.118614] usbcore: registered new interface driver ums-alauda
[   17.138399] usbcore: registered new interface driver ums-cypress
[   17.145886] usbcore: registered new interface driver ums-datafab
[   17.158298] usbcore: registered new interface driver ums-freecom
[   17.178435] usbcore: registered new interface driver ums-isd200
[   17.185864] usbcore: registered new interface driver ums-jumpshot
[   17.208283] usbcore: registered new interface driver ums-karma
[   17.216042] usbcore: registered new interface driver ums-sddr09
[   17.228814] usbcore: registered new interface driver ums-sddr55
[   17.248693] usbcore: registered new interface driver ums-usbat

I'll try lmmodesto's advice.

Hi @Icarusradio,

In my case, I've done some hacks in a WR941ND v3.6 to be able using USB.

This router is almost the same as WR1041ND v1, but this one has a particular register value set by u-boot code:

ar7100_reg_wr_nf(AR7100_USB_PLL_CONFIG, 0x00001030); /* Reg Addr: 0xb8050008 */

So, with this little modification on my u-boot code I can use some USB devices with 19.07.4 / ath79.

Using 19.07.4 / ar71xx I can use USB too if I change the board initialization code on Openwrt source (files mach-tl-wr941nd.c and dev-usb.c). It's not necessary the u-boot modification.

I don't know how or if it is possible to express this kind of initialization using DTS yet. If I understood well, it depends on some driver expecting and being able to use a configuration expressed in DTS file...

But, I'm not sure which driver could have this responsibility. Maybe ar7200-usb-phy?? (created by 0004-phy-add-ath79-usb-phys.patch).

I my case, the probe fails with the same message as yours (the same for some others devices - some posts have this message...):

ar7200-usb-phy usb-phy: phy reset is missing

I'm not sure what is the impact of this failure... I don't know if it could affect you...

The driver is not loaded, but in my case I can use some (not all that I've tested) USB devices.

Good luck!

PS: There are some specific threads about ath79 migration. Maybe you could ask there for more information. At least, there are a lot of people that knows a lot more about this than I :wink:

I've done some extras tests with ar7200-usb-phy driver (added prints for debug).

The driver probe fails at the first attempt, but kernel retries a bit latter with success.

So, I guess that your problem could be probably some initialization code that is missing...

In this case, would be worth examine mach files at target/linux/ar71xx/files/arch/mips/ath79 and search for differences for similar devices.

Good luck!

Thank you very much, I will try that later

It's very interesting. In this case the most probable that usb phy analog reset is needed.
@Icarusradio Can you test something like adding into ar9331_tplink_tl-wr703n.dts:

&usb_phy {
	status = "okay";
	reset-names = "usb-phy-analog", "usb-phy", "usb-suspend-override";
	resets = <&rst 11>, <&rst 4>, <&rst 3>;
};

?

Looking at dev-usb.c (after patches applied) it seems that this is the USB code initialization in ar71xx for your board:

static void __init ar9xxx_ci_usb_setup(int bus_id, int irq)
{
	struct ci_hdrc_platform_data ci_pdata;
	bool host_mode = true;

	if (soc_is_ar933x())
		host_mode = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP) &
			    AR933X_BOOTSTRAP_USB_MODE_HOST;
	else
		host_mode = !(ath79_reset_rr(AR934X_RESET_REG_BOOTSTRAP) &
			      AR934X_BOOTSTRAP_USB_MODE_DEVICE);

	if (host_mode) {
		ath79_usb_register("ehci-platform", bus_id,
				   AR934X_EHCI_BASE, AR934X_EHCI_SIZE,
				   irq, &ath79_ehci_pdata_v2,
				   sizeof(ath79_ehci_pdata_v2));

		return;
	}

	memset(&ci_pdata, 0, sizeof(ci_pdata));
	ci_pdata.name = "ci_hdrc_ar9xxx";
	ci_pdata.capoffset = DEF_CAPOFFSET;
	ci_pdata.dr_mode = USB_DR_MODE_PERIPHERAL;
	ci_pdata.flags = CI_HDRC_DUAL_ROLE_NOT_OTG | CI_HDRC_DP_ALWAYS_PULLUP;
	ci_pdata.vbus_extcon.edev = ERR_PTR(-ENODEV);
	ci_pdata.id_extcon.edev = ERR_PTR(-ENODEV);
	ci_pdata.itc_setting = 1;

	platform_device_register_simple("usb_phy_generic",
					PLATFORM_DEVID_AUTO, NULL, 0);

	ath79_usb_register("ci_hdrc", -1,
			   AR934X_EHCI_BASE, AR934X_EHCI_SIZE,
			   irq, &ci_pdata, sizeof(ci_pdata));
}

static void __init ar933x_usb_setup(void)
{
	ath79_device_reset_set(AR933X_RESET_USBSUS_OVERRIDE);
	mdelay(10);

	ath79_device_reset_clear(AR933X_RESET_USB_HOST);
	mdelay(10);

	ath79_device_reset_clear(AR933X_RESET_USB_PHY);
	mdelay(10);

	ar9xxx_ci_usb_setup(-1, ATH79_CPU_IRQ(3));
}

Looking at your log for 18.09.6 it seems that your device was detected by a "ehci-platform" driver...

I'm not sure, but maybe you could try to add "qca,ar7100-ehci" or "generic-ehci" in your USB compatible clause...

Good luck!

One stupid question. Which usb host driver do you use?
As @lmmodesto noted, ar71xx registrate/use ehci-platform for host mode
and ci_hdrc for device mode.
ath79 registrate/use chipidea,usb2 and force host mode.
Decompile dts-file contain:

                usb@1b000000 {
                        compatible = "chipidea,usb2";
                        reg = <0x1b000000 0x200>;
                        interrupts = <0x3>;
                        resets = <0x5 0x5>;
                        reset-names = "usb-host";
                        phy-names = "usb-phy";
                        phys = <0xb>;
                        status = "okay";
                        dr_mode = "host";
                        vbus-supply = <0xc>;
                };

Did you try opkg install kmod-usb-chipidea?
This driver may need adding something like:

&usb {
                  caps-offset = <0x100>;
}

to correspond ar71xx init sequence:

I've tried to add both &usb section and regulator-always-on to the dts file, installed kmod-usb-chipidea, it still fails to recognize the drive. The dmesg is also the same.

Looking at target/linux/ath79/image/tiny-tp-link.mk it seems that the driver is already included in the image:

define Device/tplink_tl-wr703n
  $(Device/tplink-4mlzma)
  ATH_SOC := ar9331
  DEVICE_TITLE := TP-Link TL-WR703N
  DEVICE_PACKAGES := kmod-usb-chipidea2
  TPLINK_HWID := 0x07030101
  SUPPORTED_DEVICES += tl-wr703n
endef
TARGET_DEVICES += tplink_tl-wr703n

For ar71xx it was:

define Device/tl-wr703n-v1
  $(Device/tplink-4mlzma)
  DEVICE_TITLE := TP-LINK TL-WR703N v1
  DEVICE_PACKAGES := kmod-usb-core kmod-usb2
  BOARDNAME := TL-WR703N
  DEVICE_PROFILE := TLWR703
  TPLINK_HWID := 0x07030101
  CONSOLE := ttyATH0,115200
endef
TARGET_DEVICES += tl-wr703n-v1

@Icarusradio, did you try with these drivers?

Just for reference, these are my settings for USB (.config and DTS compatible parts):

$ egrep -i "usb|ehci|ohci" .config | grep -v "^#"
CONFIG_USB_SUPPORT=y
CONFIG_PACKAGE_kmod-phy-ath79-usb=y
CONFIG_PACKAGE_kmod-usb-core=y
CONFIG_PACKAGE_kmod-usb-ehci=y
CONFIG_PACKAGE_kmod-usb-ledtrig-usbport=y
CONFIG_PACKAGE_kmod-usb-ohci=y
CONFIG_PACKAGE_kmod-usb-storage=y
CONFIG_PACKAGE_kmod-usb-storage-extras=y
CONFIG_PACKAGE_kmod-usb-uhci=y
CONFIG_PACKAGE_kmod-usb2=y
CONFIG_PACKAGE_libusb-1.0=y
CONFIG_PACKAGE_usbutils=y
		usb: usb@1b000100 {
			compatible = "qca,ar7100-ehci", "generic-ehci";

It seems that chipidea's driver would be great for using OTG. If this is not an issue, maybe you could try using the others drivers...

Good luck!