One of the outstanding items on my long of list of 'things to do with the Hackberry' was to get my Huawei E173s 3G modem working under Debian. This allows the Hackberry to used for remote deployments where LAN/WLAN is not possible. Furthermore there is the possibility of using the modem for reading and writing SMS messages. You can use these instructions as a template for other modems types and/or or other Linux variants.
First step is to enable ppp support in the kernel as below:
[*] Network device support --->
<M> PPP (point-to-point protocol) support
[*] PPP filtering
<M> PPP support for async serial ports
<M> PPP support for sync tty ports
<M> PPP Deflate compression
<M> PPP BSD-Compress compression
<M> PPP on L2TP Access Concentrator
<M> PPP on PPTP Network Server
Fortunately in my debian image the kernel is configured to include the ppp modules. Next step is to install the package usb_modeswitch which allows switching from usb storage mode to modem mode. Without this package plugging the modem into the usb port result in it being recognised as a usb storage device. At the same time we can retrieve the package usbutils and wvdial so that we run the command lsusb and configure the modem.
apt-get install usb_modeswitch
apt-get install usbutils
apt-get install wvdial
To switch modes we need to add a new rule for the modem (based on it's usb id), you can skip this step if your modem does not have usb storage support. For the E173s this means creating the file /etc/usb_modeswitch.d/12d1:1c0b with following contents:
########################################################
# Huawei E173s
DefaultVendor= 0x12d1
DefaultProduct= 0x1c0b
TargetVendor= 0x12d1
TargetProduct= 0x1c05
CheckSuccess=20
MessageEndpoint= 0x0f
MessageContent= "55534243123456780000000000000011062000000100000000000000000000"
Next install the kernel modules for usb modem support and ppp.
insmod /lib/modules/3.0.36+/kernel/drivers/usb/serial/usbserial.ko
insmod /lib/modules/3.0.36+/kernel/drivers/usb/serial/usb_wwan.ko
insmod /lib/modules/3.0.36+/kernel/drivers/usb/serial/option.ko
insmod /lib/modules/3.0.36+/lib/crc-ccitt.ko
insmod /lib/modules/3.0.36+/kernel/drivers/net/slhc.ko
insmod /lib/modules/3.0.36+/kernel/drivers/net/ppp_generic.ko
insmod /lib/modules/3.0.36+/kernel/drivers/net/bsd_comp.ko
insmod /lib/modules/3.0.36+/kernel/drivers/net/ppp_deflate.ko
insmod /lib/modules/3.0.36+/kernel/drivers/net/ppp_async.ko
Fingers crossed we can plug the modem into the top usb port of the hackberry. Dmesg should report some thing similar to this:
[ 2482.070000] option1 ttyUSB0: GSM modem (1-port) converter now disconnected from ttyUSB0
[ 2482.100000] option 2-1.2:1.0: device disconnected
[ 2482.140000] option1 ttyUSB1: GSM modem (1-port) converter now disconnected from ttyUSB1
[ 2482.170000] option 2-1.2:1.1: device disconnected
[ 2482.200000] option1 ttyUSB2: GSM modem (1-port) converter now disconnected from ttyUSB2
[ 2482.250000] option 2-1.2:1.2: device disconnected
[ 2528.090000] usb 2-1.2: new high speed USB device number 5 using sw-ehci
[ 2528.590000] scsi4 : usb-storage 2-1.2:1.0
[ 2528.620000] scsi5 : usb-storage 2-1.2:1.1
[ 2530.960000] scsi 5:0:0:0: Direct-Access HUAWEI SD Storage 2.31 PQ: 0 ANSI: 2
[ 2530.990000] scsi 4:0:0:0: CD-ROM HUAWEI Mass Storage 2.31 PQ: 0 ANSI: 2
[ 2531.050000] sd 5:0:0:0: [sda] Attached SCSI removable disk
[ 2531.090000] sr0: scsi-1 drive
[ 2531.150000] sr 4:0:0:0: Attached scsi CD-ROM sr0
And lsusb reports (note 'modem on', if 'modem off' then something is wrong):
root@(none):~# lsusb
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 002: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter
Bus 002 Device 006: ID 12d1:1c05 Huawei Technologies Co., Ltd. E173s 3G broadband stick (modem on)
Last step is to configure wvdial , I found the default configuration in /etc/wvdial.conf doesn't work so here are my settings, thanks to koi-sama on the miniand forums for help with configuration. Replace tmobile section with your settings, Init2 is APN and the Username and Password are self explanatory.
[dialer defaults]
Modem = /dev/ttyUSB0
Baud = 460800
Dial Command = ATD
Init1 = ATE1
Phone = *99***1#
Stupid Mode = 1
New PPPD = 1
Dial Attempts = 10
Dial Timeout = 10
[Dialer tmobile]
Modem = /dev/ttyUSB0
Init2 = AT+CGDCONT=1,"IP","general.t-mobile.uk"
Phone = *99#
Stupid mode = yes
Username = ""
Password = ""
Dial Attempts = 0
Now we can attempt to connect
root@(none):~# wvdial tmobile
--> WvDial: Internet dialer version 1.61
--> Initializing modem.
--> Sending: ATE1
ATE1
OK
--> Sending: AT+CGDCONT=1,"IP","general.t-mobile.uk"
AT+CGDCONT=1,"IP","general.t-mobile.uk"
OK
--> Modem initialized.
--> Sending: ATD*99#
--> Waiting for carrier.
ATD*99#
CONNECT
--> Carrier detected. Starting PPP immediately.
--> Starting pppd at Sat Jan 2 23:48:07 2010
--> Pid of pppd: 2099
--> Using interface ppp0
--> pppd: )
--> pppd: )
--> pppd: )
--> pppd: )
--> pppd: )
--> pppd: )
--> pppd: )
--> local IP address 31.126.31.57
--> pppd: )
--> remote IP address 10.64.64.64
--> pppd: )
--> primary DNS address 149.254.230.7
--> pppd: )
--> secondary DNS address 149.254.192.126
--> pppd: )
ifconfig reports
root@(none):~# ifconfig
ppp0 Link encap:Point-to-Point Protocol
inet addr:31.126.31.57 P-t-P:10.64.64.64 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:128 (128.0 B) TX bytes:185 (185.0 B)
When I get time I will look into reading/writing sms messages from the modem.