I use a USB Huawei ME906s-158 device as described in Huawei ME906s-158 not working with Ubuntu 16.04. If the module loses the connection it seems to have problems reconnecting to the network. So my idea is to write some script, running in the background checking if the LTE connection is up, and if not release the USB device and reconnect it, using terminal commands. I found helpful information in How to enable/disable mobile broadband from terminal? and on this forum thread, but the code is not running on my Ubuntu 16.04, which may be the problem.
Taking this line for example:
modprobe -r -f uhci_hcd
results in modprobe: FATAL: Module uhci_hcd is builtin.
error. The same is true if I use xhci_hcd, which is used for my device.
So my question is how to change the modprobe commands to remove/connect my device?
Using dmesg
the device is connected as
usb 3-13.1: new high-speed USB device number 117 using xhci_hcd
usb 3-13.1: New USB device found, idVendor=12d1, idProduct=15c1
usb 3-13.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 3-13.1: Product: HUAWEI Mobile
usb 3-13.1: Manufacturer: Huawei Technologies Co., Ltd.
usb 3-13.1: SerialNumber: 0123456789ABCDEF
cdc_ether 3-13.1:2.0 usb0: register 'cdc_ether' at usb-0000:00:14.0-13.1, CDC Ethernet Device, 02:1e:10:1f:00:00
where the device number varies and the usb port depends on the used hardware port. I think I simply don't understand how the device is named or mounted to be addressed with modprobe.
The relevant information of lsusb
is Bus 003 Device 028: ID 12d1:15c1 Huawei Technologies Co., Ltd.
and lsusb -t
delivers
/: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/15p, 480M
|__ Port 12: Dev 11, If 0, Class=Hub, Driver=hub/4p, 480M
|__ Port 3: Dev 14, If 1, Class=Human Interface Device, Driver=, 1.5M
|__ Port 3: Dev 14, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
|__ Port 1: Dev 64, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
|__ Port 2: Dev 13, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
|__ Port 2: Dev 13, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
|__ Port 13: Dev 3, If 0, Class=Hub, Driver=hub/4p, 480M
|__ Port 14: Dev 29, If 0, Class=Communications, Driver=cdc_ether, 480M
|__ Port 14: Dev 29, If 1, Class=CDC Data, Driver=cdc_ether, 480M
|__ Port 14: Dev 29, If 2, Class=Vendor Specific Class, Driver=option, 480M
|__ Port 14: Dev 29, If 3, Class=Vendor Specific Class, Driver=option, 480M
|__ Port 14: Dev 29, If 4, Class=Vendor Specific Class, Driver=option, 480M
|__ Port 14: Dev 29, If 5, Class=Vendor Specific Class, Driver=option, 480M
|__ Port 14: Dev 29, If 6, Class=Vendor Specific Class, Driver=option, 480M
Thank you very much for your help.
Here is the full dmesg
output:
[748010.825136] usb 3-13.1: new high-speed USB device number 79 using xhci_hcd
[748010.926143] usb 3-13.1: New USB device found, idVendor=12d1, idProduct=15c1
[748010.926146] usb 3-13.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[748010.926147] usb 3-13.1: Product: HUAWEI Mobile
[748010.926148] usb 3-13.1: Manufacturer: Huawei Technologies Co., Ltd.
[748010.926149] usb 3-13.1: SerialNumber: 0123456789ABCDEF
[748010.929581] cdc_ether 3-13.1:2.0 usb0: register 'cdc_ether' at usb-0000:00:14.0-13.1, CDC Ethernet Device, 02:1e:10:1f:00:00
[748010.930008] option 3-13.1:2.2: GSM modem (1-port) converter detected
[748010.930178] usb 3-13.1: GSM modem (1-port) converter now attached to ttyUSB0
[748010.930451] option 3-13.1:2.3: GSM modem (1-port) converter detected
[748010.930588] usb 3-13.1: GSM modem (1-port) converter now attached to ttyUSB1
[748010.930829] option 3-13.1:2.4: GSM modem (1-port) converter detected
[748010.930929] usb 3-13.1: GSM modem (1-port) converter now attached to ttyUSB2
[748010.931153] option 3-13.1:2.5: GSM modem (1-port) converter detected
[748010.931254] usb 3-13.1: GSM modem (1-port) converter now attached to ttyUSB3
[748010.931474] option 3-13.1:2.6: GSM modem (1-port) converter detected
[748010.931580] usb 3-13.1: GSM modem (1-port) converter now attached to ttyUSB4
[748010.959172] cdc_ether 3-13.1:2.0 enp0s20u13u1c2: renamed from usb0
[748010.986087] IPv6: ADDRCONF(NETDEV_UP): enp0s20u13u1c2: link is not ready
[748010.986238] cdc_ether 3-13.1:2.0 enp0s20u13u1c2: kevent 12 may have been dropped
[748010.990538] IPv6: ADDRCONF(NETDEV_UP): enp0s20u13u1c2: link is not ready
The full output of tree /sys/devices/pci0000:00/0000:00:14.0/usb3/3-13/ | grep driver
is:
│ │ ├── driver -> ../../../../../../../bus/usb/drivers/cdc_ether
│ │ ├── driver -> ../../../../../../../bus/usb/drivers/cdc_ether
│ │ ├── driver -> ../../../../../../../bus/usb/drivers/option
│ │ │ ├── driver -> ../../../../../../../../bus/usb-serial/drivers/option1
│ │ ├── driver -> ../../../../../../../bus/usb/drivers/option
│ │ │ ├── driver -> ../../../../../../../../bus/usb-serial/drivers/option1
│ │ ├── driver -> ../../../../../../../bus/usb/drivers/option
│ │ │ ├── driver -> ../../../../../../../../bus/usb-serial/drivers/option1
│ │ ├── driver -> ../../../../../../../bus/usb/drivers/option
│ │ │ ├── driver -> ../../../../../../../../bus/usb-serial/drivers/option1
│ │ ├── driver -> ../../../../../../../bus/usb/drivers/option
│ │ │ ├── driver -> ../../../../../../../../bus/usb-serial/drivers/option1
│ ├── driver -> ../../../../../../bus/usb/drivers/usb
│ ├── driver -> ../../../../../../bus/usb/drivers/hub
├── driver -> ../../../../../bus/usb/drivers/usb
As far as I know
modprobe
is used to add/remove modules / drivers. With the commandmodprobe -r -f uhci_hcd
you are trying to remove a module built in the kernel see this post on Unix & Linux.If you want to deactivate your USB device and than reactivate it, have a look at his posting here: Disconnect and reconnect USB post via CLI.
Or try the much easier way here: Is there a way to power down a USB device using software?.
Some useful information can be found on this kernel.org page on power management. under USB Port Power Control and below that at User Interface for Port Power Control.
I am running Lubuntu 16.04. My USB device for testing was a 8GB USB stick.
First of all open a terminal and type
dmesg -w
. Next, plug in your USB device.Here we can see that a new
ehci-pci
device atusb 2-2
has been recognized. After a few linesusb 2-2
changes tousb-storage 2-2:1.0
toscsi 22:0:0:0
and finally tosd 22:0:0:0
What these numbers exactly mean is beyond my knowledge. It has something to do with the USB-Port, but that is not everything. At least it is an identifier.Anyway, now we go for the
/sys/
folder. Somewhere inside/sys/
we will find the driver that is responsible for our usb device. We want tounbind
our device from that driver. Therefore we need to find out the path to the driver and itsunbind
command. We are going to use thetree
command.We type
tree /sys/ | grep 22:0:0:0
The very first line is already telling us where to go:
../devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2:1.0/host22/target22:0:0/22:0:0:0/block/sdd
Remember, we are still searching for the
unbind
command somewhere in a driver folder, that is somehow attached to our device. Our device, regarding todmesg
was also called2-2:1.0
, so we use that as parent folder fortree
:Now we have found the path to the driver that is attached to the usb device.
So let's
ls /sys/bus/usb/drivers/usb-storage/
Now we have all the information we need, so we type the following:
and right after that, because you wanted the reconnect effect:
Output of
dmesg -w
:I hope this will help you to find a solution.
If you want to read more about the topic: https://lwn.net/Articles/143397/