Using Huawei E1550 3G modem in Debian
I use this nice little 3G modem from time to time whenever I'm away from home and work. Here's how it works in Debian.
ZeroCD, modeswitch
First of all, this modem uses the so called ZeroCD mode to facilitate driver installation in Windows. When plugged in, it acts as a USB CDROM, from which the mobile provider-branded Windows software can be installed. The Windows software then performs some special action to put the modem into the actual "modem mode" (in which it even has different USD IDs).
This ZeroCD feature is of course completely unnecessary and even annoying in linux.
When first plugged in, the modem shows up like this:
$ lsusb Bus 003 Device 004: ID 12d1:1446 Huawei Technologies Co., Ltd. E1552 (HSPA modem)
To switch the mode, I used the modem-modeswitch binary that used to be included in the udev package:
$ sudo ./modem-modeswitch --vendor 0x12d1 --product 0x1446 --type option-zerocd
After that, lsusb output changes to
$ lsusb Bus 003 Device 005: ID 12d1:1001 Huawei Technologies Co., Ltd. E620 USB Modem
and the /dev/ttyUSB0
device file is created by udev. This file is used
to communicate with the modem.
Apparently, instead of the deprecated modem-modeswitch from udev, the usb-modeswitch Debian package can be installed in order to automatically switch the device into the modem mode every time it is plugged in, but I never used it. I opted for disabling ZeroCD altogether.
Disabling ZeroCD
Since I didn't plan to use this modem in Windows, I wanted to disable the ZeroCD feature completely. It is possible to change the default state of the device using the following AT commands (found here):
AT^U2DIAG=0 -- modem AT^U2DIAG=1 -- modem + CD-ROM AT^U2DIAG=255 -- modem + CD-ROM + Card Reader AT^U2DIAG=256 -- modem + Card Reader
AT commands can be entered interactively using your favorite serial communication program, for instance picocom:
$ picocom /dev/ttyUSB0
I chose the value 256 to be able to use both the modem and the built-in microSD card reader. Once the command is entered, no mode switching is necessary any more.
Entering PIN
I prefer to leave my SIM-card PIN-locked. I use the following udev rule to run the script that automatically unlocks the card every time I plug the modem in:
$ cat /etc/udev/rules.d/45-huawei1550.rules SUBSYSTEM=="usb", ACTION=="add", ATTR{idProduct}=="1001", ATTR{idVendor}=="12d1", RUN+="/usr/local/sbin/modem-pin.sh"
Here is the content of the /usr/local/sbin/modem-pin.sh
script:
Once the modem is plugged in and the SIM card is unlocked, we're ready
to connect.
pppd one-liner
The connection can be established with a single command, no need to edit any config files. Change APN name ("internet") and phone number ("*99#") to the ones appropriate for your provider:
$ /usr/sbin/pppd connect "/usr/sbin/chat -v ECHO ON '' AT+CGDCONT=1,\\\"IP\\\",\\\"internet\\\" OK ATDT*99# CONNECT" /dev/ttyUSB0 nodetach usepeerdns defaultroute noipdefault noauth
I found this one-liner to be great for debugging.
Permanent pppd and chat configuration
The last step is to put pppd and chat configuration into static files. It is pretty straightforward and I'll leave it as an excercise for the reader :).