Installing Huawei E3531 Surf Stick on Linux
May be a valuable insight for more modern surf sticks like Huawei E8231 and the likes ...
Linux is currently Ubuntu, Debian or Raspbian should be similar
This Huawei Surf stick has several USB mode. It appears first as CD-ROM-like device, so that Windows users can install their driver, then switches mode to appear as "something else". By defaut, this is a network card (virtually connected to a router), it can also be a plain old modem or a WWAN card.
Once it has switched mode, it cannot revert to any other mode.
We'll use udev rules to force the surf stick to a specific mode as soon as it is plugged in.
The actual mode switch will be performed by usb_modeswitch, which is available in standard repositories for Debian-like distributions.
The solution described here was found after much documentation gathering in usb_modeswitch home base and its forum.
Content of /etc/udev/rules.d/40-usb_modeswitch.rules
ACTION!="add|change", GOTO="modeswitch_rules_end"
SUBSYSTEM!="usb", ACTION!="add",, GOTO="modeswitch_rules_end"
# Generic entry for most Huawei devices, excluding Android phones
ATTRS{idVendor}=="12d1", ATTRS{manufacturer}!="Android", ATTR{bInterfaceNumber}=="00", ATTR{bInterfaceClass}=="08", RUN+="usb_modeswitch '%b/%k'"
LABEL="modeswitch_rules_end"
Basically, it asks udev to run usb_modeswitch as soon as a Huawei USB device, which is not an Android phone, is plugged into the linux system.
I was used to the lsusb
command to list my devices, but the problem with this kind of devices is that it changes its
productId on the fly. You need to watch your /var/log/kern.log (or use dmesg
) to figure out what the initial productID is.
In my case, I had this line in /var/log/kern.log :
usb 1-1: New USB device found, idVendor=12d1, idProduct=1f01
With that, I can configure usb_modeswitch to react to the insertion of a 12d1:1f01 device.
Content of /etc/usb_modeswitch.d/12d1:1f01
# Huawei E353 (3.se) and others
# Switch from default mass storage device mode 12d1:1f01 to ...
TargetVendor=0x12d1
# WWAN mode 12d1:155e
TargetProduct=0x155e
MessageContent="55534243123456780000000000000011063000000100010000000000000000"
# Broadband modem mode 12d1:1442
#TargetProduct=0x1442
#MessageContent="55534243000000000000000000000011060000000000000000000000000000"
# "ethernet" mode
#TargetProductList="14db,14dc"
#HuaweiNewMode=1
As you can see, several raw USB commands can be sent to the stick, resulting in different behaviours. Once again, check the forums to find out the "magic" numbers.
usb 1-2: New USB device found, idVendor=12d1, idProduct=155e
usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-2: Product: HUAWEI Mobile
usb 1-2: Manufacturer: HUAWEI
option 1-2:1.0: GSM modem (1-port) converter detected
usb 1-2: GSM modem (1-port) converter now attached to ttyUSB0
option 1-2:1.1: GSM modem (1-port) converter detected
usb 1-2: GSM modem (1-port) converter now attached to ttyUSB1
option 1-2:1.2: GSM modem (1-port) converter detected
usb 1-2: GSM modem (1-port) converter now attached to ttyUSB2
cdc_ncm 1-2:1.3: MAC-Address: 00:1e:10:1f:00:00
cdc_ncm 1-2:1.3 wwan0: register 'cdc_ncm' at usb-0000:02:03.0-2, Mobile Broadband Network Device, 00:1e:10:1f:00:00
usbcore: registered new interface driver cdc_ncm
usbcore: registered new interface driver cdc_wdm
usbcore: registered new interface driver cdc_mbim
cdc_ncm 1-2:1.3 wwx001e101f0000: renamed from wwan0
usb 1-2: New USB device found, idVendor=12d1, idProduct=1442
usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-2: Product: HUAWEI Mobile
usb 1-2: Manufacturer: HUAWEI
option 1-2:1.0: GSM modem (1-port) converter detected
usb 1-2: GSM modem (1-port) converter now attached to ttyUSB0
option 1-2:1.1: GSM modem (1-port) converter detected
usb 1-2: GSM modem (1-port) converter now attached to ttyUSB1
The default mode is characterised by those kernel messages :
usb 1-2: New USB device found, idVendor=12d1, idProduct=14dc
usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-2: Product: HUAWEI Mobile
usb 1-2: Manufacturer: HUAWEI
cdc_ether 1-2:1.0 eth0: register 'cdc_ether' at usb-0000:02:03.0-2, CDC Ethernet Device, 00:1e:10:1f:00:00
usb-storage 1-2:1.2: USB Mass Storage device detected
scsi host33: usb-storage 1-2:1.2
cdc_ether 1-2:1.0 enx001e101f0000: renamed from eth0
IPv6: ADDRCONF(NETDEV_UP): enx001e101f0000: link is not ready
IPv6: ADDRCONF(NETDEV_UP): enx001e101f0000: link is not ready
scsi 33:0:0:0: Direct-Access HUAWEI TF CARD Storage 2.31 PQ: 0 ANSI: 2
sd 33:0:0:0: Attached scsi generic sg2 type 0
sd 33:0:0:0: [sdb] Attached SCSI removable disk
IPv6: ADDRCONF(NETDEV_CHANGE): enx001e101f0000: link becomes ready