3G Cellular Zipit Z2

I’ve had this crazy idea for a while to build my own cellphone. While Android phones are ok and have most of the applications I need, I think it would be neat to have a more pure Linux/GNU based distro running on a cellphone. It would be more of a proof-of-concept slash “just because I can” type of device than a real phone. I figured I could get this working on the Zipit. Back in April while looking around for cellular modules I found that Huawei brand USB dongles are common and supported in Linux. Some of them even support voice calls. I found a dongle on Ali Express for a measly $11USD with free shipping and promptly ordered it.

My cellular provider is Ting which recently announced GSM support on the T-Mobile network. I ordered a SIM card from them which appeared in a couple of days. The dongle showed up a few weeks later from China. After many hours of painful experimenting, I learned that my dongle had no IMEI programmed into it which means it’s useless. I searched eBay and found a US seller that sold an unlocked dongle with voice support for $16USD. The new dongle is branded “iUSACell” which is a cellular provider based in Mexico.

With some help from here and here I was able to get the 3G data working on the Zipit. A few extra modules are required that aren’t in slug_’s openwrt-gmenu kernel so I recompiled the 3.17 sources from anarsoul. Kernel and modules are here. The new modules required should be loaded in this order:

insmod mii
insmod usbnet
insmod cdc_ether
insmod slhc
insmod ppp_generic
insmod ppp_async
insmod ppp_deflate
insmod usb_wwan
insmod option

You also need a few more packages to get 3g data working that are in the openwrt-zipit repo:

opkg update
opkg install chat comgt usb-modeswitch usb-modeswitch-data
opkg install ppp —nodeps

The dongle has several “modes” that it can be detected in and you need the usb-modeswitch package to set the correct mode. This particular dongle is the Huawei E153 and to switch it to modem mode you must add the modeswitch config below:

# Huawei e153
DefaultVendor= 0x12d1
TargetVendor= 0x12d1

I did find some information about the modes and figured out you can have it always detect in the correct mode by issuing some AT commands. I set mine with the following AT command (minicom /dev/ttyUSB0). This mode also sets the modem to periodically print signal status on /dev/ttyUSB2.


Next, you need to setup the ‘chat’ script with the proper commands to dial the 3g connection. This is what I’m using:

# /etc/chatscripts/3g.chat
“” “ATZ”
OK “ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0”
OK ‘AT+CGDCONT=1,”IP”,”****YOUR APN HERE ****”’ # Ting APN is “wholesale”
OK “ATD*99#”

The last step is to setup the ppp connection options:

# /etc/ppp/options
logfile /tmp/ppp.log
holdoff 10
maxfail 0

All these settings may be different depending on your carrier of choice but they work for Ting (and probably T-Mobile, except the APN which is Ting specific). Finally, to turn on the 3g data connection:

pppd connect “/usr/sbin/chat -v -t15 -f /etc/chatscripts/3g.chat” file /etc/ppp/options

I made a shell script for starting and stopping the 3g connection:

# start or stop 3g

if [ -z “$1” ]; then
     echo “Usage: 3g start OR stop”
     exit 1

if [ “$1” == “start” ]; then
     echo -n “Starting 3G Connection”
     # Check if ppd is already running and stop if it is
     pidof pppd
     if [ $? -eq 0 ]; then
          /usr/local/sbin/3g.sh stop
     mv /tmp/ppp.log /tmp/ppp.log.1
     pppd connect “/usr/sbin/chat -v -t15 -f /etc/chatscripts/3g.chat” file /etc/ppp/options
     while [ 1 ]; do
          grep -q “local IP address” /tmp/ppp.log
          if [ $? -eq 0 ]; then
               echo -n -e “done!\nSetting up DNS…”
               cp /etc/resolv.conf /etc/resolv.conf.wlan0
               cp /etc/ppp/resolv.conf /etc/resolv.conf
               echo “nameserver” >> /etc/resolv.conf
               echo “done!”
          if [ $COUNT -gt 30 ]; then
               # We’ve still not connected, so exit
               killall pppd
               echo -e “\nUnable to connect”
               exit 1
          COUNT=$((COUNT + 1))
          echo -n “.”
          sleep 1
     echo “Connected!”

if [ “$1” == “stop” ]; then
     echo -n “Stopping 3G Connection”
     killall -HUP pppd && sleep 1 && echo -n “.” && sleep 1 && echo -n “.” && sleep 1 && killall pppd
     # Restore old resolv.conf
     mv /etc/resolv.conf.wlan0 /etc/resolv.conf
     echo “.done!”
     exit 0

Awesome, now I have 3G data on my Zipit, but what about voice calls? Well, the dongle definitely supports voice calls and I successfully made phone calls from Windows 7 with a modifed version of the Huawei Mobile Partner application (by Darshana). Unfortunately, my attempts in Linux have mostly been a failure. It took me quite some time to figure out how the dongle does audio and this is what I know. The audio format is raw 16 bit Little Endian @ 8000Hz with a period size of 320 bytes and a 20000 microsecond interrupt (frame period). Audio is sent and received over ttyUSB1. The process for making a call is as follows:


The semicolon after the phone number dialed is required and tells the modem you are making a voice call. The DDSETEX command tells the modem to turn on audio on /dev/ttyUSB1 (the second modem port, ie =2). The DDSETEX command must be sent every time after dialing or answering a call to turn on the audio. If you switch modes as I mentioned above (U2DIAG command), you will see RINGING on /dev/ttyUSB2 when a call is coming in. The command ATA will answer the call. Most of the audio testing has been on my laptop. You can play the audio from the command line with:

aplay -fS16_LE -c1 -r8000 -F20000 —period-size=320 -t raw -N /dev/ttyUSB1

and you can send microphone audio with:

arecord -fS16_LE -c1 -r8000 -F20000 —period-size=320 -t raw -N /dev/ttyUSB1

I have a lot of problems with latency using the arecord/aplay commands. The arecord command sends audio to the modem in a timely manner with only a slight delay and is tolerable. The aplay command always has a delay of 3-5 seconds. Running this test on the Zipit was unbearable. There is way too much clipping and chopping of the audio to even make out a word. I suspect the USB 1.1 speeds on the Zipit can’t handle it. I played around with this answering machine code from github and it works on my laptop. On the Zipit though, the audio is unrecognisable. I found this code which uses pulseaudio on the beaglebone black and a Huawei dongle. With some modification I got the code to run on my laptop but audio was worse than using aplay/arecord (pulseaudio sucks?) I found some info on stackoverflow which helped figure out the audio format.

It would be nice to get the audio working, if not on the Zipit, at least on a laptop or PC, or some other dev board. But, I have a data connection on the Zipit when there’s no wifi. SMS is working also but I did not do any extensive testing. I just used AT commands to send and receive a message to verify it works.


Please insert the result of the arithmetical operation from the following image:

Please insert the result of the arithmetical operation from this image. =

Archives By Month