Add 3G modem to IGEP – Android

Requirements:

IGEP board

3G modem (used Sierra Wirelss Q26 Dev kit) through USB using ACM

IGEP VM

Android Froyo (2.2) and IGEP sources

Hooking up the modem to IGEP

hints:

to build only the libreference, which is a hundred times less time consuming than building the whole plateform, go to the root directory of your android distribution, and just type “make libreference-ril”. Thank you Jean Baptiste Queru

Follow this tutorial and stop right before the command “make OMAPES=5.x” and do this

make ARCH=arm CROSS_COMPILE=arm-eabi- igep0020_android_defconfig
This will copy the igep config file to the /froyo/kernel directory so that the next command uses it as it's default configuration.
make ARCH=arm CROSS_COMPILE=arm-eabi- menuconfig

This command will bring up a GUI kernel configuration editor.

  • Device drivers
    • network device support
      • enable PPP support
        • enable ppp suport for asyn serial line (TBD)
        • enable ppp support for sync serial line (TBD)
      • enable SLIP (TBD)
    • Enable telephony support (TBD)
    • USB support
      • USB Modem (CDC ACM) support (REQUIRED) (for USB modems)
      • USB Serial Converter support (REQUIRED for serial modem)
ADD FTDI_SIO support in the .config file (for serial modems)
  • Remove AT command AT> AT+COPS=3,0;+COPS?;+COPS=3,1;+COPS?;+COPS=3,2;+COPS? and replace it with AT> AT+COPS=3,0;+COPS? (TBD)
This removes    ?
D/AT      (  881): AT> AT+COPS=3,0;+COPS?;+COPS=3,1;+COPS?;+COPS=3,2;+COPS?
D/RILJ    ( 1041): [0015]< GET_CURRENT_CALLS
D/RILJ    ( 1041): [0040]> QUERY_FACILITY_LOCK
D/RILJ    ( 1041): [0041]> QUERY_FACILITY_LOCK
D/AT      (  881): AT< +COPS: 0,0,"F SFR"
D/AT      (  881): AT< +CME ERROR: 4
E/RIL     (  881): requestOperator must not return error when radio is on
  • Remove touch screen confs (TBD)

See articles: You have to modify several files before and after compiling the kernel. In red are the steps before, and the steps to do afterwards are colored in green

  • hardware/ril/libril/ril.cpp
First #if 0 to #if 1  Removes can’t connect to rild socket, but now we have can’t connect to rild-debug 
Comment next #else Removes can’t connect to rild-debug socket
  • hardware/ril/rild/rild.c
/* special override when in the emulator */
#if 1
{
to
/* special override when in the emulator */
#if 0
{
  • /hardware/ril/reference-ril/reference-ril.c
    • In function static void mainLoop replace the following
else if (s_device_path != NULL) {
                fd = open (s_device_path, O_RDWR);
                if ( fd >= 0 && !memcmp( s_device_path, "/dev/ttyS", 9 ) ) {
                    /* disable echo on serial ports */
                    struct termios  ios;
                    tcgetattr( fd, &ios );
                    ios.c_lflag = 0;  /* disable ECHO, ICANON, etc... */
			tcsetattr( fd, TCSANOW, &ios );
                }
by the following
else if (s_device_path != NULL) {
                fd = open (s_device_path, O_RDWR);
                if ( fd >= 0 && !memcmp( s_device_path, "/dev/ttyS", 9 ) ) {
                    /* disable echo on serial ports */
                    struct termios  ios;
                    tcgetattr( fd, &ios );
                    ios.c_lflag = 0;  /* disable ECHO, ICANON, etc... */
                      if( cfsetispeed( &ios, B115200) != 0 )
                       printf("Failed to set in speed\n");
                   if ( cfsetospeed( &ios, B115200) != 0 )
                       printf("Failed to set out speed\n");
			tcsetattr( fd, TCSANOW, &ios );
                }
  • try to set permissions for /dev/ttyACM0 (apparently doesn’t work when using init.rc (/home/jdoe/bin/froyo/system/core/init) { “/dev/ttyACM0”, 0660, AID_RADIO, AID_RADIO, 0 },
  • /froyo/hardware/ril/reference-ril/libreference.c
    (problem with air plane mode)
    Delete the command "AT+CGEREP=.." in  reference-ril.c.
  • /init.rc  
loglevel 4 instead of 3
set prop ro.radio.noril to no?

setprop hw.nophone false

service ril-daemon /system/bin/rild -l /system/lib/libreference-ril.so -- -d /dev/ttyUSB0
group radio cache inet misc audio vpn net_admin
  • init.goldfish.rc

setprop ro.radio.use-ppp yes TBD

  • /frameworks/base/libs/utils/ResourceTypes.cpp   (problem with the dialer crashing)
// Check to make sure this one is valid for the current parameters.
        if (config && !thisConfig.match(*config)) {
            TABLE_GETENTRY(LOGI("Does not match config!\n"));
            continue;
        }

        // Check if there is the desired entry in this type.
to
if (config && !thisConfig.match(*config)) {
TABLE_GETENTRY(LOGI("Does not match config!\n"));
 #ifdef IGNORE_TOUCHSCREEN_CONFIGURATION
 // Allow no touchscreen device to use touchscreen configuration
 thisConfig.touchscreen = 0;
 if (!thisConfig.match(*config)) {
 #endif // IGNORE_TOUCHSCREEN_CONFIGURATION
continue;
 #if 1 // IGNORE_TOUCHSCREEN_CONFIGURATION
 }
 #endif // IGNORE_TOUCHSCREEN_CONFIGURATION
}

Forward from pc to board using adb You can actually use adb and a 3G modem hook up to your pc to use ppp on your board if you want. Didn’t work for me though: adb forward dev:{PUT LOCAL DEVICE NAME HERE} dev:{PUT REMOTE DEVICE NAME HERE} I tried

adb forward dev:/dev/tty.usbserial dev:/dev/ttyS0

ADDING PPP SUPPORT

ppp 2.4.4 (ftp://ftp.samba.org/pub)

Tests on Linux 8.04, ppp 2.4.4, kernel

####LINUX

## All using /etc/ppp/options
##/etc/ppp/options =
115200
-detach
debug
lock
crtscts
defaultroute
noauth
debug

## BASE SCRIPT (worked in december on linutop)
/usr/sbin/pppd /dev/ttyS0 115200 noauth persist nocrtscts defaultroute usepeerdns connect '/usr/sbin/chat -v -f /etc/ppp/chatscripts/mgprs' 2>&1 1> /etc/ppp/ppp.log &

##without custom script
/usr/sbin/pppd /dev/ttyUSB0 connect "/usr/sbin/chat -v '' AT OK ATE1 OK AT+CGDCONT=1,"IP","websfr" OK ATD*99***1# CONNECT '\d\c'"2>&1 1> /etc/ppp/ppp.log &

## WORKING
/usr/sbin/pppd /dev/ttyUSB0 connect "/usr/sbin/chat -v  TIMEOUT 10 ABORT BUSY ABORT DELAYED ABORT \"NO ANSWER\" ABORT \"NO DIALTONE\" ABORT VOICE ABORT ERROR ABORT RINGING '' AT OK ATE1 OK AT+CGDCONT=1,"IP","websfr" OK ATD*99***1# CONNECT '\d\c'" 2>&1 1> /etc/ppp/ppp.log &

## WORKING
/usr/sbin/pppd /dev/ttyUSB0 connect "/usr/sbin/chat -v  TIMEOUT 10 ABORT BUSY ABORT DELAYED ABORT \"NO ANSWER\" ABORT \"NO DIALTONE\" ABORT VOICE ABORT ERROR ABORT RINGING '' AT OK ATE1 OK AT+CGDCONT=1,"IP","websfr" OK ATD*99***1# CONNECT " 2>&1 1> /etc/ppp/ppp.log &

## WORKING WITH DNS
/usr/sbin/pppd /dev/ttyUSB0 persist nocrtscts defaultroute -detach usepeerdns connect "/usr/sbin/chat -v  TIMEOUT 10 ABORT BUSY ABORT DELAYED ABORT \"NO ANSWER\" ABORT \"NO DIALTONE\" ABORT VOICE ABORT ERROR ABORT RINGING '' AT OK AT&F0 OK ATE1 OK AT+CGDCONT=1,"IP","websfr" OK ATD*99***1# CONNECT " 2>&1 1> /etc/ppp/ppp.log &

Tests on Android 2.2, ppp 2.4.4, kernel
####ANDROID
## compile pppd and chat
./configure --target=arm-linux --enable-arm --prefix=/home/jdoe/bin/froyo/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/

make CC=/home/jdoe/bin/froyo/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-gcc

## all not using /etc/ppp/options

## obviously not working, just for tests (logs, pppd starting, ...)
/system/bin/pppd /dev/ttyUSB0 debug defaultroute $PPPD_ARGS noauth crtscts nodetach usepeerdns ipcp-no-addresses noipdefault novj noccp lcp-echo-failure 4 lcp-echo-interval 60 modem nocrtscts linkname ppp0 

##with most of linux parameters
/system/bin/pppd /dev/ttyUSB0 115200 -detach debug crtscts defaultroute noauth debug persist usepeerdns linkname ppp

/system/bin/pppd /dev/ttyUSB0 debug defaultroute $PPPD_ARGS noauth crtscts nodetach usepeerdns ipcp-no-addresses noipdefault novj noccp lcp-echo-failure 4 lcp-echo-interval 60 modem nocrtscts linkname ppp0 

Make android kernel (from make all command) make -C kernel ARCH=arm CROSS_COMPILE=../prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi- uImage Compile PPP for ARM

source envsetup.sh (TBD)

./configure

export CC=/usr/local/poky/eabi-glibc/bin/arm-none-linux-gnueabi-gcc

make

how to install?

(http://www.slideshare.net/ssusere3af56/android-radio-layer-interface)
Building Process
Add ppp and chat script to source tree
mkdir external/ppp/chat
get chat source from ftp://ftp.samba.org/pub/ppp/ ppp-2.4.3.tar.gz
vi external/ppp/chat/Android.mk
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:=
chat.c
LOCAL_SHARED_LIBRARIES :=
libcutils libc
LOCAL_C_INCLUDES :=
$(LOCAL_PATH)/include
LOCAL_CFLAGS := -DANDROID_CHANGES -DTERMIOS -DSIGTYPE=void -UNO_SLEEP -DFNDELAY=O_NDELAY
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
LOCAL_MODULE_TAGS := eng
LOCAL_MODULE:= chat
include $(BUILD_EXECUTABLE)
Building Process
Add ppp and chat script to source tree (cont.)
vi system/core/rootdir/etc/ppp/ppp-startup.sh
#!/system/bin/sh
setprop net.dns1 168.95.1.1
/system/xbin/pppd –detach modem crtscts debug
/dev/ttyUSB0 460800 noipdefault
defaultroute usepeerdns
connect “/etc/ppp/pppondialer”
Building Process
Add ppp and chat script to source tree (cont.)
vi system/core/rootdir/etc/ppp/pppondialer
#!/system/bin/sh
chat –v –s
TIMEOUT 30
ABORT BUSY
ABORT ERROR
“” ‘ AT’
OK ‘ATZ’
OK ‘ATQ0 V1 E1 S0=0 &C1 &C2 +FCLASS=0’
OK ‘AT+CGDCONT=1,”IP”,”internet”’  internet 為中華電信 APN name
OK ‘AT+CSQ’
OK ‘ATD*99#’
CONNECT ‘’
Building Process
Add ppp and chat script to source tree (cont.)
vi system/core/rootdir/Android.mk
copy_from :=
etc/dbus.conf
etc/init.goldfish.sh
etc/hosts
etc/ppp/ppp-startup.sh
etc/ppp/pppondialer
vi vendor/asus/eeepc_701/init.rc
Add “chmod 777 /etc/ppp/ppp-startup.sh”
Add “chmod 777 /etc/ppp/pppondialer ”
Add “symlink /dev/ttyUSB0 /dev/3GModem”
Add “chmod 777 /dev/3GModem”

copy chat sources to chat folder in android

make chat from froyo root dir

Advertisements

One thought on “Add 3G modem to IGEP – Android

  1. Vinayak

    Hi,

    Its quite interesting topic. I tried on Beagleboard with ZTE modem device(MTS MBlaze). I failed to interface. Let me know, Is there any changes in procedure with respect to Beagleboard or ZTE modem?

    Thanks,
    Vinayak

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s