Tuesday, July 24, 2018

Running Huawei E5573 Mobile Wifi Under CentOS (Multimode USB)


Hi there. In this post and next two posts, I will discuss three recent events I had. They are somehow irrelevant (or loosely connected) with each other. This one is about multi mode USB devices. Next one will be about TTL signal voltage levels in LCDs and last one will be about a game. I will discuss configuration of multi mode USB devices here.

The device is Huawei E5573 mobile WiFi access point. It can be used as a WiFi repeater as well as 4G modem by inserting a SIM card. Detailed product information can be found here: https://consumer.huawei.com/lk/support/mobile-broadband/e5573/

Before 2-3 years, I preferred to use my cell phone as a WiFi Hotspot because USB dongles were required to install 3rd party software on my computer. The disadvantage is the disconnection when I receive a call. But only in 3G network has this issue.

Huawei E5573 Wifi Access Point

This device is installed as a network adapter (ethX) upon connection in Linux Mint. This is called USB tethering. This feature can be useful with linux installations without WiFi drivers like minimal CentOS. This can also be used to emulate network adapter with desktop machines without a WiFi adapter. In my case, I had installed CentOS minimal on a desktop machine without a WiFi adapter.

Another feature of this device was, which I did not care about previously, when I plug this device to another USB port or tried to use it with Windows, it was installed as CD driver which contains Windows drivers of itself (ethernet). But I was using it as WiFi access point, so actually I had no need to plug it in my computer (except charging). I noticed the tethering feature by chance and I never needed to use it in Windows. One day, I needed it for the desktop machine, mentioned above, but I could not install it as a network adapter in CentOS.

First, I thought that the tethering drivers are not installed because it was minimal. As I plugged the device to my Linux Mint computer, I saw cdc_ether driver is loaded.
[239053.520493] usb 1-2: new high-speed USB device number 9 using xhci_hcd
[239053.650038] usb 1-2: New USB device found, idVendor=12d1, idProduct=1f01
[239053.650045] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[239053.650048] usb 1-2: Product: HUAWEI_MOBILE
[239053.650051] usb 1-2: Manufacturer: HUAWEI_MOBILE
[239053.650054] usb 1-2: SerialNumber: 0123456789ABCDEF
[239053.734303] usb-storage 1-2:1.0: USB Mass Storage device detected
[239053.734728] scsi host16: usb-storage 1-2:1.0
[239054.738238] scsi 16:0:0:0: CD-ROM            HUAWEI   Mass Storage     2.31 PQ: 0 ANSI: 2
[239054.739637] sr 16:0:0:0: [sr1] scsi-1 drive
[239054.741976] sr 16:0:0:0: Attached scsi CD-ROM sr1
[239054.742188] sr 16:0:0:0: Attached scsi generic sg2 type 5
[239054.811184] systemd-udevd[7829]: Failed to apply ACL on /dev/sr1: No such file or directory
[239054.811195] systemd-udevd[7829]: Failed to apply ACL on /dev/sr1: No such file or directory
[239054.825401] usb 1-2: USB disconnect, device number 9
[239055.264962] usb 1-2: new high-speed USB device number 10 using xhci_hcd
[239055.394110] usb 1-2: New USB device found, idVendor=12d1, idProduct=14db
[239055.394116] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[239055.394119] usb 1-2: Product: HUAWEI_MOBILE
[239055.394122] usb 1-2: Manufacturer: HUAWEI_MOBILE
[239055.547598] cdc_ether 1-2:1.0 eth1: register 'cdc_ether' at usb-0000:00:14.0-2, CDC Ethernet Device, XX:XX:XX:XX:XX:XX
[239055.584282] cdc_ether 1-2:1.0 eth1: kevent 12 may have been dropped
[239055.599362] cdc_ether 1-2:1.0 eth1: kevent 12 may have been dropped

[239055.601286] IPv6: ADDRCONF(NETDEV_UP): eth1: link is not ready
[239055.721397] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
[239055.721411] cdc_ether 1-2:1.0 eth1: kevent 12 may have been dropped


But dmesg output in CentOS is below:



I couldn't see cdc_ether driver in lsmod output above. It is actually normal that I couldn't see because I didn't plug the device. I have manually loaded the driver using modprobe and after that, I plugged the device again however no new interface was created. I searched the driver name in google and checked the links. First result was this link: https://www.linuxquestions.org/questions/linux-networking-3/how-do-i-configure-a-cdc-ethernet-device-a-4g-usb-dongle-835856/ . There, the creator of the topic had same -or very similar- issue as I had and the answer for it was very important. As I learned from this answer, the name of those kind of devices is "USB dual mode" or "multimode" in general. It can contain more than one device class in a single USB connection. More important is the this link to usb_modeswitch utility, in that answer. Under this link, there is an utility to use multimode USB devices under linux.

I have downloaded the application in a different computer, because, I still don't have internet in my desktop yet. I copied what I have downloaded, to an USB disk. libusb1-devel package is required for the compilation. Additionally, I had downloaded libusb-devel, too. usbutils package is also required for the lsusb command. I have downloaded all those packages in the same USB disk, unmounted from the computer and plugged the disk to my desktop, installed prerequisite packages. After that, everything needed is make & make install.

There are two mandatory parameters for usb_modeswitch:
-v vendor ID of original mode (mandatory)
-p product ID of original mode (mandatory)

There are two optional but important parameters, too:
-V target mode vendor ID (optional)
-P target mode product ID (optional)

I found the vendor ID and product ID using lsusb. These IDs will be used in conjunction with -v and -p parameters respectively. As it can be seen in the output below, USB ID of the CD driver is 12d1:1f01:


Instead of that, the output is below in Mint:

Bus 001 Device 010: ID 12d1:14db Huawei Technologies Co., Ltd. E353/E3131.

I saved the dmesg, lsusb and lsusb -v output from Mint, into the text files in the USB disk and returned back to CentOS. I knew, which IDs will be given to -V and -P but I issued the command below and got the following error:

usb_modeswitch -v 12d1 -p 1f01 -V 12d1 -P 14db
[SNIP]
Warning: no switching method given. See documentation.

Segmentation fault.

I checked usb_modeswitch --help output, I noticed three parameters related with Huawei devices: -H, -J and -X. Because there are only three and without any explanation, I decided to use trial and error method. Thus, I found that -J parameter is what I needed. BTW, -V and -P is also not required explicitly. The utility could find the target mode by itself.


It is obvious that the application has some issues due to the "Segmentation fault" error. However the device could now work perfectly as a new ethernet card.