USB tethering doesn't work if router boots with USB already connected

If I boot up my Beryl AX with my Android phone already connected via USB, the Android phone doesn't recognize data transfer. It only charges the phone, and the panel looks like this:

If I boot up the router with the Android phone disconnected, wait until the boot is complete and THEN connect the phone, everything works fine.

I've tried to programmatically disable the USB port power, wait a few seconds and then re-enable the USB port power in a startup script to no avail.

It's also unable to connect to the repeater AP automatically on boot. It will try and fail (see screenshot above). If I go into the Android phone settings, disable and re-enable the hotspot and then change the MAC Mode in the "Modify" menu, it works. Other devices are able to connect to the hotspot just fine. It's just the Beryl AX that has issues and it's only after the Beryl reboots. This was fixed by using "Auto Update MAC" set to "Reboot" on 4.7.0. USB issues still persist.

Any advice or help would be GREATLY appreciated. Thank you so much!

logs.zip (22.5 KB)

Unfortunately the log is full of adguard things and does not tell the reason.

What is your phone model?

I tested iPhone 16 and Samsung A20s, BeryAX 4.6.4-op24 firmware

iPhone 16 works good. After Beryl is power cycled tethering is built again.

Samsung A20s does not work as its tethering is turned off automatically when beryl turned off.

In your case, when you power cycle Beryl AX, and replug your phone, does your phone prompt you to trust this device and turn on tethering again?

The smartphone is a Moto G 5G (2023) running Android 14.

Reproduction steps:

  1. Enable developer settings on phone, set USB tethering as default USB option.

  2. Connect the phone via USB to unpowered Beryl AX.

  3. Power up the Beryl AX.

  4. Observe greyed out “USB tethering” option, as if data is not enabled for USB. Observe the phone charging.

  5. Disconnect and reconnect the USB cable from the Beryl AX.

  6. Observe previously disabled “USB tethering” option become enabled, automatically toggles on due to developer settings, interface comes up on the router, everything now works.

Is there any way I can get you better logs for diagnosis? Thank you so much.

It feels like it’s an issue with the USB driver, since the crux of the issue is the USB device lacking data upon boot until it’s unplugged and plugged back in.

Here is a video demonstrating my issue with USB tethering post-boot: https://youtube.com/shorts/-dyrxObmQF0

I did some test and here is the result with iphone.

  1. I used the 4.6.4-op24 firmware and it seems just works.
  2. When I change to the 4.6.4 and I met some problems, e.g. cannot get IP. But it resolved itself after reboot iPhone. Also the mtu and interface tracking may matters.

Sorry I don't have the same Android to test. But here is everything that may matters.

  1. Turn off interfact tracking. The ping actually caused problems in some situations.

  2. Set a lower mtu. A lower mtu may work better. We found 1470 may be a problem of iPhone. Set something lower and test.

  1. Reset your phone's network or reboot it.
    In our test of iPhone, when it has a problems we need to reboot the iPhone or reset the network of iPhone. It just resolve the problem.
    Not sure for Andriod but better do the same to see if it helps.

Thank you so much, @alzhao. I regret to inform you that I tried 1, 2 and 3 and had no success.

To help aid you further, I've disabled Adguard Home, powered down my Beryl AX and booted it back up with the Android phone connected via USB--I then exported the logs which I'll be attaching to this message. Hopefully without the Adguard spam, it'll be easier to see what's going on here.

logread (1).tar (181.5 KB)

It feels like there's something going wrong during the boot process that's preventing the USB device from properly initializing. I'm unable to communicate with the USB device via SSH (eg. via adb, which returns error: device not found) on the Beryl AX until I unplug the phone via USB and plug it back in. Then everything works.

Surely there's a clue in the logs somewhere, I just need your help deciphering that.

Doing echo 0 > /sys/class/gpio/usb_power/value and echo 1 > /sys/class/gpio/usb_power/value (or via hub-ctrl) only toggles the USB power, it doesn't simulate unplugging and replugging the USB cable. Can you think of any commands I can run to fully disable and fully enable the USB port, as if I physically unplugged it? If I were to automate that during startup, I think it would fix my problem.

Here's the output of lsusb -v after boot with the Android phone already connected via USB:

root@GL-MT3000:~# lsusb -v

Bus 002 Device 001: ID 1d6b:0003 Linux 5.4.211 xhci-hcd xHCI Host Controller
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               3.10
  bDeviceClass            9 
  bDeviceSubClass         0 
  bDeviceProtocol         3 
  bMaxPacketSize0         9
  idVendor           0x1d6b 
  idProduct          0x0003 
  bcdDevice            5.04
  iManufacturer           3 Linux 5.4.211 xhci-hcd
  iProduct                2 xHCI Host Controller
  iSerial                 1 11200000.xhci
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x001f
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         9 
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0004  1x 4 bytes
        bInterval              12
        bMaxBurst               0
Hub Descriptor:
  bLength              12
  bDescriptorType      42
  nNbrPorts             1
  wHubCharacteristic 0x0009
    Per-port power switching
    Per-port overcurrent protection
  bPwrOn2PwrGood       50 * 2 milli seconds
  bHubContrCurrent      0 milli Ampere
  bHubDecLat          0.0 micro seconds
  wHubDelay             0 nano seconds
  DeviceRemovable    0x00
 Hub Port Status:
   Port 1: 0000.02a0 lowspeed L1
Binary Object Store Descriptor:
  bLength                 5
  bDescriptorType        15
  wTotalLength       0x0023
  bNumDeviceCaps          2
  SuperSpeed USB Device Capability:
    bLength                10
    bDescriptorType        16
    bDevCapabilityType      3
    bmAttributes         0x00
    wSpeedsSupported   0x0008
      Device can operate at SuperSpeed (5Gbps)
    bFunctionalitySupport   3
      Lowest fully-functional device speed is SuperSpeed (5Gbps)
    bU1DevExitLat           0 micro seconds
    bU2DevExitLat           0 micro seconds
  SuperSpeedPlus USB Device Capability:
    bLength                20
    bDescriptorType        16
    bDevCapabilityType     10
    bmAttributes         0x00000001
      Sublink Speed Attribute count 1
      Sublink Speed ID count 0
    wFunctionalitySupport   0x0001
    bmSublinkSpeedAttr[0]   0x00050034
      Speed Attribute ID: 4 5Gb/s Symmetric RX SuperSpeed
    bmSublinkSpeedAttr[1]   0x000500b4
      Speed Attribute ID: 4 5Gb/s Symmetric TX SuperSpeed
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0001
  Self Powered

Bus 001 Device 001: ID 1d6b:0002 Linux 5.4.211 xhci-hcd xHCI Host Controller
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            9 
  bDeviceSubClass         0 
  bDeviceProtocol         1 
  bMaxPacketSize0        64
  idVendor           0x1d6b 
  idProduct          0x0002 
  bcdDevice            5.04
  iManufacturer           3 Linux 5.4.211 xhci-hcd
  iProduct                2 xHCI Host Controller
  iSerial                 1 11200000.xhci
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0019
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         9 
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0004  1x 4 bytes
        bInterval              12
Hub Descriptor:
  bLength               9
  bDescriptorType      41
  nNbrPorts             1
  wHubCharacteristic 0x0009
    Per-port power switching
    Per-port overcurrent protection
    TT think time 8 FS bits
  bPwrOn2PwrGood       10 * 2 milli seconds
  bHubContrCurrent      0 milli Ampere
  DeviceRemovable    0x00
  PortPwrCtrlMask    0xff
 Hub Port Status:
   Port 1: 0000.0100 power
can't get device qualifier: Resource temporarily unavailable
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0001
  Self Powered

And then after I unplug the Android phone and plug it back in:

root@GL-MT3000:~# lsusb -v

Bus 002 Device 001: ID 1d6b:0003 Linux 5.4.211 xhci-hcd xHCI Host Controller
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               3.10
  bDeviceClass            9 
  bDeviceSubClass         0 
  bDeviceProtocol         3 
  bMaxPacketSize0         9
  idVendor           0x1d6b 
  idProduct          0x0003 
  bcdDevice            5.04
  iManufacturer           3 Linux 5.4.211 xhci-hcd
  iProduct                2 xHCI Host Controller
  iSerial                 1 11200000.xhci
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x001f
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         9 
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0004  1x 4 bytes
        bInterval              12
        bMaxBurst               0
Hub Descriptor:
  bLength              12
  bDescriptorType      42
  nNbrPorts             1
  wHubCharacteristic 0x0009
    Per-port power switching
    Per-port overcurrent protection
  bPwrOn2PwrGood       50 * 2 milli seconds
  bHubContrCurrent      0 milli Ampere
  bHubDecLat          0.0 micro seconds
  wHubDelay             0 nano seconds
  DeviceRemovable    0x00
 Hub Port Status:
   Port 1: 0000.02a0 lowspeed L1
Binary Object Store Descriptor:
  bLength                 5
  bDescriptorType        15
  wTotalLength       0x0023
  bNumDeviceCaps          2
  SuperSpeed USB Device Capability:
    bLength                10
    bDescriptorType        16
    bDevCapabilityType      3
    bmAttributes         0x00
    wSpeedsSupported   0x0008
      Device can operate at SuperSpeed (5Gbps)
    bFunctionalitySupport   3
      Lowest fully-functional device speed is SuperSpeed (5Gbps)
    bU1DevExitLat           0 micro seconds
    bU2DevExitLat           0 micro seconds
  SuperSpeedPlus USB Device Capability:
    bLength                20
    bDescriptorType        16
    bDevCapabilityType     10
    bmAttributes         0x00000001
      Sublink Speed Attribute count 1
      Sublink Speed ID count 0
    wFunctionalitySupport   0x0001
    bmSublinkSpeedAttr[0]   0x00050034
      Speed Attribute ID: 4 5Gb/s Symmetric RX SuperSpeed
    bmSublinkSpeedAttr[1]   0x000500b4
      Speed Attribute ID: 4 5Gb/s Symmetric TX SuperSpeed
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0001
  Self Powered

Bus 001 Device 002: ID 22b8:2e25 motorola moto g 5G (XT2417D)
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x22b8 
  idProduct          0x2e25 
  bcdDevice            5.04
  iManufacturer           1 motorola
  iProduct                2 moto g 5G (XT2417D)
  iSerial                 3 ZY22K48DNZ
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0062
    bNumInterfaces          3
    bConfigurationValue     1
    iConfiguration          4 rndis_adb
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              500mA
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         2
      bFunctionClass        239 
      bFunctionSubClass       4 
      bFunctionProtocol       1 
      iFunction               7 RNDIS
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass       239 
      bInterfaceSubClass      4 
      bInterfaceProtocol      1 
      iInterface              5 RNDIS Communications Control
      ** UNRECOGNIZED:  05 24 00 10 01
      ** UNRECOGNIZED:  05 24 01 00 01
      ** UNRECOGNIZED:  04 24 02 00
      ** UNRECOGNIZED:  05 24 06 00 01
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval               9
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass        10 
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              6 RNDIS Ethernet Data
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x8e  EP 14 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x0f  EP 15 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 
      bInterfaceSubClass     66 
      bInterfaceProtocol      1 
      iInterface              8 ADB Interface
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  bNumConfigurations      1
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0000
  (Bus Powered)

Bus 001 Device 001: ID 1d6b:0002 Linux 5.4.211 xhci-hcd xHCI Host Controller
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            9 
  bDeviceSubClass         0 
  bDeviceProtocol         1 
  bMaxPacketSize0        64
  idVendor           0x1d6b 
  idProduct          0x0002 
  bcdDevice            5.04
  iManufacturer           3 Linux 5.4.211 xhci-hcd
  iProduct                2 xHCI Host Controller
  iSerial                 1 11200000.xhci
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0019
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         9 
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0004  1x 4 bytes
        bInterval              12
Hub Descriptor:
  bLength               9
  bDescriptorType      41
  nNbrPorts             1
  wHubCharacteristic 0x0009
    Per-port power switching
    Per-port overcurrent protection
    TT think time 8 FS bits
  bPwrOn2PwrGood       10 * 2 milli seconds
  bHubContrCurrent      0 milli Ampere
  DeviceRemovable    0x00
  PortPwrCtrlMask    0xff
 Hub Port Status:
   Port 1: 0000.0503 highspeed power enable connect
can't get device qualifier: Resource temporarily unavailable
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0001
  Self Powered

I tested out 4.7.0 and found that the "Auto Update MAC" set to "Reboot" fixes the issue I had with the Repeater. USB issues still persist.

Create the following file on your Beryl AX using nano or vim after you've ssh'ed into the router: /etc/init.d/reset_usb.sh

For example, nano /etc/init.d/reset_usb.sh

Add the following code to the script:

#!/bin/sh /etc/rc.common

START=99

start() {
    echo '11200000.xhci' > /sys/bus/pci/drivers/xhci_hcd/unbind
    sleep 1
    echo '11200000.xhci' > /sys/bus/pci/drivers/xhci_hcd/bind
}

Exit and save the file

Make the file executable: chmod +x /etc/init.d/reset_usb.sh

Enable the script to run at startup: /etc/init.d/reset_usb.sh enable

Now test it

1 Like

Thanks, @AdamK! I have tried what you suggested. The script fails with the following errors:

sh: write error: No such device
sh: write error: No such device

I've seen this error before when trying to echo to unbind and bind.

This would indicate that 11200000.xhci is not the device even though your lsusb command returned that it was.

Try running ls /sys/bus/pci/drivers/xhci_hcd/ with the phone plugged in and again after the phone is unplugged to see what the USB controller is named for sure.

Then update the script as needed for the correct device name.

Thanks @AdamK!

With the phone plugged in:

root@GL-MT3000:/sys/bus/usb/drivers/usb# ls /sys/bus/pci/drivers/xhci_hcd/
bind       new_id     remove_id  uevent     unbind

With it unplugged (appears to be same output):

root@GL-MT3000:/sys/bus/usb/drivers/usb# ls /sys/bus/pci/drivers/xhci_hcd/
bind       new_id     remove_id  uevent     unbind

And yeah, everything points to 11200000.xhci being the correct device name, so I'm pretty baffled what's going on. Doing some googling on sh: write error: No such device doesn't appear to yield anything useful.

Have you also tried running the commands manually outside of the script?

Also tried a reboot reset of the router?

As you mentioned to me in private message earlier, your fear that the issue could be the Linux kernel (version 5.4.211) might be correct. Some limitation or bug with the xHCI driver or USB implementations for certain devices I would guess. Not a GL.iNet issue of course.

The last thing I can recommend is checking the system logs (dmesg or /var/log/syslog) for any related errors.

Thank you so much for your help, @AdamK.

Yep, I have tried both in the script and outside the script.

Also tried a reboot of the router?

Yep, tried that too.

I looked through system logs and everything looks identical to the log .tar I uploaded above.

I feel like we're on the right path, that is creating a startup script that unbinds/binds the device to simulate unplugging and plugging in the USB cable. Perhaps there's something else I can try?

I would love to avoid replacing the Beryl AX with a different travel router if possible, I really like the little thing.

Note: I discovered that by disabling USB power via /sys/class/gpio/usb_power, it fixes the issue. However this isn't a viable solution for me as I need the phone to charge. Perhaps that's a clue of some sort.

Again, if this doesn't work I strongly suspect it's an issue with the way the kernel interacts with this USB device and there's nothing we can really do because the linux kernel is bundled with the GL.iNet firmware. You'll probably need to post on some more linux dev-focused forums to see if they've seen this issue and maybe they'll have a suggestion or even a patch.

1 Like

In your previous post, you said it does not work.

Do you need to put a "sleep 5" in between so that the power is not cut and then on immediatelly.

Hi @alzhao! I have tried that. Regardless of the amount of sleep between the commands, the USB tethering option is disabled once the USB port has its power re-enabled.

Only turning off the power works to fix the tethering issue (but is not a viable solution for me since I need charging). Turning off and on the power doesn’t work.

I am about to attempt using a powered USB hub attached to the Beryl AX, with the Moto G smartphone plugged into the hub. I am then going to disable /sys/class/gpio/usb_power/value on the Beryl AX. My hopes here is that it'll allow the USB tethering to activate AND charge the phone. Will update this thread with my results.

Update: Powered USB hub doesn't fix the problem.

With the smartphone connected via USB to the Beryl AX while it's booting, the device doesn't even show up in lsusb until I turn USB power off. And when I turn it back on, the device disappears.

root@GL-MT3000:~# lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux 5.4.211 xhci-hcd xHCI Host Controller
Bus 001 Device 001: ID 1d6b:0002 Linux 5.4.211 xhci-hcd xHCI Host Controller
root@GL-MT3000:~# echo 0 > /sys/class/gpio/usb_power/value;
root@GL-MT3000:~# lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux 5.4.211 xhci-hcd xHCI Host Controller
Bus 001 Device 006: ID 22b8:2e25 motorola moto g 5G (XT2417D)
Bus 001 Device 001: ID 1d6b:0002 Linux 5.4.211 xhci-hcd xHCI Host Controller
root@GL-MT3000:~# echo 1 > /sys/class/gpio/usb_power/value;
root@GL-MT3000:~# lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux 5.4.211 xhci-hcd xHCI Host Controller
Bus 001 Device 001: ID 1d6b:0002 Linux 5.4.211 xhci-hcd xHCI Host Controller
root@GL-MT3000:~# 

I will next be looking into tweaking /etc/usb-mode.json as I'm pretty much back at square one now.

Just had another thought: Maybe the Android device is only showing when I physically unplug it and plug it back in because some magic is happening in /etc/hotplug.d. Thoughts?