NOTICE: The Processors Wiki will End-of-Life in December of 2020. It is recommended to download any files or other content you may need that are hosted on The site is now set to read only.


From Texas Instruments Wiki
Jump to: navigation, search

Content is no longer maintained and is being kept for reference only!

Construction Icon small.png This page is currently under construction. The content of this page is due to change quite frequently and thus the quality and accuracy are not guaranteed until this message has been removed. Please feel free to contribute to this page while construction is in progress.

This page is currently under construction


Content is no longer maintained and is being kept for reference only!

Majority of mobile telephone networks around the world offer mobile internet connections over 3G GSM using a portable USB modem device. A 3G modem allows you to access the internet anywhere, anytime, as long as you are within a 3G coverage area.

This document acts as guide to add 3G USB modem device spport in Android to access the data connectivity. It describes components involved for adding 3G modem support to Android and provides necessary configuration procedure.

AM335x EVM(REV 1.1A) and TI-Android-JB-4.1.2-DevKit-4.0.1 release is used as a base code for 3G modem integration. Airtel USB 3G (Huawei E173 based) modem is used for testing the functionality.Other Huawei based modems might work as well.

Android Telephony Architecture

The diagram illustrates the Android's Telephony system architecture.


Application: All the telephony related applications like Dialer, Call tracker, SMS, MMS, GPRS, Antenna signal indicator and etc, will be tied up with the Android telephony framework services. The telephony framework provides APIs to access the Phone.

Framework services: Telephony framework will be initialized and started during the system start up. All the queries from the application through API will directed to the Radio interface Layer of Android by these services. The service will keep tracking of all the unsolicited commands from the modem. Unsolicited commands are the commands initiated from the modem.

Radio Interface Layer (RIL): It is the bridge between Android phone framework services and the hardware.The RIL consist of two primary components.

  • RIL Daemon
  • Vendor RIL

RIL Daemon: RILD will be initialized during the Android system start up. It will read the system property or use command line arguments to find which library has to be used for Vendor RIL.It provide the appropriate input for vendor RIL and finally calls RIL_Init function of Vendor RIL to map all the Vendor RIL functions to the upper layer.

Vendor RIL: It is a library specific to each modem that processes all communication with radio hardware and dispatches calls to the RIL Daemon.

USB 3G Modem Demo

USB 3G modem support is available for AM335x EVM with Android 4.1.1 sources. Below sections provide procedure to download and build sourcesand provides necessary steps to configure 3G modem.

Getting Sources

3G USB modem configuration support has been added in settings app for AM335x EVM. Please follow below commands to download AM335x Android 4.1.1 sources with 3G modem support.

 $ mkdir ~/roboat-jb
 $ cd ~/rowboat-jb
 $ repo init -u git:// -m rowboat-jb-4.1.2-am335x.xml
 $ repo sync

Create a Bootable SD/MMC Card

Build source code for AM335x EVM and create a bootable SD card. Please follow instructions mentioned in below developer guide.

Download USB mode switch pre-complied binary from

Copy usb_modeswitch binary to Android Filesystem (system/bin location)

   $ sudo cp usb_modeswitch-1.1.9-arm-static /media/rootfs/system/bin/usb_modeswitch

Test 3G Functionality

  • Bootup the board.
  • Connect USB 3G modem to board.
  • Wait for around 8-10 secs to get 3G modem detected and configured.
  • Go Settings Application <More...> and you will see the following


  • Select <Mobile networks> and you will get this screen:


  • Select <Access Point Names>. when you come to the access point page you should see the list of APNs that are supported for your modem. Select appropriate APN.

If you don't see any APN list, click in the top right corner and select <New APN>. This is the tricky part where you fill in the GSM operators settings.Find your GSM operator settings and fill in following fields.


Mark "Data Enabled" check box.

  • Check whether browser works

Android USB 3G modem Integration

This section takes you through necessary steps involved in integrating USB 3G modem with Android. Procedure mentioned below is applicable for Android 4.1.1 version and may or may not work as ease with other Android versions.

Enable Android Telephony

Add APN List

An Access Point Name (APN) is the name of a gateway between a 3G(or GPRS, etc) mobile network and another computer network, frequently the public Internet.A mobile device making a data connection must be configured with an APN to present to the carrier. The carrier will then examine this identifier to determine what type of network connection should be created, for example: what IP addresses should be assigned to the wireless device, what security methods should be used, and how or if, it should be connected to some private customer network.

apns-conf.xml file contains the list of carriers. Android Telephony provider will read this file (/etc/apns-conf.xml location) and maintain the database of all APN carriers mentioned.

Add apns-conf.xml file to /system/etc/ (symlink /etc) of your file system.

 diff --git a/ b/
 --- a/
 +++ b/
 @@ -46,6 +46,9 @@ PRODUCT_COPY_FILES += \
 +       device/ti/am335xevm/apns-full-conf.xml:system/etc/apns-conf.xml
 # KeyPads
      $(LOCAL_PATH)/gpio-keys.kl:system/usr/keylayout/gpio-keys.kl \

Enable Mobile Network Support

Add mobile network attribute to the overlay config.xml file so that connectivity manager will understand that mobile connectivity is available. This will also enable "Settings->More->Mobile networks" option.

 diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml
 index 82229a2..a2e55de 100644
 --- a/overlay/frameworks/base/core/res/res/values/config.xml
 +++ b/overlay/frameworks/base/core/res/res/values/config.xml
 @@ -128,6 +128,7 @@
      <string-array translatable="false" name="networkAttributes">
 +        <item>"mobile,0,0,0,-1,true"</item>

Add GSM telephony permissions

 diff --git a/ b/
 index 7f0bc2d..64f9ec8 100644
 --- a/
 +++ b/
 @@ -41,7 +41,8 @@ PRODUCT_COPY_FILES += \
         frameworks/native/data/etc/android.hardware.usb.accessory.xml:system/etc/permissions/android.hardware.usb.accessory.xml \
         frameworks/native/data/etc/ \
         frameworks/native/data/etc/android.hardware.sensor.light.xml:system/etc/permissions/android.hardware.sensor.light.xml \
 -       device/ti/am335xevm/android.hardware.screen.xml:system/etc/permissions/android.hardware.screen.xml
 +       device/ti/am335xevm/android.hardware.screen.xml:system/etc/permissions/android.hardware.screen.xml \
 +       frameworks/native/data/etc/android.hardware.telephony.gsm.xml:system/etc/permissions/android.hardware.telephony.gsm.xml

Enable Radio Intferace Layer(RIL) deamon build

By default RIL daemon is not included in build. Enable RIL daemon build.

 diff --git a/ b/
 index 64f9ec8..399e54e 100644
 --- a/
 +++ b/
 @@ -142,6 +142,9 @@ PRODUCT_PACKAGES += \
 +       rild
  $(call inherit-product, frameworks/native/build/
  $(call inherit-product-if-exists, hardware/ti/wpan/wl12xx-bluetooth/
  $(call inherit-product-if-exists, hardware/ti/wlan/mac80211/firmware/

USB Modem Mode Switching

USB 3G modem devices will have two modes

  • USB flash memory storage
  • USB Modem.

The first mode, sometimes known as ZeroCD, is often used to provide driver for desktop operating system and is generally of no interest for Android.

By default modem will be in flash memory storage mode. usb_modeswitch utility can be used for switching USB 3G modem into modem mode.

USB Mode Switch Configuration

The ARM compiled usb_modeswitch binary and its sources can be obtained from HERE Copy the usb_modeswitch (ARM Compiled binary) and usb_modeswitch.conf to the /system/bin folder.

Below is example usb_modeswitch.conf file for the Huawei E1731 Modem (Airtel in India).

  Huawei E1731


  DefaultVendor= 0x12d1

  TargetVendor=  0x12d1


  MessageEndpoint= 0x01

The vendor IDs and product IDs mentioned in this configurations are specific to modem. If you are using some other modem then, you can find vendor IDs and product IDs using lsusb command and modify usb_modeswitch.conf file accordingly.

Add USB Mode switch as a Service

Add USB mode switch as a service in init.<platform>.rc file.

 :Ex device/ti/am335xevm/init.am335xevm.rc file
 #Download usb_modeswitch ARM complied binrary from
 #    and place it in "/system/bin" folder of your filesystem with "usb_modeswitch" name.
 service usb_modeswitch /system/bin/usb_modeswitch -I -W -c /etc/usbmodeswitch.conf
     class main

Start usb_modeswitch Service

start usb_modeswitch service if "usb" is connected. If 3G modem is connected, it will switch it in modem mode.

 diff --git a/VolumeManager.cpp b/VolumeManager.cpp
 --- a/VolumeManager.cpp
 +++ b/VolumeManager.cpp
 @@ -37,6 +35,7 @@
  #include <sysutils/NetlinkEvent.h>
  #include <private/android_filesystem_config.h>
 +#include <cutils/properties.h>
  #include "VolumeManager.h"
  #include "DirectVolume.h"
 @@ -144,6 +143,11 @@ void VolumeManager::handleBlockEvent(NetlinkEvent *evt) {
              SLOGD("Device '%s' event handled by volume %s\n", devpath, (*it)->getLabel());
 +       if (strcmp((*it)->getLabel(),"usb")  == 0)
 +       {
 +            SLOGD("start usb modswitch service");
 +           property_set("ctl.start","usb_modeswitch");
 +       }
              hit = true;

3G Modem Node Permissions

Once 3G modem is switched into modem mode. It will provide 3 serial nodes. /dev/ttyUSB0: used for your ppp data connections. /dev/ttyUSB2: used for GSM related tasks such as SMS and network checks. /dev/ttyUSB1: not used at all.

Note: The actual device assignments (e.g. /dev/ttyUSB0) may be different if you have other USB serial devices installed..

Provide appropriate permissions to these nodes.

 diff --git a/ueventd.am335xevm.rc b/ueventd.am335xevm.rc
 index d7cc538..2ba0518 100644
 --- a/ueventd.am335xevm.rc
 +++ b/ueventd.am335xevm.rc
 @@ -1 +1,4 @@
 -/dev/video0         0666  root       root
 +/dev/video0    0666    root    root
 +/dev/ttyUSB0   0660    radio   radio
 +/dev/ttyUSB1   0660    radio   radio
 +/dev/ttyUSB2   0660    radio   radio

Get RIL library

Download the ril repository and replace your existing RIL library with new one. This RIL library will start ppp (point to point) daemon to establish a internet link when setup data call is requested.

 $ cd ~
 $ git clone git:// -b rowboat-jb-4.1
 $ cd ~/hardware-ril
 $ rm -rf <android sources>/hardware/ril/reference-ril
 $ cp -r ~/hardware-ril/reference-ril  <android sources>/hardware/ril/reference-ril

PPP Configuration

PPP is the protocol used for establishing internet links over dial-up modems, DSL connections, and many other types of point-to-point links. The pppd daemon works together with the kernel PPP driver to establish and maintain a PPP link with another system (called the peer) and to negotiate Internet Protocol (IP) addresses for each end of the link.

PPP daemon will run user defined scripts when link is established and disconnected.

ip-up-datakey: This script is run by the pppd after the link is established. ip-down-datakey: This script is run by the pppd after the link is disconnected.

  • ip-up-datakey script
 case $1 in
         /android/bin/iptables --flush;
         /android/bin/iptables --table nat --flush;
         /android/bin/iptables --delete-chain;
         /android/bin/iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE;
         /android/bin/iptables --append FORWARD --in-interface ppp1 -j ACCEPT;
         echo 0 > /proc/sys/net/ipv4/ip_forward;
         echo 1 > /proc/sys/net/ipv4/ip_forward;
     /system/bin/setprop "net.interfaces.defaultroute" "ppp1";
 /system/bin/setprop "net.ppp1.dns1" "$DNS1"
 /system/bin/setprop "net.ppp1.dns2" "$DNS2"
 /system/bin/setprop "net.ppp1.local-ip" "$IPLOCAL"
 /system/bin/setprop "net.ppp1.remote-ip" "$IPREMOTE"
 /system/bin/setprop "" "$IPREMOTE"
 /system/bin/setprop "net.ppp1.if" "$IFNAME"
  • ip-down-datakey
 case $1 in
         echo 0 > /proc/sys/net/ipv4/ip_forward;
 /system/bin/setprop "net.ppp1.dns1" ""
 /system/bin/setprop "net.ppp1.dns2" ""
 /system/bin/setprop "net.ppp1.local-ip" ""
 /system/bin/setprop "net.ppp1.remote-ip" ""
 /system/bin/setprop "" ""
 /system/bin/setprop "net.ppp1.if" ""

Place these scripts in <Android source>/device/ti/<target product>/ppp folder.

Add following lines to file to copy these files to Android filesystem.

        device/ti/am335xevm/ppp/ip-up-datakey:system/etc/ppp/ip-up-datakey \

Kernel Configuration for USB Modem

Make sure following configuration options are enabled in kernel.

Device Drivers  --->
 [*] Network device support  --->
   <*>   PPP (point-to-point protocol) support
     <*>     PPP BSD-Compress compression
     <*>     PPP Deflate compression
     <*>     PPP support for async serial ports
     <*>     PPP support for sync tty ports
 [*] USB support  --->
   <*>   USB Modem (CDC ACM) support
   <*>   USB Serial Converter support  --->
     [*]   USB Generic Serial Driver
     <*>   USB driver for GSM and CDMA modems