Thursday, September 20, 2012

Getting Ready for Maker Faire NY!

Call me strange, but I’m a big fan of planning and logistics, so I’m pumped that everything is set for our trip to Maker Faire NY next week!

We’re only 8 days, 20 hours, 35 minutes and 12, no 8 seconds away from Maker Faire New York 2012. This will be my first Maker Faire, so I’m really excited to head down and see what projects people have been working on. I’ve read through the list of Makers and can’t wait to sneak away to check out their projects.

I’m heading down with Mike, Justin and Rith, who have all been to several Maker Faires in the past and had great times. We’ll be bringing down our Digital Rooster project and a couple of other gadgets for people to check out, so come find us in the Arduino Pavilion!

Tuesday, September 4, 2012

How to connect a cellular modem on your Android and BeagleBoard on boot up

Last week, I wrote a tutorial about how to get a 3G/4G cellular modem working on my Android/BeagleBoard setup. The next question (after everything works) is, how can I get this running automatically every time I boot up my Android device?

Boot scripts are nothing too fancy, and anyone with some basic Linux or Android experience can navigate this process pretty easily. But I always find it helpful to have the actual scripts written out. As a beginner, it’s a great way to figure out what the commands actually mean, and as an advanced developer, it’s a huge timesaver to copy and paste what’s already been done.

As a quick recap, I'm running all of this off my BeagleBoard xM, BeagleTouch, and Android Ambrosia SD card/image. I decided to use a T-Mobile 4G Rocket 3.0 USB cellular modem, but any USB cellular modem should work, with some tweaks to the vendor/product ID as well as the chat script (more on that in the previous post).

Outline the process

Looking through the original 3G/4G cellular modem integration process, I needed to do 4 things:

1) Get usb_modeswitch and usbserial.ko onto your Android setup

2) Execute usb_modeswitch using the correct usb_modeswitch.conf config file

3) Once modeswitch was successful, install usbserial.ko module to the correct vendor and product ID for the device

4) Execute chat script using pppd command

Wrap up relevant components into a script

I created a file called, which contains the relevant content and commands to create the usb_modeswitch.conf file as well as the script.

#This is a wrapper script to enable cellular wireless

# echo usb modeswitch config
echo_modeswitch_conf_zte() {
echo "$TAG building modeswitch config"
cat > /system/etc/usb_modeswitch.conf << EOF

# ZTE devices

DefaultVendor=  0x19d2
DefaultProduct= 0x2000
TargetVendor=   0x19d2


# echo chatscript
echo_chatscript_tmobile() {
echo "$TAG building chatscript"
cat > /system/etc/ppp/ << EOF
SAY 'Starting GPRS connect script\n'

SAY 'Setting APN\n'

SAY 'Dialing...\n'
OK 'ATD*99***1#'

# Switch USB modes
switch_usb() {
    echo "$TAG switching USB mode" && \
    usb_modeswitch -I -W -c /system/etc/usb_modeswitch.conf && \
    sleep 5 && \
    echo "$TAG mode switch success" && \
    return 0

# Start T Mobile firmware
start_tmobile() {
    rmmod usbserial
    echo "$TAG tmobile firmware provider"


    echo "$TAG installing firmware"
    busybox insmod /system/etc/firmware/usbserial.ko vendor=0x19d2 product=0x0157
    echo "$TAG starting pppd"
    /system/bin/pppd /dev/ttyUSB1 persist defaultroute usepeerdns -detach crtscts noauth debug connect "/system/xbin/chat -v -s -f /system/etc/ppp/" &

Insert command to run script into Android’s init.rc bootup commands

You’ll find init.rc in the root folder on your Android device.

I placed the script in /system/etc/ppp, though it could technically go anywhere – as long as it’s being called in the right location, and the files it generates are going to the right places as well.

Then I just added these two lines to Android’s init.rc bootup script:

service cellular_up /system/bin/logwrapper /system/xbin/busybox sh -c /system/etc/ppp/

This ensures that I execute every time I boot, which in turn generates the files I need and executes the commands required to have a fully functional 3G/4G cellular connection every time I boot up my Android device, provided I have the modem plugged in.

In my last blog post, I cover which parameters you’ll want to tweak if you’re using a different modem or cellular provider, but if you have any questions or suggestions, I’d love to hear it.

Email me at or follow me on twitter @liquidware