Using The T-Mobile 3G USB Stick Under Linux

Mobile broadband with a small USB stick.

Background

This page is an update to my earlier pages on 3G under Linux.

As the first 12 months of my T-Mobile contract had finished, in March 2008 I was able to upgrade free of charge to a new USB stick 3G device. The one supplied by T-Mobile UK is a little larger than a USB memory stick. It is black and pink with T-Mobile branding, but it is really a HUAWEI E220 device, made in China. Somewhat annoyingly it is locked to T-Mobile UK SIM cards.

Compared to the old Cardbus PCMCIA card, the USB stick is much easier to set up under Windows and MacOsX, as it doubles as a read-only memory stick containing the setup programs for Windows and MacOsX, which are mercifully smaller and less fiddly than the ones shipped with the device I'd used earlier. So, under Windows and MacOsX, the device is really quick to set up: just plug in the stick and let the autorun programs do their job. Really very handy if a colleague wants to borrow your 3G to quickly look something up on the web.

Inserting the 3G USB stick into my Dell D620 laptop running Linux (Kubuntu/Ubuntu Feisty Fawn), there was a little more fiddling to do, as detailed below. Basically in most cases it should just work (the thing is autodetected as a USB serial port), but in my case there was a small amount of messing required in order to avoid a clash with a built-in 3G card that I didn't want to use.

Costs

By agreeing to a 24-month contract, the cost (for up to 3 GB per month) comes down to 15 pounds per month (or half that if you are lucky enough to know someone who can give you a friends and family employee discount).

Getting 3G working Under Linux

Note for Ubuntu 7.10 "Gutsy Gibbon" Linux (tested on a Thinkpad T41): You need to enter the following commands after plugging in the USB stick, in order for /dev/ttyUSB0 and /dev/ttyUSB1 to be created:

	sudo modprobe -r uhci_hcd
	sudo modprobe uhci_hcd

The remainder of these notes apply to Kubuntu/Ubuntu 7.04 "Feisty Fawn" Linux on a Dell Latitude D620. Your mileage may vary on other Linux versions on other hardware.

Plug in the 3G USB stick and you should see this:-

	cat /proc/bus/usb/devices	!! This command does not work on Gutsy Gibbon !!
	...
	P:  Vendor=12d1 ProdID=1003 Rev= 0.00
	S:  Manufacturer=HUAWEI Technologies
	S:  Product=HUAWEI Mobile

Similarly if you run 'sudo lsusb' you should see (even on Gutsy):

	Bus 004 Device 024: ID 12d1:1003

Now, on my machine, there was already an internal 3G modem that I no longer wished to use, as I wanted to keep the SIM card in the USB stick for portability. But the effect of the internal modem was to autoload the 'option' kernel module, which in turn would autoload the 'usbserial' module with the wrong parameters, creating a /dev/ttyUSB0 device pointing to the wrong hardware. Your mileage may vary, but on my machine the solution was as follows...

1. Edit /etc/modprobe.d/blacklist and add a line saying:

	blacklist option
to stop the kernel module loading for the old hardware made by Option Inc.

2. Create /etc/modprobe.d/usb3g containing this line:

	install usb3g modprobe usbserial vendor=0x12d1 product=0x1003
This creates a placeholder called 'usb3g' which is a shorthand for loading the usbserial module with the right arguments.

Now, to test this by hand... Execute the following commands as root..

	rmmod option
	rmmod usbserial
	modprobe usb3g
This unloads the old option 3G module and the usbserial module from the kernel memory, then it loads the usbserial module with the right parameters (just a shorthand for 'modprobe usbserial vendor=0x413c product=0x8116'). If you type ls -l /dev/ttyU* you should now see:-
	crw-rw---- 1 root dialout 188, 0 2008-03-07 21:40 /dev/ttyUSB0
	crw-rw---- 1 root dialout 188, 1 2008-03-07 21:40 /dev/ttyUSB1
	crw-rw---- 1 root dialout 188, 2 2008-03-07 21:40 /dev/ttyUSB2

In order to connect to the Internet, we just need to invoke 'kppp' and tell it to dial '*99#' using device /dev/ttyUSB0 (see below).

The fiddly bit was getting the three /dev/ttyUSB devices created correctly each time. You will probably find that it will be simpler on your machine: you can probably just add the line 'usb3g' to /etc/modules (to get the module loaded correctly at boot time). In my case that didn't work, because it was too late when that happened: the usbserial module had already been loaded with the wrong parameters (for my old modem I think), so the /dev/ttyUSB0 entry pointed to the wrong device. So I frigged it using a combination of /etc/sudoers and the KPPP pre-flight command execution option as detailed below....

Using 3G with KPPP

Using the KPPP utility from the Kubuntu desktop ("K" / "Internet" / "KPPP Internet Dial-Up Tool"), I created a new PPP dialup connection.

Interestingly, there did not seem to be any need to set up the APN, the 'novj' command, or the MTU. So the procedure seems a little simpler than before in some regards.

I hope this helps someone. I would be interested to hear if there is some way to make usbserial load correctly at boot time, to avoid the need to unload it and reload it with the right arguments from KPPP, which seems dirty on account of the sudoers hack.