Friday 31 July 2009

Huawei E1550 on Debian

If you want to get the Huawei E1550 USB modem working with linux, here's what you need to do, with specific instructions for those on Debian.

modem-modeswitch


This utility is part of udev as of version 145. You need it because the E1550 has a clever double-identity: when you insert it at first, it masquerades as a mass storage device (usb id 12D1:1446). Upon running this magical command, it disconnects and reappears as an "E620 USB modem" (usb id 12D1:1001). Magic eh?

Firstly, you need to get the program. If you have udev 145, life is good. Unfortunately, the current debian unstable package is on version 141, which doesn't have it. Trying to manually install udev 145, I managed to break my X setup quite spectacularly, so I don't advise that. Fortunately, if you download the latest udev source (from
http://www.kernel.org/pub/linux/utils/kernel/hotplug/) and compile it, you'll find that the binary in the extras/modem-modeswitch directory works fine without the rest of udev 145. Note that to compile udev, you'll need some libraries. On debian, an incantation like apt-get build-dep udev should get them. To put it somewhere useful, one option is to run checkinstall from inside the extras/modem-modeswitch
directory and make a fake debian package for the meantime.

Now you've got modem-modeswitch installed, you want to try it! Pull up a spare terminal window and run something like sudo tail -f /var/log/syslog in it. This lets you know what's going on, since drivers tend to report stuff there when they initialise
themselves. Now run the following command /path/to/modem-modeswitch -v 0x12d1 -p 0x1446 -t option-zerocd. On my dongle (courtesy of 3), there's a green LED that flashes at first and then turns blue at this point. In any case, the syslog window should report a USB disconnect and then a new device. Running lsusb should show a line something like Bus 002 Device 003: ID 12d1:1001 Huawei Technologies Co., Ltd. E620 USB Modem (the first two numbers will probably be different: they're
just to say where it's connected).

If you've got this far, the confusing bit's over. Unplug the device again and we'll set things up to run modem-modeswitch by default.

udev


To do so, we need to create a udev rule to tell it to run when the device is plugged in. Create a file in /etc/udev/rules.d/ called something like 50-huawei1550.rules containing the following line

SUBSYSTEM=="usb", SYSFS{idProduct}=="1446",SYSFS{idVendor}=="12d1", RUN+="/usr/libexec/modem-modeswitch --vendor 0x12d1 --product 0x1446 --type option-zerocd"

This tells udev that when a device with USB id 12d1:1446 gets plugged in, it should run modem-modeswitch to change its mode. (This snippet came from somewhere on the web, but I've lost the reference). You probably need to restart udev here (/etc/init.d/udev restart) to enable your rule. Re-insert the device and cross your fingers... if everything works, it should change mode.


usb-serial

If you're using a distro kernel, you can probably ignore this, but I was running a home-built kernel which didn't have the usb-serial kernel module. You need it.

If you've got stuff right, lines like the following should appear in your syslog:

Jul 31 10:49:03 hake kernel: usbcore: registered new interface driver usbserial
Jul 31 10:49:03 hake kernel: USB Serial support registered for generic
Jul 31 10:49:03 hake kernel: usbcore: registered new interface driver usbserial_generic
Jul 31 10:49:03 hake kernel: usbserial: USB Serial Driver core
Jul 31 10:49:03 hake kernel: USB Serial support registered for GSM modem (1-port)
Jul 31 10:49:03 hake kernel: option 2-2:1.0: GSM modem (1-port) converter detected
Jul 31 10:49:03 hake kernel: usb 2-2: GSM modem (1-port) converter now attached to ttyUSB0
Jul 31 10:49:03 hake kernel: option 2-2:1.1: GSM modem (1-port) converter detected
Jul 31 10:49:03 hake kernel: usb 2-2: GSM modem (1-port) converter now attached to ttyUSB1
Jul 31 10:49:03 hake kernel: option 2-2:1.2: GSM modem (1-port) converter detected
Jul 31 10:49:03 hake kernel: usb 2-2: GSM modem (1-port) converter now attached to ttyUSB2
Jul 31 10:49:03 hake kernel: usbcore: registered new interface driver option
Jul 31 10:49:03 hake kernel: option: v0.7.2:USB Driver for GSM modems

No comments: