TI-Android-JB-4.2.2-DevKit-4.1.1 PortingGuide

From Texas Instruments Wiki
Jump to: navigation, search
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.

Contents

About this manual

The goal of Porting Guide is to provide valuable information and instructions to people who want to run Android OS on their (new) HW. Information covered here will mainly be useful to port TI Android JB DevKit on Sitara-based devices.


Note: Detailed porting information in the different technical areas is dependent on the respective h/w architecture. The information provided here generally refers to the AM335x devices.

Base Port

The Android Board-specific configuration files are present in device/ti/<boardname>. e.g for am335xevm, the files are at <android sources root>/device/ti/am335xevm.

The Jelly Bean release uses board-specific init file instead of the unified init.rc used in previous releases. The board name is determined by the android property ro.hardware which is the machine name set in the board file in the kernel. So the init file for am335xevm becomes init.am335xevm.rc.

Display

Introduction

This section of the porting guide describes the display system with respect to TI Android JB DevKit. AM335x EVM, AM335x Starter Kit and BeagleBone with LCD cape use LCD interface for display while BeagleBone Black (without LCD cape) uses HDMI output.

Depending on the display size, android uses either the phone layout (e.g. AM335xevm) or tablet layout (BeagleBone Black).

Features Overview

  • Supports LCD display interface on AM335x EVM, AM335x Starter Kit and BeagleBone with LCD cape
  • Supports DVI output on BeagleBone with DVI-D cape
  • Supports HDMI output on BeagleBone Black without any cape

Android Display Subsystem Overview

See AOSP Graphics Guide at http://s.android.com/devices/graphics.html

Driver Configuration

Android Configuration

Display density

The TI Android DevKit configures Android for mdpi display (dpi=160) for AM335x EVM, BeagleBone and BeagleBone Black. AM335x Starter Kit is configured as ldpi display (dpi=120)

The dpi setting is done in device.mk as follows: (eg AM335x Starter Kit)

PRODUCT_PROPERTY_OVERRIDES += \
    ro.sf.lcd_density=120

Navigation Keys

To activate the Software Navigation Bar, add the following line in overlay/frameworks/base/core/res/res/values/config.xml. This is done by default for AM335x EVM

<bool name="config_showNavigationBar">true</bool>

In case you have a Landscape Display and the resolution is not high enough to enter Tablet-mode, you will see a Vertical Navigation Bar. To view the Navigation keys correctly in this case add the following lines in init.{ro.hardware}.rc

# This board has landscape LCD, enable rotation of keys on Navigation bar
setprop lcd.landscape true

Display backlight

Introduction

This section explains how the LCD backlight control is implemented in the DevKit. For variable backlight intensity, PWM-controlled backlight is generally used.

Driver Configuration

TBD

Android Configuration

For integration with the Android Backlight settings configuration, the liblights HAL needs to be implemented for the board. The output HAL library should have the name lights.<TARGET_PRODUCT>.so. E.g. for AM335x EVM, the liblights HAL is called lights.am335xevm.so.

The liblights backlight HAL for AM335x EVM is implemented at device/ti/am335xevm/liblights.

Android 4.2.2 framework requires the brightness scale to be 0-255. In TI Android DevKit liblights HAL, we map the 0-255 scale in Android framework to the 0-100 scale as supported by the LCD backlight driver. You can however specify the minimum brightness below which Brightness cannot be reduced from the Android settings in the overlay (e.g AM335x EVM overlay/frameworks/base/core/res/res/values/config.xml)

<!-- Minimum screen brightness setting allowed by the power manager.
     The user is forbidden from setting the brightness below this level. -->
<integer name="config_screenBrightnessSettingMinimum">50</integer>
<integer name="config_screenBrightnessDim">50</integer>

A setting of 50 in the Android framework corresponds to ~20% duty cycle on AM335x EVM.

Touchscreen

Introduction

The touchscreen is the primary input device for TI Android DevKit on AM335xevm, AM335x Starter Kit and BeagleBone LCD7/LCD3 cape

Features Overview

The features supported by Touchscreen in Android are:

  • Single touch input
  • Single click
  • Single long click
  • Uni-direction motion touch

Driver Configuration

Add touchscreen driver support

Test touch driver using getevent

  • Once ADC Touchscreen driver is up through board file (e.g. board-am335xevm.c) configuration.
  • Test with AndroidFS as events are coming while touching the LCD display. Run on command prompt:
    # getevent
    add device 1: /dev/input/event1
      name:     "ti-tsc-adcc"

    /dev/input/event1: 0003 0000 00000659
    /dev/input/event1: 0003 0001 00000a31
    /dev/input/event1: 0001 014a 00000001
    /dev/input/event1: 0000 0000 00000000
    /dev/input/event1: 0003 0000 00000654
    /dev/input/event1: 0000 0000 00000000
    
  • It confirms that touch inputs and irq based event generation is working fine.

Touch Calibration

The platform data for TSC driver for AM335x contains the following fields to provide calibration data:

static struct tsc_data am335xevm_touchscreen_data = {
...
        .x = {
                .min = 0xCB,
                .max = 0xF9B,
                .inverted = 1,
        },
        .y = {
                .min = 0xC8,
                .max = 0xE93,
                .inverted = 1,
        },
...

X-axis is from left to right and Y-axis from top to bottom.

min and max values are the actual touch data obtained at the extreme corners of the LCD screen. You can obtain the raw value returned by the touchscreen at the corners using the getevent utility in Android. Use the values for ABS_X and ABS_Y

root@android:/ # getevent -tl /dev/input/event3                                
[    2331.426687] EV_ABS       ABS_X                00000ea7            
[    2331.426687] EV_ABS       ABS_Y                00000819            
[    2331.426718] EV_ABS       ABS_PRESSURE         000000b8            
[    2331.426718] EV_KEY       BTN_TOUCH            DOWN                
[    2331.426718] EV_SYN       SYN_REPORT           00000000

Test Touch Calibration in Android

  • Run android on the board.
  • select "Menu" -> "Dev Tools" -> "Pointer Location" utility
  • Touch and draw on the screen and observe that the expected points are getting marked on the LCD screen.
  • if drawing on LCD is not proper then driver needs to be fine tune the above mentioned macros.

Android Touchscreen configuration

An .idc file is required to register the touch driver correctly with Android. AM335x uses ti-tsc touchscreen driver, so the .idc file becomes ti-tsc.idc. See device/ti/am335xevm/ti-tsc.idc

Refer the AOSP guide on touch devices at http://source.android.com/tech/input/touch-devices.html for more information.

In the TI Android DevKit, touchscreen is set as the default input device. commit

Keypad

Introduction

The matrix gpio keypad and Volume gpio keys are in AM335x EVM. Here porting explanation for matrix gpio keypad controller.

Features Overview

  • 3x2 matrix key layout supported
  • single click input

Driver Configuration

Add keypad driver support

  • start the Linux Kernel Configuration tool:
    $ make ARCH=arm menuconfig
  • Select Device Drivers from the main menu.
    ...
    Power management options --->
    [*] Networking support --->
    '''Device Drivers --->'''
    File systems --->
    Kernel hacking --->
    ...
  • Select Input device support form the next menu:
    ...
    [ ] ISDN support  --->
    < > Telephony support  --->
    '''Input device support  --->'''
    Character devices  --->
    -*- I2C support  --->
    ...
  • Select Keyboards from the next menu:
    ...
    < >   Reset key
          *** Input Device Drivers ***
    '''[*]   Keyboards  --->'''
    [ ]   Mice  --->
    [ ]   Joysticks/Gamepads  --->
....
  • Select GPIO driven matrix keypad support and GPIO Buttons from the next menu:
    ....
 < >   DECstation/VAXstation LK201/LK401 keyboard
 <*>   GPIO Buttons
 < >   Polled GPIO buttons
 < >   TCA6416/TCA6408A Keypad Support
 <*>   GPIO driven matrix keypad support
 < >   Maxim MAX7359 Key Switch Controller
....

Board-specific Configuration The board-specific configuration includes, specifying the GPIOs, no. of rows and columns, debounce, scan settings etc. The following code snippet shows the configuration for AM335x EVM (arch/arm/mach-omap2/board-am335xevm.c).

static const uint32_t am335x_evm_matrix_keys[] = {
        KEY(0, 0, KEY_MENU),
        KEY(1, 0, KEY_BACK),
        KEY(2, 0, KEY_LEFT),

        KEY(0, 1, KEY_RIGHT),
        KEY(1, 1, KEY_ENTER),
        KEY(2, 1, KEY_DOWN),
};

const struct matrix_keymap_data am335x_evm_keymap_data = {
        .keymap      = am335x_evm_matrix_keys,
        .keymap_size = ARRAY_SIZE(am335x_evm_matrix_keys),
};

static const unsigned int am335x_evm_keypad_row_gpios[] = {
        GPIO_TO_PIN(1, 25), GPIO_TO_PIN(1, 26), GPIO_TO_PIN(1, 27)
};

static const unsigned int am335x_evm_keypad_col_gpios[] = {
        GPIO_TO_PIN(1, 21), GPIO_TO_PIN(1, 22)
};

static struct matrix_keypad_platform_data am335x_evm_keypad_platform_data = {
        .keymap_data       = &am335x_evm_keymap_data,
        .row_gpios         = am335x_evm_keypad_row_gpios,
        .num_row_gpios     = ARRAY_SIZE(am335x_evm_keypad_row_gpios),
        .col_gpios         = am335x_evm_keypad_col_gpios,
        .num_col_gpios     = ARRAY_SIZE(am335x_evm_keypad_col_gpios),
        .active_low        = false,
        .debounce_ms       = 5,
        .col_scan_delay_us = 2,
};

...

static struct gpio_keys_button am335x_evm_volume_gpio_buttons[] = {
        {
                .code                   = KEY_VOLUMEUP,
                .gpio                   = GPIO_TO_PIN(0, 2),
                .active_low             = true,
                .desc                   = "volume-up",
                .type                   = EV_KEY,
                .wakeup                 = 1,
        },
        {
                .code                   = KEY_VOLUMEDOWN,
                .gpio                   = GPIO_TO_PIN(0, 3),
                .active_low             = true,
                .desc                   = "volume-down",
                .type                   = EV_KEY,
                .wakeup                 = 1,
        },
};

static struct gpio_keys_platform_data am335x_evm_volume_gpio_key_info = {
        .buttons        = am335x_evm_volume_gpio_buttons,
        .nbuttons       = ARRAY_SIZE(am335x_evm_volume_gpio_buttons),
};

Test keypad driver using getevent

  • Once matrix gpio keypad and volume gpio keys driver is up through board file (e.g. board-am335xevm.c) configuration.
  • Test with AndroidFS as events are coming while pressing the keys. Run on command prompt:
    # getevent
    add device 1: /dev/input/event2
            name: "gpio-keys"
    add device 2: /dev/input/event0
            name: "matrix-keypad"

    /dev/input/event0: 0004 0004 00000002
    /dev/input/event0: 0001 009e 00000001
    /dev/input/event0: 0000 0000 00000000
    /dev/input/event0: 0004 0004 00000002
    /dev/input/event0: 0001 009e 00000000
    /dev/input/event0: 0000 0000 00000000
    
  • It confirms that keypad inputs and irq based event generation is working fine.

Android Keypad Configuration

  • Android requires Key layout files (.kl files) for mapping Linux key codes and axis codes to Android key codes and axis codes and specifying associated policy flags.
  • The <matrix keypad driver name>.kl (e.g. QWERTY_Keypad.kl) or <gpio keypad driver name>.kl (e.g. gpio-keys.kl) should be present in root directory of AndroidFS.
  • Syntax of a Key layout File (Refer to the link: http://source.android.com/tech/input/key-layout-files.html):
  • Key declarations each consist of the keyword "key" followed by a Linux key code number(In Decimal), an Android key code name, and optional set of whitespace delimited policy flags.
  • For example:
  The gpio-keys.kl for Beaglebone looks like:
  # Beaglebone LCD Cape  GPIO KEYPAD keylayout
  key 105   BACK               WAKE
  key 106   HOME               WAKE
  key 103   MENU               WAKE
  key 108   SEARCH             WAKE
  key 28    POWER              WAKE


MMC

Introduction

The MMC/SD card is used as the primary boot device and storage device on TI Android DevKit. This section gives details on configuring the MMC interface and supporting MMC/SD storage card.


Features Overview

The MMC/SD/SDIO driver supports following features

  • The driver is built in-kernel (part of vmlinux).
  • MMC cards including High Speed cards.
  • SD cards including SD High Speed and SDHC cards
  • Uses block bounce buffer to aggregate scattered blocks


Driver Configuration

Android MMC HAL or Vold Configuration

Android system uses vold as the mount daemon, which detects, mounts and monitors the status of sdcard. The mount daemon needs a configuration file to tell it what the sdcard device is. Since Android 2.2 (froyo), it ships with a new implementation of vold (aka vold2). The configuration is changed to /etc/vold.fstab and its format is also changed. See system/core/rootdir/etc/vold.fstab in the Android source tree for the detailed explanations of the format.

However, a fixed vold.fstab can only support block device with fixed name.

# cat /etc/vold.fstab
dev_mount sdcard /mnt/sdcard 3 /devices/platform/omap/omap_hsmmc.0/mmc_host/mmc0
dev_mount usb /mnt/usb2 auto /devices/platform/omap/ti81xx-usbss/musb-hdrc.1/usb1

Depending on the interface used these values can change. Best way is to probe sysfs directories to find the fixed name. For MMC the entry will be of the form:

 /sys/devices/platform/omap/omap_hsmmc.X/mmc_host/mmcY


Update the android storage list overlay at overlay/frameworks/base/core/res/res/xml/storage_list.xml

<StorageList xmlns:android="http://schemas.android.com/apk/res/android">
    <storage android:mountPoint="/storage/sdcard0"
             android:storageDescription="@string/storage_internal"
             android:primary="true"
             android:emulated="true"
             android:mtpReserve="100" />
</StorageList>

Audio

This release supports audio playback and capture at 44.1kHz. For application-specific usage, the audio HAL supports the software resampler. The audio HAL is implemented at hardware/ti/omap3/audio. The audio HAL uses the file mixer_paths.xml to configure the audio driver. This file contains the ALSA mixer settings for the various audio paths supported by the driver. The mixer_paths.xml is present at device/ti/<boardname> and is copied to the filesystem by the entry in device.mk. The following is the contents of mixer_paths.xml for AM335x EVM

<mixer>
  <!-- These are the initial mixer settings -->
  <ctl name="DAC IF1 SWITCH" value="Normal" />

  <path name="speaker">
    <ctl name="PCM Playback Volume" value="120" />
  </path>

  <path name="headphone">
    <ctl name="PCM Playback Volume" value="120" />
  </path>

  <path name="headset-mic">
    <ctl name="Mic Jack Switch" value="1" />
    <ctl name="Analog Left AUXL Capture Switch" value="1" />
    <ctl name="Analog Right AUXR Capture Switch" value="1" />
    <ctl name="Analog Capture Volume" value="3"/>
   </path>
</mixer>

The mixers setting commands at the beginning of the file are executed when the audio HAL is initialized. The mixer settings within the various <paths> are executed when that mode of operation is selected.

Testing audio from command line

You can use tinyalsa utilities to test audio input/output from shell.

  • To play simple audio
   # tinyplay testfile.wav -n 16
  • To record simple audio
   # tinycap testfile.wav -n 16

NOTE: Android handles volume control in software. We recommend to keep the default volume levels close to maximum in the audio HAL.

WLAN

Introduction

This section of guide provides a step by step explanation of what's involved in adding a new WiFi driver and making WiFi work in a custom Android build like Rowboat.

Features Overview

  • WLAN (802.11 b/g/n)
  • Core IP pre-tested against WiFi specifications.
  • Station mode is fully supported.
  • Initial support for SoftAP/WiFi hotspot and WiFi Direct is available


Android WLAN Sub-System Overview

WLAN Stack.jpg

Diagram explains WLAN event flow from application to h/w with respect to rowboat android source tree.

Application

  • Settings/Connection Manager:<android-src>/packages/apps/Settings/src/com/android/settings/WirelessSettings.java

Application Framework

  • WiFi manager:<android-src>/frameworks/base/wifi/java/android/net/wifi
  • JNI Implementation:<android-src>/frameworks/base/core/jni/android_net_wifi_Wifi.cpp

Libraries

  • libhardware_legacy:<android-src>/hardware/libhardware_legacy/wifi/wifi.c
  • wpa_supplicant (Daemon):<android-src>/external/hostap/wpa_supplicant
  • Higher level network management is done in <android-src>/frameworks/base/core/java/android/net.

Driver Configuration

In this Devkit release we are using WL12XX Compat wireless SDK. The drivers and firmwares of WL12XX Compat release are at hardware/ti/wlan

To enable WLAN support in kernel the following settings need to be enabled:

  • First enable Wireless LAN device driver as shown below:
   Device Drivers  --->
       [*] Network device support  --->
           [*]   Wireless LAN --->
  • Enable WLAN Networking support as shown below:
   [*] Networking support  --->
       -*-   Wireless  --->
           [*]   Wireless extensions sysfs files

This enables the following CONFIG options in kernel and allows WL12xx compat wlan drivers to be built:

   CONFIG_WLAN=y
   CONFIG_WIRELESS_EXT=y
   CONFIG_WEXT_CORE=y
   CONFIG_WEXT_PROC=y
   CONFIG_WEXT_PRIV=y
  • The following additional options need to be enabled in kernel for WLAN to operate
  CONFIG_KEYS=y
  CONFIG_SECURITY=y
  CONFIG_CRYPTO=y
  CONFIG_CRYPTO_ARC4=y
  CONFIG_CRYPTO_ECB=y
  CONFIG_CRYPTO_AES=y
  CONFIG_CRYPTO_MICHAEL_MIC=y
  CONFIG_CRC7=y
  • The relevant initialization and pin-muxing for MMC bus is done in the relevant board file e.g for AM335xevm arch/arm/mach-omap2/board-am335xevm.c. Do take care of this initialization and pin-muxing if using any other MMC bus e.g. MMC3.

The following code snippet shows the board-specific WLAN configuration done on AM335xevm. The code below is provided for information only and is not complete. Please refer to the source for more details.

File: arch/arm/mach-omap2/board-am335xevm.c arch/arm/mach-omap2/board-am335xevm.c
struct wl12xx_platform_data am335xevm_wlan_data = {
        .irq = OMAP_GPIO_IRQ(AM335XEVM_WLAN_IRQ_GPIO),
        .board_ref_clock = WL12XX_REFCLOCK_38_XTAL, /* 38.4Mhz */
        .bt_enable_gpio = GPIO_TO_PIN(3, 21),
        .wlan_enable_gpio = GPIO_TO_PIN(1, 16),
};

/* Module pin mux for wlan and bluetooth */
static struct pinmux_config mmc2_wl12xx_pin_mux[] = {
        {"gpmc_a1.mmc2_dat0", OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLUP},
        {"gpmc_a2.mmc2_dat1", OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLUP},
        {"gpmc_a3.mmc2_dat2", OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLUP},
        {"gpmc_ben1.mmc2_dat3", OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLUP},
        {"gpmc_csn3.mmc2_cmd", OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLUP},
        {"gpmc_clk.mmc2_clk", OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLUP},
        {NULL, 0},
};
...
static int wl12xx_set_power(struct device *dev, int slot, int on, int vdd)
{
        if (on) {
                gpio_direction_output(am335xevm_wlan_data.wlan_enable_gpio, 1);
                mdelay(70);
        } else {
                gpio_direction_output(am335xevm_wlan_data.wlan_enable_gpio, 0);
        }

        return 0;
}

static void wl12xx_init(int evm_id, int profile)
{
...
        if (wl12xx_set_platform_data(&am335xevm_wlan_data))
                pr_err("error setting wl12xx data\n");

        dev = am335x_mmc[1].dev;
        if (!dev) {
                pr_err("wl12xx mmc device initialization failed\n");
                goto out;
        }
...
        ret = gpio_request_one(am335xevm_wlan_data.wlan_enable_gpio,
                GPIOF_OUT_INIT_LOW, "wlan_en");
...
        setup_pin_mux(wl12xx_pin_mux);

        pdata->slots[0].set_power = wl12xx_set_power;
out:
        return;
}


See also: WL127x WiLink6 Portal

Android WiFi HAL Configuration

  • Enable building of TI version of wpa_supplicant 0.8.x in your BoardConfig.mk (e.g. device/ti/am335xevm/BoardConfig.mk for AM335xevm)

This is by simply adding following options in BoardConfig.mk:

   BOARD_WPA_SUPPLICANT_DRIVER      := NL80211
   WPA_SUPPLICANT_VERSION           := VER_0_8_X_TI
   BOARD_WLAN_DEVICE                := wl12xx_mac80211
   BOARD_SOFTAP_DEVICE              := wl12xx_mac80211
   WIFI_DRIVER_MODULE_PATH          := "/system/lib/modules/wl12xx_sdio.ko"
   WIFI_DRIVER_MODULE_NAME          := "wl12xx_sdio"

This will set WPA_BUILD_SUPPLICANT to true in external/wpa_supplicant_8_ti/Android.mk enabling building of wpa_supplicant 0.8.x with NL80211. At run time wl12xx_sdio will get loaded from WIFI_DRIVER_MODULE_PATH.

BOARD_SOFTAP_DEVICE := wl12xx_mac80211 needs to be set only if SoftAP/hotspot feature is required.

  • Next we need to provide a proper wpa_supplicant.conf for our device. That we will keep in /data/misc/wifi.
  • Set the correct permissions and paths created and load the core wi-fi drivers from init.am335xevm.rc
# wi-fi
   mkdir /data/misc/wifi/sockets 0770 wifi wifi
   mkdir /data/misc/dhcp 0770 dhcp dhcp
   insmod /system/lib/modules/compat.ko
   insmod /system/lib/modules/cfg80211.ko
   insmod /system/lib/modules/mac80211.ko
   insmod /system/lib/modules/wlcore.ko
   insmod /system/lib/modules/wl12xx.ko
   insmod /system/lib/modules/wl18xx.ko

  • Set the wifi interface name in device.mk
  PRODUCT_PROPERTY_OVERRIDES := \
       wifi.interface=wlan0
  • Start wpa_supplicant and dhcpcd from init.am335xevm.rc.
service wpa_supplicant /system/bin/wpa_supplicant \
       -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
       -e/data/misc/wifi/entropy.bin
       class main
       socket wpa_wlan0 dgram 660 wifi wifi
       disabled
       oneshot
service dhcpcd_wlan0 /system/bin/dhcpcd -ABKL
       class main
       disabled
       oneshot
service iprenew_wlan0 /system/bin/dhcpcd -n
       class main
       disabled
       oneshot

The following entries are required to configure SoftAP/hotspot and WiFi Direct functions:

  • Register hostap service for SoftAP/hotspot:
service hostapd_bin /system/bin/hostapd -d /data/misc/wifi/hostapd.conf
   socket wpa_wlan0 dgram 660 wifi wifi
   disabled
   oneshot
  • Register the supplicant and dhcp hooks for WiFi Direct:
service p2p_supplicant /system/bin/wpa_supplicant \
       -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf -N \
       -ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf \
       -puse_p2p_group_interface=1
       class main
       socket wpa_wlan0 dgram 660 wifi wifi
       disabled
       oneshot
service dhcpcd_p2p /system/bin/dhcpcd -aABKL
   disabled
   oneshot
service iprenew_p2p /system/bin/dhcpcd -n
   disabled
   oneshot

Overlay changes

The following entries enable Wi-Fi for use by android network manager.

Add the following entries in device/ti/<boardname>/overlay/frameworks/base/core/res/res/values/config.xml

<string-array translatable="false" name="networkAttributes">
...
        <item>"wifi,1,1,1,-1,true"</item>
        <item>"wifi_p2p,13,1,0,-1,true"</item>
...
    </string-array>

<string-array translatable="false" name="radioAttributes">
        <item>"1,1"</item>
...
    </string-array>

Add the required permissions file into the android filesystem by updating device.mk. This also enables the Wi-Fi and Wi-Fi Direct options in the Settings App.

PRODUCT_COPY_FILES := \
...
    frameworks/native/data/etc/android.hardware.wifi.xml:system/etc/permissions/android.hardware.wifi.xml \
    frameworks/native/data/etc/android.hardware.wifi.direct.xml:system/etc/permissions/android.hardware.wifi.direct.xml

Verify WLAN from console

The following steps perform basic checks to see if WiFi driver is operational:

# lsmod
wl12xx 142062 0 - Live 0xbf08d000 (O)
mac80211 248275 1 wl12xx, Live 0xbf03c000 (O)
cfg80211 161123 2 wl12xx,mac80211, Live 0xbf004000 (O)
compat 1706 0 - Live 0xbf000000 (O)


# insmod /system/lib/modules/wl12xx_sdio.ko
[  154.549804] wl1271: loaded

If you do not see the message wl1271: loaded after inserting wl12xx_sdio.ko kernel module, the wifi driver initialization may not be correct. Please ensure that all the relevant pinmuxing and gpio configuration is correct and not over-written.

Next, check that the driver is not unloaded after initialization:

# netcfg
lo       UP                                   127.0.0.1/8   0x00000049 00:00:00:00:00:00
sit0     DOWN                                   0.0.0.0/0   0x00000080 00:00:00:00:00:00
eth0     UP                               172.24.190.76/22  0x00001043 40:5f:c2:76:4c:99
wlan0    DOWN                                   0.0.0.0/0   0x00001002 00:12:34:56:78:90

If wlan0 is not available in netcfg output, the driver might have been unloaded due to some error.

Now, we try to up the wlan0 interface:

# netcfg wlan0 up
[ 8255.485626] wl1271: firmware booted (Rev 6.3.6.0.79_2)
[ 8255.491027] wl1271: Driver version: R4_SP2_03_00
[ 8255.515350] ADDRCONF(NETDEV_UP): wlan0: link is not ready

The above messages show that the interface is up and the firmware is downloaded to wlan module and booted.

Ensure that wlan drivers are unloaded before trying the Android UI for wireless settings

# netcfg wlan0 down
# rmmod wl12xx_sdio

If wlan0 is not available in netcfg output, the driver might have been unloaded due to some error.

TBD

WLAN calibration

  • Copy the ini files used for calibration to the sdcard
  sudo cp -rv rowboat/hardware/ti/wlan/mac80211/ti-utils/ini_files /media/rootfs/system/etc/wifi
  • Boot the board. Make sure WLAN is disabled. wl12xx_sdio.ko should NOT be loaded
root@android:/ # lsmod
omaplfb 10662 0 - Live 0xbf0ed000 (O)
pvrsrvkm 159205 49 omaplfb, Live 0xbf0bc000 (O)
wl12xx 142062 0 - Live 0xbf08e000 (O)
mac80211 251034 1 wl12xx, Live 0xbf03c000 (O)
cfg80211 161115 2 wl12xx,mac80211, Live 0xbf004000 (O)
compat 1706 0 - Live 0xbf000000 (O)
  • Remove existing calibration file
  rm /system/etc/firmware/ti-connectivity/wl1271-nvs.bin
  • Run the calibrator tool
  calibrator plt autocalibrate wlan0 /system/lib/modules/wl12xx_sdio.ko /system/etc/wifi/ini_files/127x/TQS_S_2.6.ini /system/etc/firmware/ti-connectivity/wl1271-nvs.bin

NOTE: Running the calibration results in a random MAC address being set. To set the desired MAC address, run the following step:

  calibrator set nvs_mac /system/etc/firmware/ti-connectivity/wl1271-nvs.bin <MAC Address>

You can verify the MAC address using the following command:

  calibrator get nvs_mac /system/etc/firmware/ti-connectivity/wl1271-nvs.bin

Bluetooth

Introduction

This section describes how to enable Bluetooth support on Android for wl1271 chipset.

Features Overview

  • Bluetooth 2.1
  • OPP, A2DP, AVRCP, HID profiles are supported.
  • HSP, HFP profiles are NOT supported


Android BT Sub-System Overview

Detailed information is available at the AOSP Bluetooth Guide http://s.android.com/devices/bluetooth.html


Enable Bluetooth with the following setting in BoardConfig.mk (e.g. device/ti/am335xevm/BoardConfig.mk)

   # Bluetooth
   BOARD_HAVE_BLUETOOTH := true
   BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := device/ti/am335xevm/bluetooth

The file bdroid_buildcfg.h in device/ti/am335xevm/bluetooth specifies the Bluetooth Device Name

Driver Configuration

TI Android DevKit uses the TI Wilink7 Bluetooth driver along with the TI Shared-Transport driver (TI-ST) for managing the BT-UART.

  • WL12xx BT is interfaced to UART1 on AM335xevm. UART1 initialization and BT module registration with TI-ST is implemented at arch/arm/mach-omap2/board-am335xevm.c
  • Bluetooth support is enabled in the kernel as shown below:
   [*] Networking support  ---> 
       <*>   Bluetooth subsystem support  --->
           [*]   L2CAP protocol support
           <*>   RFCOMM protocol support
           <*>   RFCOMM protocol support
           <*>   BNEP protocol support
           [*]     Multicast filter support
           [*]     Protocol filter support 
           <*>   HIDP protocol support 
                 Bluetooth device drivers  --->
                   <*> HCI UART driver
                   [*]   UART (H4) protocol support 
                   [*]   HCILL protocol support
       <*>   RF switch subsystem support

This enables the following CONFIG options:

CONFIG_BT=y
CONFIG_BT_L2CAP=y
CONFIG_BT_RFCOMM=y
CONFIG_BT_RFCOMM_TTY=y
CONFIG_BT_BNEP=y
CONFIG_BT_BNEP_MC_FILTER=y
CONFIG_BT_BNEP_PROTO_FILTER=y
CONFIG_BT_HIDP=y
CONFIG_BT_HCIUART=y
CONFIG_BT_HCIUART_H4=y
CONFIG_BT_HCIUART_LL=y
CONFIG_RFKILL=y
  • The following CONFIG options enable TI-ST and WiLink Bluetooth driver support:
CONFIG_BT_WILINK=y
CONFIG_TI_ST=y
  • The following kernel configs are required for Bluetooth AVRCP support:
CONFIG_INPUT_MISC=y
CONFIG_INPUT_UINPUT=y

You can check this as follows:

   Device Drivers  --->
       Input device support  --->
           [*]   Miscellaneous devices  --->
                   <*>   User level driver support


The following code-snippet shows board-level configuration for TI-ST on AM335xevm:

File: arch/arm/mach-omap2/board-am335xevm.c
struct ti_st_plat_data wilink_pdata = {
	.nshutdown_gpio = GPIO_TO_PIN(3, 21),
	.dev_name = "/dev/ttyO1",
	.flow_cntrl = 1,
	.baud_rate = 3000000,
	.suspend = plat_kim_suspend,
	.resume = plat_kim_resume,
	.chip_enable = plat_kim_chip_enable,
	.chip_disable = plat_kim_chip_disable,
};

static struct platform_device wl12xx_device = {
	.name		= "kim",
	.id		= -1,
	.dev.platform_data = &wilink_pdata,
};

static struct platform_device btwilink_device = {
	.name = "btwilink",
	.id = -1,
};

static inline void __init am335xevm_init_btwilink(void)
{
	pr_info("am335xevm: bt init\n");

	platform_device_register(&wl12xx_device);
	platform_device_register(&btwilink_device);
}


Android BT HAL Configuration

  • Set the correct permissions and paths created from init.rc
   #Owners, Modes for Bluetooth
   chmod 0660 /dev/ttyO1
   chown bluetooth bluetooth /dev/ttyO1
   chmod 0660 /sys/class/rfkill/rfkill0/state
   chown bluetooth bluetooth /sys/class/rfkill/rfkill0/state
  • The following services are registered in init.rc for Bluetooth operation:
  • dbus-daemon: (deal connections between hcid and system server)
   service dbus /system/bin/dbus-daemon --system --nofork
   class main
   socket dbus stream 660 bluetooth bluetooth
   user bluetooth
   group bluetooth net_bt_admin
  • bluetoothd: create hcid (Bluetooth Host Controller Interface Daemon) service, but disabled at first
   service bluetoothd /system/bin/bluetoothd -n
   class main
   socket bluetooth stream 660 bluetooth bluetooth
   socket dbus_bluetooth stream 660 bluetooth bluetooth
   # init.rc does not yet support applying capabilities, so run as root and
   # let bluetoothd drop uid to bluetooth with the right linux capabilities
   group bluetooth net_bt_admin misc
   disabled
  • uim-sysfs: userspace module for TI-ST kernel driver. This service attaches the BT UART HCI interface to the bluetooth stack at 3000000 baud rate. It is also responsible for loading the BT firmware on WL1271. The sources for uim-sysfs is found in hadware/ti/wpan
   #shared transport user space mgr service for Bluetooth, FM and GPS
   service uim /system/bin/uim-sysfs
   class core
   user bluetooth
   group bluetooth net_bt_admin

Overlay changes

Add bluetooth entry in the overlay to indicate bluetooth availability to network manager

<string-array translatable="false" name="networkAttributes">
...
    <item>"bluetooth,7,7,0,-1,true"</item>
...
</string-array>

<string-array translatable="false" name="radioAttributes">
...
    <item>"7,1"</item>
...

Copy the Bluetooth permissions file and the relevant bluez conf file. The permissions file also enables Bluetooth menu in Settings

PRODUCT_COPY_FILES += \
    frameworks/native/data/etc/android.hardware.bluetooth.xml:system/etc/permissions/android.hardware.bluetooth.xml \
    system/bluetooth/data/main.nonsmartphone.conf:system/etc/bluetooth/main.conf

USB Host and Gadget

Introduction

Android JB supports both USB host and USB device ports. USB host can be used to connect Keyboard/Mouse, Mass storage device, modem dongles etc, while the USB device port is mainly used for adb and USB accessory gadgets.

Driver Configuration

-> Device Drivers
   -> USB support
      -> USB Gadget Support
         -> USB Gadget Drivers
            (X) Android Gadget

Android USB Configuration

Android USB Gadget Configuration

USB Gadget configuration for AM335x

The Android gadget driver is configured via the sysfs entries. These are done from init.<ro.hardware>.usb.rc. For am335xevm, this is init.am335xevm.usb.rc

on boot
    write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer}
    write /sys/class/android_usb/android0/iProduct ${ro.product.model}
    write /sys/class/android_usb/android0/iSerial ${ro.serialno}

on property:sys.usb.config=none
    stop adbd
    write /sys/class/android_usb/android0/enable 0
    write /sys/class/android_usb/android0/bDeviceClass 0
    setprop sys.usb.state ${sys.usb.config}

on property:sys.usb.config=adb
    write /sys/class/android_usb/android0/enable 0
    write /sys/class/android_usb/android0/idVendor 18d1
    write /sys/class/android_usb/android0/idProduct D002
    write /sys/class/android_usb/android0/functions ${sys.usb.config}
    write /sys/class/android_usb/android0/enable 1
    setprop sys.usb.state ${sys.usb.config}

on property:sys.usb.config=mtp
    write /sys/class/android_usb/android0/enable 0
    write /sys/class/android_usb/android0/idVendor 18d1
    write /sys/class/android_usb/android0/idProduct D108
    write /sys/class/android_usb/android0/functions ${sys.usb.config}
    write /sys/class/android_usb/android0/enable 1
    setprop sys.usb.state ${sys.usb.config}

on property:sys.usb.config=mtp,adb
    write /sys/class/android_usb/android0/enable 0
    write /sys/class/android_usb/android0/idVendor 18d1
    write /sys/class/android_usb/android0/idProduct D109
    write /sys/class/android_usb/android0/functions ${sys.usb.config}
    write /sys/class/android_usb/android0/enable 1
    start adbd
    setprop sys.usb.state ${sys.usb.config}

The sysfs settings need to be done depending on the features required to be enabled. By default only the adb and mtp mode is configured.

USB Accessory Gadget configuration for AM335x

To indicate that the platform supports USB Host port add the following to device.mk:

PRODUCT_COPY_FILES += \
    frameworks/native/data/etc/android.hardware.usb.accessory.xml:system/etc/permissions/android.hardware.usb.accessory.xml

PRODUCT_PACKAGES += \
    com.android.future.usb.accessory

NOTE: The USB accessory does not work over USB Hub.

Android USB Host Configuration

To indicate that the platform supports USB Host port add the following to device.mk:

PRODUCT_COPY_FILES += \
    frameworks/native/data/etc/android.hardware.usb.host.xml:system/etc/permissions/android.hardware.usb.host.xml

NAND

Introduction

This section of porting guide will describe the NAND layout present on AM335x EVM.Micron MT29F2G08ABA Nand part (AM335x EVM) is supported.

NAND Layout

The NAND on the EVM has been configured in the following manner.

 +------------+-->0x00000000-> SPL start
 |            |
 |            |-->0x0001FFFF-> SPL end  
 |            |-->0x00020000-> SPL.backup1 start
 |            |
 |            |-->0x0003FFFF-> SPL.backup1 end  
 |            |-->0x00040000-> SPL.backup2 start
 |            |
 |            |-->0x0005FFFF-> SPL.backup2 end  
 |            |-->0x00060000-> SPL.backup3 start
 |            |
 |            |-->0x0007FFFF-> SPL.backup3 end  
 |            |-->0x00080000-> U-Boot start
 |            |
 |            |-->0x0025FFFF-> U-Boot end  
 |            |-->0x00260000-> U-Boot ENV start
 |            |
 |            |
 |            |-->0x0027FFFF-> ENV end
 |            |-->0x00280000-> Linux Kernel start
 |            |
 |            |
 |            |
 |            |
 |            |-->0x0077FFFF-> Linux Kernel end
 |            |-->0x00780000-> Filesystem start
 |            |
 |            |
 |            |
 |            |
 |            |
 |            |
 |            |
 |            |
 +------------+-->0x10000000-> Filesystem end


To change NAND layout, modify u-boot and kernel code as mentioned in below code snippet.

Note: u-boot and kernel NAND layout should match as it is.


U-boot NAND Layout

File: drivers/usb/gadget/u_fastboot_nand.c
Here is default NAND layout. Modify start and length fields as needed.

 fastboot_ptentry nand_ptn[MAX_PTN] = {
       {
               .name   = "spl",
               .start  = 0x0000000,
               .length = 0x0020000, /* 128 K */
               /* Written into the first 4 0x20000 blocks
                  Use HW ECC */
               .flags  = FASTBOOT_PTENTRY_FLAGS_WRITE_I |
                         FASTBOOT_PTENTRY_FLAGS_WRITE_HW_BCH8_ECC |
                         FASTBOOT_PTENTRY_FLAGS_REPEAT_4,
       },
       {
               .name   = "uboot",
               .start  = 0x0080000,
               .length = 0x01E0000, /* 1.875 M */
               /* Skip bad blocks on write
                  Use HW ECC */
               .flags  = FASTBOOT_PTENTRY_FLAGS_WRITE_I |
                         FASTBOOT_PTENTRY_FLAGS_WRITE_HW_BCH8_ECC,
       },
       {
               .name   = "environment",
               .start  = NAND_ENV_OFFSET,  /* set in config file */
               .length = 0x0020000,
               .flags  = FASTBOOT_PTENTRY_FLAGS_WRITE_ENV |
                         FASTBOOT_PTENTRY_FLAGS_WRITE_HW_ECC,
       },
       {
               .name   = "kernel",
               .start  = 0x0280000,
               .length = 0x0500000, /* 5 M */
               .flags  = FASTBOOT_PTENTRY_FLAGS_WRITE_I |
                         FASTBOOT_PTENTRY_FLAGS_WRITE_HW_BCH8_ECC,
       },
       {
               .name   = "filesystem",
               .start  = 0x0780000,
               .length = 0xF880000, /* 248.5 M */
               .flags  = FASTBOOT_PTENTRY_FLAGS_WRITE_I |
                         FASTBOOT_PTENTRY_FLAGS_WRITE_HW_BCH8_ECC,
       },
 };


Kernel NAND Layout

File: arch/arm/mach-omap2/board-am335xevm.c

Here is default NAND layout. Modify offset and size fields as needed.

 /* NAND partition information */
 static struct mtd_partition am335x_nand_partitions[] = {
 /* All the partition sizes are listed in terms of NAND block size */
       {
               .name           = "SPL",
               .offset         = 0,                    /* Offset = 0x0 */
               .size           = SZ_128K,
       },
       {
               .name           = "SPL.backup1",
               .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x20000 */
               .size           = SZ_128K,
       },
       {
               .name           = "SPL.backup2",
               .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x40000 */
               .size           = SZ_128K,
       },
       {
               .name           = "SPL.backup3",
               .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x60000 */
               .size           = SZ_128K,
       },
       {
               .name           = "U-Boot",
               .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x80000 */
               .size           = 15 * SZ_128K,
       },
       {
               .name           = "U-Boot Env",
               .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x260000 */
               .size           = 1 * SZ_128K,
       },
       {
               .name           = "Kernel",
               .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x280000 */
               .size           = 40 * SZ_128K,
       },
       {
               .name           = "File System",
               .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x780000 */
               .size           = MTDPART_SIZ_FULL,
       },
 };



Fastboot

The fastboot protocol is a mechanism for communicating with bootloaders over USB. It is designed to flash Android build images(x-loader, bootloader, kernel, system, userdata etc) on to the target device.

Fastboot is implemented in u-boot. TI-Android-JB-4.2.2-DevKit-4.1.1 release fastboot implementation supports NAND and eMMC/SD flashing.

NAND Flashing

To configure fastboot for NAND flashing, make sure that CONFIG_FASTBOOT_NAND is defined in <u-boot/>include/configs/am335x_evm.h file.

  File: <u-boot/>include/configs/am335x_evm.h
  #define CONFIG_FASTBOOT_NAND

NAND Partition Layout

Please refer to U-boot NAND Layout section for more details.

eMMC Flashing

To configure fastboot for eMMC/SD flashing, make sure that CONFIG_FASTBOOT_NAND is not defined in u-boot/include/configs/am335x_evm.h file.

eMMC Partition Layout

Default eMMC partitioning layout is defined in u-boot/drivers/usb/gadget/u_fastboot_mmc.c file. The entry for each partition can be modified as per the requirement.

  File: drivers/usb/gadget/u_fastboot_mmc.c
  
  /* eMMC partition layout (All sizes are in kB)
   * Modify the below partition table to change the GPT configuration.
   * The entry for each partition can be modified as per the requirement.
   */
  static struct partition partitions[] = {
       { "-", 128 },                   /* Master Boot Record and GUID Partition Table */
       { "spl", 128 },                 /* First stage bootloader */
       { "bootloader", 512 },          /* Second stage bootloader */
       { "misc", 128 },                /* Rserved for internal purpose */
       { "-", 128 },                   /* Reserved */
       { "recovery", 8*1024 },         /* Recovery partition  */
       { "boot", 8*1024 },             /* Partition contains kernel + ramdisk images */
       { "system", 256*1024 },         /* Android file system */
       { "cache", 256*1024 },          /* Store Application Cache */
       { "userdata", 256*1024 },       /* User data */
       { "media", 0 },                 /* Media files */
       { 0, 0 },
  };

Fastboot Transfer Size

BeagleBone white, AM335x-SK and old AM335xEVMs have only 256MB RAM. To be compatible with all devices, default fastboot assume 256MB max RAM.

The current fastboot implementation assumes maximum 16MB of RAM will be used by u-boot itself. So the maximum fastboot transfer buffer in current implentation is (256-16)= 240MB, which means transfer image size is limited to 240MB. Fastboot will reject flashing for images more than 240MB size.

You can change fastboot maximum tranfer size by modifying following macro.

  File: include/configs/am335x_evm.h
  
  #define CONFIG_FASTBOOT_MAX_TRANSFER_SIZE       (SZ_256M - SZ_16M)

Sensors

Accelerometer

The STMicro LIS33 Accelerometer is supported on AM335x evm.

Kernel driver for accelerometer on AM335x : http://gitorious.org/rowboat/kernel/trees/rowboat-am335x-kernel-3.2/drivers/misc/lis3lv02d

Android HAL on AM335xevm: http://gitorious.org/rowboat/vendor-ti-am335xevm/trees/rowboat-jb/libsensors

To indicate accelerometer support to android add the following line in device.mk

PRODUCT_COPY_FILES += \
    frameworks/native/data/etc/android.hardware.sensor.accelerometer.xml:system/etc/permissions/android.hardware.sensor.accelerometer.xml

Light sensor

AM335x evm supports light sensor TSL2550.

Light sensor kernel driver : http://gitorious.org/rowboat/kernel/blobs/rowboat-am335x-kernel-3.2/drivers/misc/tsl2550.c

Please note that the standard linux driver is modified to report light sensor values to the input sub-system. See commit.

Android HAL on AM335xevm: http://gitorious.org/rowboat/vendor-ti-am335xevm/trees/rowboat-jb/libsensors

To indicate light sensor support to android add the following line in device.mk

PRODUCT_COPY_FILES += \
    frameworks/native/data/etc/android.hardware.sensor.light.xml:system/etc/permissions/android.hardware.sensor.light.xml

You can use the light sensor input to modify the LCD backlight intensity. You need to add the following entry in the overlay:

  <bool name="config_automatic_brightness_available">true</bool>

Also you need to implement a lookup table to map the light intensity to the LCD backlight values. Please refer to the overlay patch file for more details.

Temperature Sensor

AM335xevm supports temperature sensor LM75.

Kernel driver path : https://gitorious.org/rowboat/kernel/blobs/rowboat-am335x-kernel-3.2/drivers/hwmon/lm75.c The driver is modified to be compatible with the android sensor input subsystem. See commits here and here

Android HAL for AM335xevm is at :http://gitorious.org/rowboat/vendor-ti-am335xevm/trees/rowboat-jb/libsensors

USB camera

This section discusses interfacing USB camera with android

Kernel configuration

Enable the following CONFIGs to add support for USB camera in kernel:

  CONFIG_USB_VIDEO_CLASS=y
  CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV=y

Android Configuration

Enable USB Camera support in BoardConfig.mk. Also disable stub camera

   BOARD_USB_CAMERA := true
   #USE_CAMERA_STUB := true

Add the following entries in device.mk

#Camera
PRODUCT_PACKAGES += \
        camera.omap3 \

NOTE: The Camera icon will automatically appear in apps due to presence of camera.omap3.so in the filesystem.

Add permission for camera in init.am335xevm.rc. This is used for temporary storage before capture.

   mkdir /data/misc/camera 0770 media media

Add camera permissions in ueventd.am335xevm.rc

  /dev/video0         0666  root       root

The Camera HAL is at hardware/ti/omap3/camera.

NOTE: By default it is assumed that the USB camera is registered as /dev/video0 ( source ). You may need to change this for your device.

USB 3G Modem

Introduction

This section describes how to integrate USB 3G modem with Android.

Android Telephony Architecture

The diagram illustrates the Android's Telephony system architecture.

AndroidTelephony.gif

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 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

  EnableLogging=1

  DefaultVendor= 0x12d1
  DefaultProduct=0x1446

  TargetVendor=  0x12d1
  TargetProductList="1001,1406,140b,140c,1412,141b,1436,14ac,1506"

  CheckSuccess=20

  MessageEndpoint= 0x01
  MessageContent="55534243123456780000000000000011062000000100000000000000000000"

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
 #    http://www.draisberghof.de/usb_modeswitch/#download
 #    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
     disabled
     oneshot

Start usb_modeswitch Service

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

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

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

Disclaimer

  • All components explained in this porting guide are validated against TI Android DevKit release 4.2.2.
  • This guide can be taken as reference to port mentioned components on similar architecture.


Technical Support and Product Updates

For further information or to report any problems, contact http://e2e.ti.com/android or http://support.ti.com.
For community support join http://groups.google.com/group/rowboat
For IRC #rowboat on irc.freenode.net