Installing Vodafone 3G Datacards under Linux

Author:  David Cottingham

The following is a terse description of how to install a Vodafone 3G (UMTS and GPRS) or 3G Broadband (HSDPA) datacard on Suse 9.3 or Gentoo Linux.
For information on how to send SMSs with this card, see the SMS sending Howto.

Drivers for 3G Broadband (HSDPA)

  • This is remarkably painless! Just download Paul Hardwick's Nozomi drivers. Then...
  • tar -xzvf nozomi.tar.gz
  • make
  • mkdir /lib/modules/`uname -r`/kernel/drivers/pci/ (if it does not already exist)
  • mkdir /lib/modules/`uname -r`/kernel/drivers/pci/hotplug/ (if it does not already exist)
  • cp nozomi.ko /lib/modules/`uname -r`/kernel/drivers/pci/hotplug/
  • depmod
  • modprobe nozomi
  • The only problem I had was that the drivers did not compile for the Gentoo 2.6.12-suspend-r6 (?) kernel. This appears to be because nozomi.c calls a function defined in workqueue.c of the kernel called create_singlethread_workqueue(). In the suspend-2 kernel it requires two arguments, whereas in the other Gentoo kernel we used, it does not. The solution is to edit the call in nozomi.c to be create_singlethread_workqueue(NOZOMI_NAME,0) (line 1576), which supplies zero flags to the function.

Drivers for 3G (UMTS/GPRS)

  • Ensure that you have the Linux PCMCIA drivers installed, and that they appear to be working (try cardctl status).
  • Plug in the 3G datacard. If you run dmesg you should find notifications of a USB hub being installed. tail -n 30 /var/log/messages will also tell you similar helpful things, including what ports the hub has been assigned to.
  • The card has two lights, one blue light for UMTS (3G) connectivity, and a green one for GPRS connectivity. On insertion the lights both blink for a while, (showing that the card is scanning for a network), and then they settle down to blinking about twice a second. Each indicates whether there is coverage of its respective network type.
  • If you now run cardctl status you should find that one of the sockets shows that has a card inserted. If it doesn't there is something wrong with your PCMCIA setup.
  • Execute cat /proc/bus/usb/devices to see what devices you have that are USB. One of them should be the Vodafone card. The first time I did this my machine locked up, but after restarting it was fine.
  • If the Vodafone card does not appear, check that you have USB OHCI support compiled into your kernel. If you do, you should see lines in /var/log/messages detailing that OHCI has found a USB hub.
  • Under Suse: Edit /etc/modprobe.conf.local and add the line options usbserial vendor=0xaf0 product=0x5000 .
    Under Gentoo: Make a new file called /etc/modules.d/vodafone and put the line options usbserial vendor=0xaf0 product=0x5000 in it. Then run modules-update. Check that the insertion has been successful by using grep -i usbserial /etc/modprobe.conf .
    After a reboot (?) /var/log/messages should now inform you which USB ports the card is on.
  • If (by the end of this guide) pppd complains (in /var/log/messages - it's silent on the command line), that /dev/ttyUSB0 (or /dev/modem) is not a valid serial device, you need to make sure that you have USB serial support compiled into the kernel. Try modprobe usbserial. If this fails, you need to compile that in (as a module is fine). If on insertion it complains that "vendor" is an unrecognised option to the module, you haven't compiled the module with the optional support for Generic serial devices. When I reached this point I also compiled in a load of other USB EHCI/OHCI related stuff, so if all else fails try compiling that in too, however, I suspect that the Generic serial device is the key here.
  • If you get an error in dmesg along the lines of kobject_register failed for usbserial (-17), make certain that you have not only done make; make modules_install but also make install for your kernel (to get it into /boot where your bootloader expects it), as otherwise you will be attempting to insert modules that your kernel has not got support for, because the kernel you are booting is still the old one!
  • Check that the ports exist using ls /dev/ttyUSB*. Add them if they do not (see Paul Hardwick's page).
  • The card is likely to be on USB ports /dev/ttyUSB0, /dev/ttyUSB1, and /dev/ttyUSB2. USB0 is used for actual data transfers, and USB2 for things like network queries or SMS while a connection on USB0 can be maintained. You may therefore want to alias /dev/modem to /dev/ttyUSB0 so that the standard dialup programmes work (ln -sf /dev/ttyUSB0 /dev/modem).
  • At this point some other guides tell you to restart: I don't see why, but do so if things don't work!

Using the modem with pppd

  • I couldn't get wvdial to work, (it complained that it couldn't get modem information from /dev/modem). I therefore fell back to pppd.
  • I set up the following files (the first is entirely from Paul Hardwick's page). Bear in mind that the second file could be cut down significantly, and simply illustrates the available commands. We use the card for some research that involves measuring signal strengths, as well as occasionally obtaining network lists. You are unlikely to want this if you just want an Internet connection! You may find GCOM useful for performing operations like setting the PIN.

    /etc/ppp/peers/vodafone:

    ###########################################
    #Suggested Vodafone PPPD configuration file
    #File /etc/ppp/peers/vodafone
    ###########################################
    #Set this to the device allocated to the Datacard
    /dev/modem
    #Baudrate
    384000
    #Idle time for closing connection
    idle   7200
    #Lock the device for this PPPD process use only
    lock
    #Use normal handshaking
    crtscts
    #Assume it is a modem device and force modem control methods
    modem
    #Any user can start the connection
    noauth
    #If a default route exists replace it with the ppp link
    #You get an error if this command is not supported
    #by your version of PPPD
    replacedefaultroute
    #Make the ppp link the default root
    defaultroute
    #Username and Password for computer/GlobeTrotter ppp link
    #Normally ignored. Change if GSM Operator requires it
    user               Anyname
    password           Anypassword
    #Change the path to chat if required for your version of Linux
    connect "/usr/sbin/chat -V -f /etc/ppp/vodafone-chat"
    #Accept IP address provided by network
    noipdefault
    #Detach PPPD from console used to run the program {optional}
    #updetach
    #Get DNS addresses from operator
    usepeerdns
    #Don't use VJ compression for ppp link
    novj
    ###########################################
    ###########################################
    
    
    /etc/ppp/vodafone-chat

    ###########################################
    # Suggested chat script called by PPPD
    # File: /etc/ppp/vodafone-chat
    # Heavily edited by David Cottingham
    # Many of these commands you will not need: they are for illustration
    # Comment them out as necessary. 
    # david [=at=] cottinghams.com 21/06/2005
    # See http://www.pharscape.org/index.php?option=content&task=view&id=29
    ###########################################
    ABORT BUSY 
    ABORT 'NO CARRIER'
    ABORT ERROR
    REPORT CONNECT
    TIMEOUT 120
    "" "AT&F"
    OK "ATE1" 
    # Is there a PIN set on the SIM? 
    #OK "AT+CPIN?"
    # What network are we connected to?
    OK "AT+COPS?"
    # Next line can be used to get a full list of available
    # networks, but it takes a long time!
    #OK "AT+COPS=?"
    # List what AT commands we can issue to this card.
    #OK "AT&V;"
    # Prefer UMTS networks over GPRS networks
    # (but connect to GPRS if UMTS unavailable)
    OK "AT_OPSYS=3"
    # Current network signal strength
    OK "AT+CSQ"
    # Note the single quotes at the beginning and end,
    # reversing the quoting (double at ends, single
    # inside) does NOT work!
    OK 'AT+CGDCONT=1,"IP","internet"'
    SAY "Calling Vodafone GPRSn"
    TIMEOUT 60
    OK "ATD*99***1#"
    CONNECT c
    ###########################################
    ###########################################
    
  • In partcular, note the AT command that specified the APN to dial ("internet"). This is crucial. AT commands (in my experience; I haven't read anything about them!) need to be quote delimited, but the arguments to them are also quote delimited. The arguments need to be double quoted, while the entire expression is therefore single quote delimited. If you need the APN for a network other than Vodafone UK, see Reqwireless's page on APNs
  • On some distributions (notably Gentoo) you will need to add the line nodetach to the file /etc/ppp/options if you wish to see the output from the AT commands on stdout. Otherwise pppd will be very silent, and you will need to look at /var/log/messages to see whether you have been successful.
  • Having created these files you can then run pppd dump call vodafone, which will give you debug output of all the things that have been set by your chat script, before executing your AT commands. If all is well you will get a connection! One thing to bear in mind is that you should check that a default route has been placed in your routing table by using route to inspect it. If you have another network interface you may find that unplugging it will leave that default route in the table, in which case you will not get any connection on the datacard! Also note that Vodafone appears to block pings, so try a wget http://www.google.com/ instead. Finally, bear in mind that pppd may die if does not recognise the replacedefaultroute command above: comment out as necessary (but find another way of getting the correct route into your routing table, otherwise you won't get any connection!).

Note: network scans (i.e., to see what networks are available, not just Vodafone ones) take quite a long time, during which you will not be able to connect. The AT command for scanning may time out, and pppd will come back with a connection failed message, but the card will continue to be blocked on scanning. Increasing the timeout in your chat file is useful here (I set mine to 120).

Note: I made heavy use of Paul Hardwick's page on the Vodafone 3G card to find out some of the above. Kai Engert's page on Linux and the Vodafone 3G datacard was also very useful.