Probing

This page is part of the 3GNetworkingIntrepid effort.

Contents

Probing your modem

Many modems are internally installed in a laptop, or are rebranded/rebadged devices from other providers. They also vary in terms of their capabilities, many of which can't be discovered from the USB device IDs alone.

This page details some steps you can take to find out more about your modem so the NetworkManager team have more information to work with during testing and development.

Finding the bus type and device identifiers for your modem

If you already know your device's USB product and vendor IDs, you might as well skip this section. If you file a hardware support bug, consider including the output of lsusb -vvv (or an excerpt of it showing the output for the device of interest).

Most cellular modems seem to present a USB interface, even the internal mini-PCI-E and mini-PCI cards. Unless you know your modem isn't a USB device you should start by using `lsusb' to check for your device and, if you find it, get its vendor and device IDs.

Make sure you run update-usbids before you try to find your modem, as more details are always being added to the USB device IDs database.

craig$ sudo /usr/sbin/update-usbids

Now, to find the modem:

craig$ lsusb
Bus 007 Device 003: ID 05a9:7670 OmniVision Technologies, Inc. OV7670 Webcam
Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 004: ID 0421:04f0 Nokia Mobile Phones 
Bus 004 Device 002: ID 04f2:0618 Chicony Electronics Co., Ltd 
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 413c:8138 Dell Computer Corp. Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard EAP-SIM Port
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 007: ID 0a5c:4503 Broadcom Corp. 
Bus 001 Device 006: ID 0a5c:4502 Broadcom Corp. 
Bus 001 Device 005: ID 413c:8126 Dell Computer Corp. Wireless 355 Bluetooth
Bus 001 Device 004: ID 0a5c:4500 Broadcom Corp. 
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

In this case it's pretty clear that the modem is the Dell Computer Corp. Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard EAP-SIM Port with USB ID 413c:8138, ie vendor=0x413c product=0x8138 . However, there's also a Nokia mobile phone that's capable of being used as a modem shown in the list.

In some cases your device will have a less useful name - like, say, Dell. You may be able to find it using lsusb -vvv (run as root).

sudo lsusb -vvv > /tmp/usb_info

There's a lot of information there. What you're looking for is a CDC ACM device category, which most phones and some, but far from all, internal modems provide. The following awk script will search lsusb for you and print some details for anything with CDC ACM interface descriptors:

/^Bus/ {
        curdev = $0;
}
/iManufacturer/ {
        curman = $2
}
/iProduct/ {
        curprod = $2
}
/bInterfaceNumber/ {
        curiface = $2
}
/CDC ACM/ {
        printf "%s iM=%s iP=%s if=%s\n",curdev,curman,curprod,curiface;
}

Save it as searchusb.txt to your Desktop then run:

sudo lsusb -vvv | awk -f ~/Desktop/searchusb.txt

Hopefully you'll see something like:

Bus 004 Device 004: ID 0421:04f0 Nokia Mobile Phones  iM=1 iP=2 if=10
Bus 004 Device 004: ID 0421:04f0 Nokia Mobile Phones  iM=1 iP=2 if=12

which gives you the vendor and product IDs (0421 and 04f0 respectively) as well as a few other handy details.

Note that the Dell built-in modem was not detected, because it doesn't use the standard CDC ACM descriptors. You just have to know what it is, identify it by elimination (ie you know what every other device is), etc. When you're pretty sure you know the vendor and product IDs, try talking to it with the usbserial driver (see the instructions for devices that aren't detected below) and see if it responds sensibly to a probe.

Some devices won't be found by the lsusb command above, but will be known to one of the kernel drivers. In that case you may well be able to see details about the device in the output of dmesg or lshal. Drivers to look out for include airprime and option.

There are also non-USB cellular modems. Some external modems connect to the host using RS232 serial lines, and may not be detected by Linux at all, though you can still probe them using the procedures below if you know which serial port they're connected to. Others appear on the PCI or cardbus interfaces.

If you just can't find your device, make sure you still add it to the 3G hardware table. Submit a bug report that includes (as individual file attachments):

  • the full output of nm-tool

  • the full output of lshal

  • the full output of sudo lsusb -vvv

  • /var/log/syslog

  • /var/log/kern.log

  • the full output of sudo lspci -vvv

  • the full output of sudo pccardctl ident (if you have a PCMCIA, ie "PC Card" bus)

Finding your modem's serial device

To probe your modem, you need to find out your modem's device node. That'll normally be printed in /var/log/kern.log when you plug the modem in, or will appear in dmesg during boot. Common device nodes are /dev/ttyUSB0 and /dev/ttyACM0.

If it doesn't seem to be detected at all and it's a USB device (almost all, even internal modems, are) then try using lsusb to find its vendor and product codes (see above) and load the usbserial module manually. (You can probe a bluetooth modem too with a bit more work - see the end of the document for setup). For example, if lsusb shows:

Bus 002 Device 002: ID 413c:8138 Dell Computer Corp. Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard EAP-SIM Port

the vendor ID is 413c and the device ID is 8138, so I can load the driver with:

sudo modprobe usbserial vendor=0x413c product=0x8138

after which I can access the modem as /dev/ttyUSB0 since I have no other USB serial devices on the system.

Probe script for modem capabilities

Save the following text to a file named 'probe.txt' on your GNOME desktop. This script will be used to probe your modem for its capabilities and a few other details.

REPORT +GCAP:
REPORT +COPS:
REPORT +CREG:

TIMEOUT 2
''
# Change the PIN below to your SIM unlock PIN if you have one.
# If you don't, just leave it at 0000.
ATZ+CPIN="0000"
OK-ATZ-OK
AT+GCAP
+GCAP:
AT+COPS?
+COPS:
AT+CREG?
+CREG:

Probing the modem

Once you know the device node for your modem, execute the following shell command, replacing MODEMDEVICE with the path to the device node:

chat -s -f ~/Desktop/probe.txt >/dev/MODEMDEVICE </dev/MODEMDEVICE

For example, the following shows me probing my my built-in HSDPA modem on /dev/ttyUSB0 then my USB mobile phone on /dev/ttyACM0:

craig$ chat -s -f ~/Desktop/probe.txt >/dev/ttyACM0 </dev/ttyACM0 
chat:  Sep 03 10:40:47 +GCAP: +CGSM,+DS,+W
chat:  Sep 03 10:40:47 +COPS: 0,2,"50501",2
chat:  Sep 03 10:40:47 +CREG: 0,1
craig$ chat -s -f ~/Desktop/probe.txt >/dev/ttyUSB0 </dev/ttyUSB0
chat:  Sep 03 10:40:51 +GCAP: +CGSM,+DS,+ES
chat:  Sep 03 10:40:52 +COPS: 0,0,"Telstra Mobile",2
chat:  Sep 03 10:40:52 +CREG: 0,1

The part of the output you want to include on this wiki page is the bit after +GCAP:, eg +CGSM,+DS,+ES. It'd be helpful if you could post the COPS output, too, eg 0,0,"Telstra Mobile",2.

Getting more hardware details

Lots of GSM/CDMA modems are rebranded. Everything in a Dell machine, for example. You can get hardware details from these modems using gsmctl from the gsm-utils package in universe:

craig$ # My Dell 5520 internal HSDPA modem
craig$ gsmctl -d /dev/ttyUSB0 ME
<ME0>  Manufacturer: Novatel Wireless Incorporated
<ME1>  Model: Expedite EU870D MiniCard
<ME2>  Revision: 10.9.0102.0-00  [2007-07-03 13:50:21]
<ME3>  Serial Number: 351380115216121
craig$
craig$ # My N95-3
craig$ gsmctl -d /dev/ttyACM0 ME
<ME0>  Manufacturer: Nokia
<ME1>  Model: Nokia N95
<ME2>  Revision: V 06wk41v57.1
24-04-08
RM-160
(c) Nokia
<ME3>  Serial Number: 318911111771193

Note: The serial numbers in the above have been replaced with dummies.

If you file a bug with an issue about phone support, consider attaching the output of gsmctl -d /dev/MODEMDEVICE ALL to the bug report (in addition to the output of lshal and the other information requested by the NM team). It might prove handy. Remember to add the device to the 3G hardware table and link to the bug from there if it's not already listed.

Probing bluetooth modems

A bluetooth modem generally works as a virtual serial device over an rfcomm channel. You can probe these much the same way as shown above, but first you need to set up the channel.

To start with, make sure the tools you'll need are installed:

sudo aptitude install bluez-utils ppp

Turn bluetooth on in your phone and set it to be visible to all (discoverable). If it's a dedicated modem not a phone, you might need to press the "connect" or "discover" button instead. It'll also help if you pair your phone/modem and laptop then set the pairing to trusted on the phone/modem so that you're not prompted to approve connections all the time.

Now find its bluetooth MAC address using hcitool scan:

craig$ hcitool scan 
Scanning ...
        00:1D:E9:F5:55:AF       Craig's N95

You can now set your phone/modem back to invisible (not discoverable) mode if you prefer to. We'll be talking to it directly from now on, so bluetooth must be on but does not need to be discoverable.

Use sdptool to discover the rfcomm port for DUN (dial-up networking) communication:

craig$ sdptool search --bdaddr 00:1D:E9:F5:55:AF DUN
Searching for DUN on 00:1D:E9:F5:55:AF ...
Service Name: Dial-Up Networking
Service RecHandle: 0x1001f
Service Class ID List:
  "Dialup Networking" (0x1103)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 4
Language Base Attr List:
  code_ISO639: 0x454e
  encoding:    0x6a
  base_offset: 0x100
Profile Descriptor List:
  "Dialup Networking" (0x1103)
    Version: 0x0100

The RFCOMM channel we need is 4, as shown on the line below RFCOMM in the output above. Note that this often varies; some phones change RFCOMM DUN channels when rebooted, for example.

We now know enough to set up an RFCOMM binding we can use to talk to the modem. Specify your device's bluetooth MAC address and its RFCOMM channel (the last argument to rfcomm) in place of mine when you run the command below:

craig$ sudo rfcomm bind /dev/rfcomm0 00:1D:E9:F5:55:AF 4
craig$

It will generate no output, but running rfcomm again without arguments should show a binding.

craig$ rfcomm
rfcomm0: 00:1D:E9:F5:55:AF channel 4 clean

You can now use /dev/rfcomm0 as the serial device node to talk to the modem when probing it using the instructions above. The phone and/or gnome-bluetooth on your laptop might prompt you for a passkey to set up a pairing if you haven't used the two devices together before. Additionally, the phone/modem may prompt you to accept the bluetooth connection from the laptop, so make sure you're ready to accept if prompted. Setting up a trusted pairing will eliminate that prompt.

This setup procedure will also let you use ppp over the rfcomm channel to connect to the Internet through your phone. Use a ppp and chat setup, or use a tool like wvdial just as you would a USB or serial GSM modem once you've created the binding. Here's a little shell script I use to re-bind the phone before connecting:

# replace the following with the MAC address of your phone. Note that
# your phone does NOT need to be discoverable for this to work.
BT=00:1D:E9:F5:55:AF
if test "$(id -u)" -ne 0 ; then
        exec sudo $0
fi
CHAN=$(sdptool search --bdaddr $BT DUN | awk '/Channel/ { print $2}')
rfcomm release 2
rfcomm bind 2 "$BT" "$CHAN"
rfcomm

This full procedure has been tested on a Nokia N95 and an LG U990.

Testing your modem using wvdial

Even if NetworkManager can't find your modem, you can probably still dial out with it using pppd and chat, or using wvdial. I'll give instructions for wvdial here, as using wvdial is a bit more self contained and perhaps easier for people to debug.

WARNING WARNING WARNING

Note that some cellular providers charge a LOT for data connections - often charging a session fee to connect, plus punitive data transfer charges. For example, my provider in Australia charges users on a default business plan AU$10/MB, which at HSDPA 7.2 data rates works out to around AU$32000/hour (somewhere around $25,000 US/hour). Make sure your provider's charges are reasonable before you attempt to connect to the cellular network for data services. If you're unsure about your provider's data rates, do not attempt to use cellular data services.

To begin testing, first install wvdial:

sudo aptitude install wvdial

then copy the following text into the file ~/.wvdialrc (ie .wvdialrc in /home/YOURUSERNAME}}}:

[Dialer cellular]

# This configuration should work for most cellular modems and
# USB or bluetooth connected mobile phones.

# Your modem device. Usually /dev/ttyUSB0 or /dev/ttyACM0
# Bluetooth devices use an rfcomm device (/dev/rfcomm0, etc) that must be set
# up first.
#
#Modem = /dev/ttyACM0
#Modem = /dev/ttyUSB0
#Modem = /dev/rfcomm0
Modem = /dev/ttyACM0

# Port speeds that're worth testing:
# 921600
# 460800
# 115200
#  57600
Baud = 115200

# If your SIM card has a PIN, comment this line, uncomment the next one, and
# change the PIN shown to your PIN.
Init = ATZ
# Init = ATZ+CPIN="0000"

# If you know your ISP's APN, specify it instead of YOUR_ISP_APN below.
# If you don't, you may be able to find out on the 'net, or from tech
# support.
#
# There's also an APN table at https://wiki.ubuntu.com/NetworkManager/Hardware/3G .
#
# If you can't find it, you might be able to dial out without setting an APN
# (especially from a mobile phone). Just comment this line and uncomment
# the next one.
Init2 = AT+CGDCONT=1,"IP","YOUR_ISP_APN"
#Init2 = AT+CGDCONT=1,"IP"

# Most services/devices dial with *99# . A few seem to require *99***1#
Phone = *99#

# These often suffice, but your ISP might require different details. They're
# often dummy details used for all users on the ISP, frequently the ISP's
# name, but some ISP's do require you to use a real username and password.
Username = dummy
Password = dummy

Read through it and make sure the Modem, Init, Init2, Username and Password entries are correct for your provider. Then try to dial (running wvdial as root):

sudo wvdial cellular

With luck, and if you have the right settings, you should see output like:

craig$ sudo wvdial cellular
--> WvDial: Internet dialer version 1.60
--> Cannot get information for serial port.
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: AT+CGDCONT=1,"IP","Telstra.Internet"
AT+CGDCONT=1,"IP","Telstra.Internet"
OK
--> Modem initialized.
--> Sending: ATDT*99#
--> Waiting for carrier.
ATDT*99#
CONNECT
~[7f]}#@!}!} } }2}#}$@#}!}$}%\}"}&} }*} } g}%~
--> Carrier detected.  Waiting for prompt.
~[7f]}#@!}!} } }2}#}$@#}!}$}%\}"}&} }*} } g}%~
--> PPP negotiation detected.
--> Starting pppd at Wed Sep  3 13:55:10 2008
--> Pid of pppd: 22341
--> Using interface ppp0
--> local  IP address 10.164.32.250
--> remote IP address 10.6.6.6
--> primary   DNS address 203.50.2.71
--> secondary DNS address 139.130.4.4

}}}

You might have issues with resolvconf stomping on your DNS configuration in /etc/resolv.conf - but if you're getting an IP address from the remote peer then the modem is working, even if you can't access any websites etc. If you don't use resolvconf, consider just uninstalling it.

If wvdial reports something like:

--> PPP negotiation detected.
--> Starting pppd at Wed Sep  3 13:54:13 2008
--> Pid of pppd: 22239
--> Using interface ppp0
--> Disconnecting at Wed Sep  3 13:54:19 2008
--> The PPP daemon has died: A modem hung up the phone (exit code = 16)
--> man pppd explains pppd error codes in more detail.
--> Try again and look into /var/log/messages and the wvdial and pppd man pages for more information.

then it's quite likely that your APN, username, or password are wrong. Run tail -f /var/log/messages and redial. If it's the APN, you might see something like:

Sep  3 13:54:44 ayaki pppd[22271]: pppd 2.4.4 started by root, uid 0
Sep  3 13:54:44 ayaki pppd[22271]: Using interface ppp0
Sep  3 13:54:44 ayaki pppd[22271]: Connect: ppp0 <--> /dev/ttyACM0
Sep  3 13:54:47 ayaki pppd[22271]: PAP authentication succeeded
Sep  3 13:54:47 ayaki pppd[22271]: LCP terminated by peer
Sep  3 13:54:50 ayaki pppd[22271]: Connection terminated.
Sep  3 13:54:50 ayaki pppd[22271]: Modem hangup
Sep  3 13:54:50 ayaki pppd[22271]: Exit.

Note the successful authentication, then connection termination by the remote end.

That, or successful negotiation followed by the inability to send and receive IP packets, could also indicate that your cellular service has barring active on data connections. You'd need to talk to the accounts people at your cellular provider.

Notes

The gsmctl program from the gsm-utils should be able to probe most modems, but appears to have issues parsing provider information returned by many devices. As I wasn't able to get it to reliably probe my modems I've provided a chat script to do the job instead. However, it and libgsm appear to be an ideal way to talk to modems, and should probably be considered for use by NetworkManager when doing things like:

  • Determining battery level and charging state for a bluetooth or USB phone/modem (I'm thinking in terms of a NetworkManager popup: "WARNING: The modem you are using for your network connection is almost out of battery power")

  • Determining network connection quality
  • Getting operator details
  • Getting make/model information
  • Discovering operators within range for roaming etc
  • Testing PIN locking status

Also, some handy commands for GSM hardware control and probing can be found here and here.

This document was originally written by Craig Ringer <craig at postnewspapers dot com dot au>

NetworkManager/Hardware/3G/Probing (last edited 2009-06-29 23:46:36 by host-94-243-84-195)