Markus Wernig

UNIX/Network Security Engineer
CCSA, CCSE
CISSP


PGP key transition note
GPG Key
 (in use after Aug. 9 2013)

old GPG Key
 (in use up to Aug. 9 2013)

Personal | Professional | IT related | Writings de

How to connect a cell phone via USB to a Linux laptop
and dial-up an internet connection

NOTE: I have a Siemens M65 cell phone, but I suppose the methods won't differ too much for other models.
For hints about Linux on my laptop model see:Linux on the HP Pavilion ze4300.

Hardware involved:
HP Pavilion ze4300
Siemens M65
Siemens Data Cable USB DCA-540

Software:
Linux Gentoo, Kernel 2.6.10
Siemens firmware:
Product: M65
P-Date: 2004-12-01
SW-Version: 16
Baseline: kzdb4#main_1.0_V119.8
FFS-Version: M65_2_xx-FFS-LG01_16_0259
Variant: A 115

Protocols
CSD (GSM)
GPRS

1) Get a cell phone with an internal modem (most have one today, because of GPRS, I think). Mine was the Siemens M65, as described above.

2) First, before purchasing the USB cable, I took my laptop to the shop and asked if I could connect my cellphone to my laptop with the cable before actually bying it.
The relevant output from "lsmod" regarding the USB subsystem at that point was:

# lsmod
[...]
usb_storage           101264  0
uhci_hcd               33420  0
ohci_hcd               34952  0
usbcore 	      129784  4 usb_storage,uhci_hcd,ohci_hcd
[...]

When I attached the phone, the device was recognized:

Feb  9 17:29:31 blue kernel: usb 1-2: new full speed USB device using ohci_hcd and address 2
Feb  9 17:29:31 blue kernel: usb 1-2: Product: Siemens USB Connectivity
Feb  9 17:29:31 blue kernel: usb 1-2: Manufacturer: Siemens AG
Feb  9 17:29:31 blue kernel: usb 1-2: SerialNumber:  353669000550637

I then decided, that it's worth the risk, and bought the cable.

3) Then came Google time.

The two pages that helped me most were:

http://www.peerfear.org/rss/permalink/2004/11/30/WirelessIPWithSprintUSBAndKernel26/

and

http://www.linuxformat.co.uk/modules.php?op=modload&name=phpBB_14&file=index&action=viewtopic&topic=9210&forum=1&6

For the GPRS connection I found the following discussion very helpful (Long live public mailing list archives!):
http://www.webservertalk.com/archive216-2004-4-189602.html

4) What it all boils down to, is:

Prepare your kernel carefully. As I always do, I compiled all the necessary options as modules (for better control and adaptability). You can probably as well just compile it into the kernel, if you like.
Besides the standard, I needed the following options:

Device Drivers -> Networking Support -> Network Device Support

CONFIG_PPP=m
# CONFIG_PPP_MULTILINK is not set
CONFIG_PPP_FILTER=y
CONFIG_PPP_ASYNC=m
CONFIG_PPP_SYNC_TTY=m
CONFIG_PPP_DEFLATE=m
CONFIG_PPP_BSDCOMP=m
# CONFIG_PPPOE is not set

Device Drivers -> USB support
You definitely don't need all of those, but not knowing what your hardware is (as is likely with a cell phone internal usb modem ;-), you might first try to build all modules and let the autoloader figure out which one to use, then disable the rest in a second kernel build.

You will definitely need at least (well, if you have my hardware, anyway):

CONFIG_USB=m
CONFIG_USB_ARCH_HAS_HCD=y
CONFIG_USB_ARCH_HAS_OHCI=y
CONFIG_USB_OHCI_HCD=m
CONFIG_USB_UHCI_HCD=m
(depending on your usb hardware)
CONFIG_USB_ACM=m (I didn't need it, but that's likely to be an exception)
CONFIG_USB_SERIAL=m
CONFIG_USB_SERIAL_GENERIC=y
CONFIG_USB_SERIAL_PL2303=m
(remember that your modem/cable combination could require another option!)

I'm not sure about the following
# USB Host-to-Host Cables
CONFIG_USB_ALI_M5632=y
CONFIG_USB_AN2720=y
CONFIG_USB_BELKIN=y
CONFIG_USB_GENESYS=y
CONFIG_USB_NET1080=y
CONFIG_USB_PL2301=y
CONFIG_USB_KC2190=y

You also need a module called "slhc", for which I can't find the config option at the moment.

Compile, install and reboot if necessary.

5) Now what remains is to load the modules and configure a dialer.
NOTE: Since I couldn't get it to work properly with wvdial, I used kppp, which works fine, although I don't see the difference in the configuration.

modprobe cdc-acm
modprobe usbserial
modprobe pl2303

Now attach the phone with the USB cable to your computer.
You should see the kernel registering the necessary devices.

Feb  9 21:03:25 blue kernel: drivers/usb/serial/usb-serial.c: USB Serial support registered for Generic
Feb  9 21:03:25 blue kernel: usbcore: registered new driver usbserial_generic
Feb  9 21:03:25 blue kernel: usbcore: registered new driver usbserial
Feb  9 21:03:25 blue kernel: drivers/usb/serial/usb-serial.c: USB Serial Driver core v2.0
Feb  9 21:03:44 blue kernel: usb 1-2: new full speed USB device using ohci_hcd and address 2
Feb  9 21:03:44 blue kernel: usb 1-2: Product: Siemens USB Connectivity
Feb  9 21:03:44 blue kernel: usb 1-2: Manufacturer: Siemens AG
Feb  9 21:03:44 blue kernel: usb 1-2: SerialNumber:  353669000550637
Feb  9 21:03:45 blue kernel: drivers/usb/serial/usb-serial.c: USB Serial support registered for PL-2303
Feb  9 21:03:45 blue kernel: pl2303 1-2:1.0: PL-2303 converter detected
Feb  9 21:03:45 blue kernel: usb 1-2: PL-2303 converter now attached to ttyUSB0
Feb  9 21:03:45 blue kernel: usbcore: registered new driver pl2303
Feb  9 21:03:45 blue kernel: drivers/usb/serial/pl2303.c: Prolific PL2303 USB to serial adaptor driver v0.12

You should now have /dev/ttyUSB0 (or /dev/usb/tts/0 under devfs). This is your serial line modem. Use any dialer on it you want to.

Add "noauth" to /etc/ppp/options, as your provider will most likely not authenticate to you. If you are a pppd expert, besides probably not needing this tutorial, you can configure pppd in /etc/ppp to your heart's content. In my case kppp does all that magic for me on the fly when dialling. You would probably want to add "defaultroute" and "usepeerdns" to the options file.

Note for GPRS
In order to use the faster (and sometimes cheaper) GPRS, you will need to change a few settings in your dialer configuration. The basic modules and stuff remain the same. I still didn't get wvdial to play along, but in the meantime added pppd itself to the list of working dialers. Here's how:

First (for convenience only) I made a link from /dev/usb/tts/0 to /dev/gprsmodem:

# ln -s /dev/usb/tts/0 /dev/gprsmodem

Then created the file /etc/ppp/peers/gprs with the following content:

user USER
password PASSWORD
defaultroute
/dev/gprsmodem
connect "/usr/sbin/chat -v -f /etc/ppp/gprsmodem.chat"
debug
kdebug 4
ipcp-no-addresses
noipdefault
noauth
novj
noccp

Please note that the option "usepeerdns" MUST NOT be set. You need to create a file "/etc/ppp/resolv.conf" instead with a set of valid nameservers. In my case it reads:

nameserver 213.55.128.1
nameserver 213.55.128.2

The "ipcp-no-addresses" and "noipdefault" options tell pppd not to consider the local machine's IP configuration when negotiating with the other side. Orange's dial-up PPP server is very picky when it comes to what it expects you to send after authenticating. Anything else than "[IPCP ConfReq id=0x1 <addr 0.0.0.0>]" will result in a negotiation timeout.

In /etc/ppp/gprsmodem.chat there's:

'ABORT' 'BUSY'
'ABORT' 'ERROR'
'ABORT' 'NO ANSWER'
'ABORT' 'NO CARRIER'
'ABORT' 'NO DIALTONE'
'ABORT' 'Invalid Login'
'ABORT' 'Login incorrect'
'' 'ATZ'
'TIMEOUT' '10'
'OK' 'ATM1L1'
'OK' 'AT&f+cgdcont=1,"IP","internet","",0,0'
'OK' 'ATDT*99***1#'
'CONNECT' ''

(The parameters are quite public, part of it is on the homepage, part of it you get from customer support. Those settings are for Orange, I don't know if they work with other providers. I think you need a special contract ("Express") to use GPRS.)

Note: Please see Pieter de Preez' notes on getting this to work on 64bit Debian et al. It contains further valuable tips an links.

When using pppd as a dialer, you can now call

# pppd call gprs

Watch /var/log/messages (and on Gentoo /var/log/daemon.log) for progress.

The configuration for kppp is similar.
Create a new account. Add the pppd options from /etc/ppp/peers/gprs under "Customize pppd Arguments". Authentication PAP/CHAP, Number *99***1#. Set DNS configuration to "Manual" and add your namesevers.
Add a new modem on /dev/usb/tts/0. In the "Modem Commands" section, set the "Initialization string 2" to AT&f+cgdcont=1,"IP","internet","",0,0.

This should do, you're set. Your system log should tell you more:

Feb  9 22:23:50 blue net.agent[11720]: add called for ppp0
Feb  9 22:23:51 blue kernel: PPP BSD Compression module registered
Feb  9 22:23:52 blue kernel: PPP Deflate Compression module registered

Starting pppd (either by hand or automatically from your dialler) will load some more modules.

# lsmod
[...]
pl2303                 20356  0
usbserial              30312  1 pl2303
ppp_deflate             6272  0
zlib_deflate           22808  1 ppp_deflate
zlib_inflate           18304  1 ppp_deflate
bsd_comp                6144  0
ppp_async              11776  0
ppp_generic            27284  3 ppp_deflate,bsd_comp,ppp_async
slhc                    7680  1 ppp_generic
[...]
usb_storage           101264  0
uhci_hcd               33420  0
ohci_hcd               34952  0
usbcore               129784  6 pl2303,usbserial,usb_storage,uhci_hcd,ohci_hcd

Note on CSD (GSM)
Now all you need is a provider that will accept your data call. I use Orange here in Switzerland (see http://www.orange.ch/pricesservices/services/dataAccess/webOrange?ts=1107956611879), and no registration is needed. Dial-up numbers, username and password are also on the above website. Beware! The fees on the site are charged in addition to normal connection fees!

Markus Wernig


Markus Wernig

webmaster wernig net