TI-Android-GingerBread-2.3.4-DevKit-2.1.1 PortingGuides

From Texas Instruments Embedded Processors Wiki

Jump to: navigation, search
Translate this page to   

TIBanner.png


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 Android GingerBread DevKit 2.1.1 (with kernel 3.1) on AM335x based devices.

NoteNote: Detailed porting information in the different technical areas is dependent on the respective h/w architecture.

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


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

Application Framework

Libraries

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

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

   Device Drivers  --->
       [*] Network device support  --->
           [*]   Wireless LAN --->
   [*] 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
  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

Android WiFi HAL Configuration

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

  BOARD_WLAN_DEVICE             := wl12xx_mac80211
  BOARD_SOFTAP_DEVICE           := wl12xx_mac80211
  WPA_SUPPLICANT_VERSION        := VER_0_8_X
  BOARD_WPA_SUPPLICANT_DRIVER   := NL80211
  WIFI_DRIVER_MODULE_PATH       := "/system/etc/wifi/wl12xx_sdio.ko"
  WIFI_DRIVER_MODULE_NAME       := "wl12xx_sdio"

This will set WPA_BUILD_SUPPLICANT to true in external/hostap/wpa_supplicant/Android.mk enabling building of wpa_supplicant 0.8 with NL80211. At run time wl12xx_sdio will get loaded from WIFI_DRIVER_MODULE_PATH. We don't need any external WIFI_FIRMWARE_LOADER because our driver module wl12xx_sdio is capable of loading the firmware by itself.

   # give system access to wpa_supplicant.conf for backup and restore
   mkdir /system/etc/wifi 0770 system wifi
   chmod 0770 /system/etc/wifi
   chmod 0660 /system/etc/wifi/wpa_supplicant.conf
   chown system wifi /system/etc/wifi/wpa_supplicant.conf
   mkdir /data/misc/wifi 0770 system wifi
   mkdir /data/misc/wifi/sockets 0770 system wifi
   chmod 0770 /data/misc/wifi
   chmod 0660 /data/misc/wifi/wpa_supplicant.conf
   chown wifi wifi /data/misc/wifi
   chown wifi wifi /data/misc/wifi/wpa_supplicant.conf

Important We use System user(uid: 1000) to initiate wpa_supplicant service that way are able to enable WiFi over Android NFS rootfs. Here is the detailed discussion on that WiFi does not work when booting from an NFS file system

  setprop wifi.interface wlan0:0
   # wpa_supplicant and dhcp daemon
   service wpa_supplicant /system/bin/wpa_supplicant -Dnl80211 -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf -dd -qq
       socket wpa_wlan0:0 dgram 660 wifi wifi
       group system wifi inet
       disabled
   service dhcpcd /system/bin/dhcpcd  -ABKL wlan0:0
       disabled
       oneshot

Note: AOSP 2.3.4 requires using dhcpcd_<ifname> for dhcpc service, but currently this does not work correctly for wlan0:0 interface. This patch is reverted in TI-Android-Gingerbread-2.3.4-DevKit-2.1.1 sources and the service name is changed to dhcpcd.

Bluetooth

Introduction

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

Features Overview


Android BT Sub-System Overview

BT Stack.jpg


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

   # Bluetooth
   BOARD_HAVE_BLUETOOTH := true

This enables bluez external/bluez HAL layer, which is used to connect with Android Frameworks (frameworks/base/core/jni/android_bluetooth_*.cpp, frameworks/base/core/java/android/bluetooth/*.java and SystemServer via DBUS .

Driver Configuration

   [*] 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
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

Android BT HAL Configuration

   #Owners, Modes for Bluetooth
   #console changed to ttyO* from ttyS* since 2.6.37 kernel.
   chmod 0660 /dev/ttyO1
   chown bluetooth bluetooth /dev/ttyO1
   chmod 0660 sys/class/rfkill/rfkill0/state
   chown bluetooth bluetooth /sys/class/rfkill/rfkill0/state
   write /sys/class/rfkill/rfkill0/state 0
   service dbus /system/bin/dbus-daemon --system --nofork
   socket dbus stream 660 bluetooth bluetooth
   user bluetooth
   group bluetooth net_bt_admin
   service bluetoothd /system/bin/bluetoothd -n
   socket bluetooth stream 660 bluetooth bluetooth
   socket dbus_bluetooth stream 660 bluetooth bluetooth
   group bluetooth net_bt_admin misc
   disabled
   service hciattach /system/bin/hciattach -n /dev/ttyO1 texas 3000000
   user root
   group bluetooth net_bt_admin misc
   disabled
   oneshot
   service opush /system/bin/sdptool add --channel=12 OPUSH
   user bluetooth
   group bluetooth net_bt_admin
   disabled
   oneshot

Adding bluetooth profile

Kindly refer the following wiki guide: Android-Adding Bluetooth Profile

Audio

Introduction

AM335x EVM uses AIC31 for audio analog inputs and outputs. It is connected to the main processor through the TDM / I2S interface and used to transmit and receive audio data. The AIC31 audio codec is connected via Multi-Channel Audio Serial Port (McASP) interface, a communication peripheral, to the main processor.

McASP provides a full-duplex direct serial interface between the main processor (AM335x) and other devices in the system such as the AIC31 codec. It provides a direct interface to industry standard codecs, analog interface chips (AICs) and other serially connected A/D and D/A devices:

The AIC31 audio module is controlled by internal registers that can be accessed by the high speed I2C control interface.

This user manual section defines and describes the user level and platform level interfaces of the ALSA SoC Audio driver.

Features Overview

The features supported by ALSA SoC Audio driver are:

Important

Please note that enabling any line-in inputs necessitates connecting an audio playback source's output; connecting a (non-preamplified) microphone input (like the one from a head-set jack) might not work.

Android Audio Sub-System Overview

Audio Stack.jpg


BOARD_USES_ALSA_AUDIO := true
BUILD_WITH_ALSA_UTILS := true


Driver Configuration

To enable/disable audio support, start the Linux Kernel Configuration tool:

$ make ARCH=arm menuconfig
   ...
   ...
   Power management options --->
   [*] Networking support --->
   Device Drivers --->
   File systems --->
   Kernel hacking --->
   ...
   ...
   ...
   ...
   Multimedia devices --->
   Graphics support --->
   <*> Sound card support --->
   [*] HID Devices --->
   [*] USB support --->
   ...
   ...
   --- Sound card support
   <*> Advanced Linux Sound Architecture --->
   < > Open Sound System (DEPRECATED) --->
   ...
   ...
   [*] ARM sound devices  --->
   [*] SPI sound devices  --->
   [*] USB sound devices  --->
   <*> ALSA for SoC audio support --->
   --- ALSA for SoC audio support
   <*> SoC Audio for the AM33XX chip
   <*> SoC Audio support for AM335X EVM
   < > SoC Audio for the Texas Instruments OMAP chips
   < > Build all ASoC CODEC drivers


See also: AM335x Audio Driver's Guide

Android Audio HAL Configuration

Before diving into Android ALSA hardware layer, we have to verify whether ALSA driver is properly working or not. We will use ALSA utilities(alsa_aplay, alsa_arecord, and alsa_amixer) which got build along with Rowboat and is a part of external/alsa-utils package.


By default alsa_arecord doesn't exist. It is a soft link to alsa_aplay. So to create the link run the following command from Android prompt.

# ln -s /system/bin/alsa_aplay /system/bin/alsa_arecord


Important (for AM335x EVM ONLY)

# alsa_arecord -f cd | alsa_aplay

The --help option provides a comprehensive list of command-line options for ALSA utilities.

The above procedure should get your Audio Capture and Playback working from command line. If it is then we are all set to make the corresponding changes in Android HAL layer and that will be all.

Hardware specific ALSA configurations will go here to hardware/ti/omap3/modules/alsa/alsa_module.cpp file.

Select and configure hardware devices

# alsa_aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: EVM [AM335X EVM], device 0: AIC3X tlv320aic3x-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
.....
    {
        module      : 0,
        devices     : OMAP3_OUT_DEFAULT,
        curDev      : 0,
        curMode     : 0,
        handle      : 0,
        format      : SND_PCM_FORMAT_S16_LE, // AudioSystem::PCM_16_BIT
        channels    : 2,
        sampleRate  : DEFAULT_SAMPLE_RATE,
        latency     : 200000, // Desired Delay in usec
        bufferSize  : DEFAULT_SAMPLE_RATE / 11, // Desired Number of samples
        mmap        :0,
        modPrivate  : (void *)&setDefaultControls,
    },
.....


Important
Please note that enabling any line-in inputs necessitates connecting an audio playback source's output ; connecting a (non-preamplified) microphone input (like the one from a head-set jack) might not work.


Display

Introduction

This section of the porting guide describes the display system with respect to AM335x EVM. Display Sub-System hardware integrates one graphics pipeline (for digital interface). Digital interface is used for LCD out.

TFC_S9700RTWV35TR_01B LCD Panel is used on AM335x EVM. Porting explanation for TFC_S9700RTWV35TR_01B LCD Panel is given in this section

Features Overview

Android Display Subsystem Overview

The block diagram below shows the display subsystem in GingerBread android. Android display system is based on a Client/Server Architecture.
Server side: Surface Flinger is a service coded in C++

Client side: Applications can draw on surfaces using two paths:

Surface Flinger Provides system-wide surface “composer”, handling all surface rendering to frame buffer device. Uses OPENGL and hardware accelerator for composing surfaces. Surfaces passed as buffers via binder IPC calls.

Display_system_overview.jpg

























Driver Configuration

Frame Buffer Driver

   ...
   ...
    Power management options  --->
[*] Networking support  --->
    Device Drivers  --->
    File systems  --->
    Kernel hacking  --->
    ...
    ...
    ...
    ...
[*] Voltage and Current Regulator Support  --->
<*> Multimedia support  --->
    Graphics support  --->
<*> Sound card support  --->
[*] HID Devices  --->
    ...
    ...
    ...
    ...
<M> Lowlevel video output switch controls
<*> Support for frame buffer devices  --->
< > Virtual Frame Buffer support (ONLY FOR TESTING!)
    ...
    ...
   ...
    ...
< > Displaylink USB Framebuffer support
<*> DA8xx/OMAP-L1xx Framebuffer support  --->
(4)   Consistent DMA memory size (MB)
< > Virtual Frame Buffer support (ONLY FOR TESTING)  --->
    ...
    ...

Modification in Board File and LCD driver

TFC_S9700RTWV35TR_01B LCD panel LCD timing need to be configure in drivers/video/da8xx-fb.c.

 static const struct display_panel disp_panel = {
        WVGA,
        32,
        32,
        COLOR_ACTIVE,
};

static struct lcd_ctrl_config lcd_cfg = {
        &disp_panel,
        .ac_bias                = 255,
        .ac_bias_intrpt         = 0,
        .dma_burst_sz           = 16,
        .bpp                    = 32,
        .fdd                    = 0x80,
        .tft_alt_mode           = 0,
        .stn_565_mode           = 0,
        .mono_8bit_mode         = 0,
        .invert_line_clock      = 1,
        .invert_frm_clock       = 1,
        .sync_edge              = 0,
        .sync_ctrl              = 1,
        .raster_order           = 0,
};

struct da8xx_lcdc_platform_data TFC_S9700RTWV35TR_01B_pdata = {
        .manu_name              = "ThreeFive",
        .controller_data        = &lcd_cfg,
        .type                   = "TFC_S9700RTWV35TR_01B",
}; 
 static struct da8xx_panel known_lcd_panels[] = {
        ...
        ...
        /* ThreeFive S9700RTWV35TR */
        [2] = {
                .name = "TFC_S9700RTWV35TR_01B",
                .width = 800,
                .height = 480,
                .hfp = 39,
                .hbp = 39,
                .hsw = 47,
                .vfp = 13,
                .vbp = 29,
                .vsw = 2,
                .pxl_clk = 30000000,
                .invert_pxl_clk = 0,
        },
     };


See also: AM335x LCD Controller Driver's Guide

MMC

Introduction

TI AM335x has an multimedia card high-speed/secure data/secure digital I/O (MMC/SD/SDIO) host controller, which provides an interface between microprocessor and either MMC, SD memory cards, or SDIO cards. The current version of the user guide talks about the MMC/SD controller. The MMC driver is implemented on top of host controller as a HS-MMC controller driver and supports MMC, SD, SD High Speed and SDHC cards. The salient features of the aforementioned HS-MMC host controller are:


Features Overview

The MMC/SD/SDIO driver supports following features


Driver Configuration

The default kernel configuration enables support for MMC/SD(built-in to kernel). The selection of MMC/SD/SDIO driver can be modified as follows:

$ make menuconfig  ARCH=arm
...
...
Kernel Features  --->
Boot options  --->
CPU Power Management  --->
Floating point emulation  --->
Userspace binary formats  --->
Power management options  --->
[*] Networking support  --->
Device Drivers  --->
...
...
...
...
[*] USB support  --->
<*> MMC/SD/SDIO card support  --->
< > Sony MemoryStick card support (EXPERIMENTAL)  --->
...
...
...
[ ] MMC debugging
[ ] Assume MMC/SD cards are non-removable (DANGEROUS) 
     *** MMC/SD/SDIO Card Drivers ***
<*> MMC block device driver
[*]  Use bounce buffer for simple hosts
...
<*>   TI OMAP High Speed Multimedia Card Interface support 
...

See also: AM335x MMC/SD Driver's Guide

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

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

Touchscreen

Introduction

The touch controller is TSCADC with ADC interface (in AM335x EVM). This is resistive touch screen controllers.

Features Overview

The features supported by Touchscreen in Android are:

Driver Configuration

Add touchscreen driver support

    $ make ARCH=arm menuconfig
   ...
   Power management options --->
   [*] Networking support --->
   Device Drivers --->
   File systems --->
   Kernel hacking --->
   ...
   ...
   [ ] ISDN support  --->
   < > Telephony support  --->
   Input device support  --->
   Character devices  --->
   -*- I2C support  --->
   ...
   ...
   [ ]   Joysticks/Gamepads  --->
   [ ]   Tablets  --->
   [*]   Touchscreens  --->
   [*]   Miscellaneous devices  --->
   Hardware I/O ports  --->
   ...
   ...
   --- Touchscreens
   < >   Touchwin serial touchscreen
   <*>   TI Touchscreen Interface
   < >   USB Touchscreen Driver
   ...
static struct resource tsc_resources[]  = {
        [0] = {
                .start  = AM33XX_TSC_BASE,
                .end    = AM33XX_TSC_BASE + SZ_8K - 1,
                .flags  = IORESOURCE_MEM,
        },
        [1] = {
                .start  = AM33XX_IRQ_ADC_GEN,
                .end    = AM33XX_IRQ_ADC_GEN,
                .flags  = IORESOURCE_IRQ,
        },
};

static struct tsc_data am335x_touchscreen_data  = {
        .wires  = 4,
        .x_max = 0x0fff,
        .y_max = 0x0fff,
};

static struct platform_device tsc_device = {
        .name   = "tsc",
        .id     = -1,
        .dev    = {
                        .platform_data  = &am335x_touchscreen_data,
        },
        .num_resources  = ARRAY_SIZE(tsc_resources),
        .resource       = tsc_resources,
};

See also: AM335x Touchscreen Driver's Guide

Test touch driver using getevent

    # 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
    

Touch Calibration

    /* Calibrate absolute value of x and y co-ordinate */
    val_x = ts_dev->x_max -
                ((ts_dev->x_max * (val_x - AM335X_TS_XMIN)) /
                    (AM335X_TS_XMAX - AM335X_TS_XMIN));
    val_y = ts_dev->y_max -
                ((ts_dev->y_max * (val_y - AM335X_TS_YMIN)) /
                    (AM335X_TS_YMAX - AM335X_TS_YMIN));

Note: Above four macros need to be fine tune to get the correct absolute value of x and y.

#ifdef CONFIG_MACH_AM335XEVM
#define AM335X_XMIN           0x0A5
#define AM335X_XMAX           0xFB0
#define AM335X_YMIN           0x0DC
#define AM335X_YMAX           0xF43
#endif

Note: sometimes calculation method return negative values. Then method needs some modification to get positive calculated touch inputs.

Test Touch Calibration in Android

Keypad

Introduction

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

Features Overview

Driver Configuration

Add keypad driver support

    $ make ARCH=arm menuconfig
    ...
    Power management options --->
    [*] Networking support --->
    '''Device Drivers --->'''
    File systems --->
    Kernel hacking --->
    ...
    ...
    [ ] ISDN support  --->
    < > Telephony support  --->
    '''Input device support  --->'''
    Character devices  --->
    -*- I2C support  --->
    ...
    ...
    < >   Reset key
          *** Input Device Drivers ***
    '''[*]   Keyboards  --->'''
    [ ]   Mice  --->
    [ ]   Joysticks/Gamepads  --->
....
    ....
 < >   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

    # 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
    

Android Keypad Configuration


NAND

Important Note
This section is not applicable for TI-Android-GingerBread-2.3.4-DevKit-2.1.1 and shall be updated later.


Introduction

This section of porting guide will describe the NAND layout present on AM335x EVM and how to integrate Fastboot functionality in u-boot. 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


Features Overview


Driver Configuration

$ make ARCH=arm menuconfig
-> Device Drivers
   -> Memory Technology Device (MTD) support (MTD [=y])
      -> NAND Device Support (MTD_NAND [=y])     
-> Device Drivers
   -> Memory Technology Device (MTD) support (MTD [=y])
      -> Enable UBI - Unsorted block images (MTD_UBI [=y])
-> File systems
   -> Miscellaneous filesystems (MISC_FILESYSTEMS [=y])
      -> UBIFS file system support (UBIFS_FS [=y])


Fastboot

Fastboot flashing utility is for updating the different software components of Android. Here is a guide to re-flash the spl, u-boot, kernel and root-filesystem (UBIFS image). This guide assume that Rowboat has been compiled before trying out these instructions.

Establishing Fastboot connectivity

Setup on Linux host

   $ export ANDROID_ROOT=<rowboat top level directory>
   $ cd $ANDROID_ROOT/out/host/linux-x86/bin
   $ sudo ./fastboot devices

if a device number is echoed, fastboot is working.

Setup on Windows host

   %SingleBootLoaderInterface% = USB_Install, USB\VID_0451

Supported Fastboot commands

   $ export ANDROID_ROOT=<rowboat_top_level_build_directory>
   $ cd $ANDROID_ROOT/out/host/linux-x86/bin
   $ sudo ./fastboot devices
   $ sudo ./fastboot boot <image_path>
   $ sudo ./fastboot flash <image_name> <image_path>

Note: Where "image_name" can be spl, uboot, kernel or filesystem.

   $ sudo ./fastboot erase <partition_name> (eg. spl)

Note: Where "partition_name" can be spl, uboot, environment, kernel or filesystem.

   $ sudo ./fastboot getvar <variable>
   $ sudo ./fastboot continue

Fastboot Porting guide

Fastboot implementation have a generic board independent function driver (cmd_fastboot.c), which will communicate with USB gadget driver, in the present case USB gadget stack is handled by MUSB driver. In the board dependent files, configurations like the available partition name, offset, size, method of nand write etc are defined.

In the Config file:

In the Board file:

Notes


USB Host and Gadget

Introduction

For AM335x the usb0 or usb1 can either act as Host or device mode. On the AM335x EVM, usb0 is set up for device mode and usb1 is set up for host mode operation. We use the Android USB Gadget driver on usb0 to enable the adb feature.

Driver Configuration

USB support for host and device mode is enabled in the kernel as shown below:

Device Drivers  --->
  [*] USB support  --->
    <*>   Support for Host-side USB
    <*>   Inventra Highspeed Dual Role Controller (TI, ADI, ...)
            *** Platform Glue Layer ***
          ...
    <*>     TI81XX onward
    [*]   Disable DMA (always use PIO)
    <*>   USB Mass Storage support
    ...
    <*>   USB Gadget Support  --->
        <*>   USB Peripheral Controller (Inventra HDRC USB Peripheral (TI, ADI, ...))  --->
        <*>   USB Gadget Drivers (Android Gadget)  --->
        ...
        <M>       Android gadget Zero (DUMMY)

See also: AM335x USB Driver's Guide

Android USB Configuration

Android USB Gadget Configuration

The Android gadget driver is enabled via the script at /system/bin/usb/rc.usb. For enabling Android gadget features, the following sysfs entries are done after the gadget driver is loaded and running:

echo 0       > /sys/class/android_usb/android0/enable
echo adb,acm > /sys/class/android_usb/android0/functions
echo 2       > /sys/class/android_usb/android0/f_acm/instances
echo 1       > /sys/class/android_usb/android0/enable

The sysfs settings need to be done depending on the features required to be enabled. The above settings enable adb and acm modes in the Android gadget driver.

USB Mass storage

The USB mass storage device class, otherwise known as USB MSC or UMS, is a protocol that allows file transfers between device and host to which it is connected. Mass storage is very good source of carrying media as well as other data files.

Introduction

The Android system uses vold as the mount daemon which detects, mounts and monitors the status of external storage.This mount daemon needs a configuration file(vold.fstab) to determine the mount device and location where it should be mounted.
Vold reads /etc/vold.fstab configuration file and mounts the device specified in the file. The basic format of the vold.fstab is

  dev_mount <label> <mount_point> <part> <sysfs_path1...> 
  
  where
  label - Label for the volume
  mount_point - Where the volume will be mounted
  part - Partition # (1 based), or 'auto' for first usable partition.
  <sysfs_path> - List of sysfs paths to source devices

sysfs_path is the full or partial path where kernel exports the udev information about the device currently pluged into system.
See system/core/rootdir/etc/vold.fstab in the Android source tree for the detailed explanations of the format.

Android Configuration for USB mass storage

In case of AM335xevm, Kernel populates udev entries for the following path for USB.

  /sys/devices/platform/omap/ti81xx-usbss/musb-hdrc.1/usb2

The following changes are done to detect connected usb mass storage device and mount/unmount it automatically when plugged/unplugged.

  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/usb2
# create mountpoints
    mkdir /mnt 0775 root system
    mkdir /mnt/sdcard 0000 system system
    mkdir /mnt/usb2 0000 system system

... 
# Backwards Compat - XXX: Going away in G*
    symlink /mnt/sdcard /sdcard
    symlink /mnt/usb2 /usb2

    mkdir /system
    mkdir /data 0771 system system

Test mass storage in Android

Connect USB mass storage device to board and check whether it is mounted properly.

  # mount
  rootfs / rootfs rw 0 0
  /dev/root / ext3 rw,relatime,errors=continue,barrier=1,data=writeback 0 0
  tmpfs /dev tmpfs rw,relatime,mode=755 0 0
  devpts /dev/pts devpts rw,relatime,mode=600 0 0
  proc /proc proc rw,relatime 0 0
  sysfs /sys sysfs rw,relatime 0 0
  tmpfs /mnt/asec tmpfs rw,relatime,mode=755,gid=1000 0 0
  /dev/block/mmcblk0p3 /part-3 vfat rw,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 0
  /dev/block/vold/179:3 /mnt/sdcard vfat rw,nosuid,nodev,noexec,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 0
  /dev/block/vold/179:3 /mnt/secure/asec vfat rw,nosuid,nodev,noexec,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 0
  tmpfs /mnt/sdcard/.android_secure tmpfs ro,relatime,size=0k,mode=000 0 0
  /dev/block/vold/8:1 /mnt/usb2 vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
  /dev/block/vold/8:1 /mnt/secure/asec vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
  tmpfs /mnt/usb2/.android_secure tmpfs ro,relatime,size=0k,mode=000 0 0

Browsing to usb2 directory using OI File Manager

USB 3G Modem

The USB 3G Modem section describes how to connect USB Modem to the android.

Introduction

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.

Kernel Configuration for USB Modem

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

File System Changes

To get the Modem Working, we need usb_modeswitch, usb_modeswicth.conf(configuration file) for the specific modem or Hardware vendor and the airtel.chat(dialer script) for the specific network.

Below is the description of an 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 DefaultVendor and DefaultProduct is the ID displayed for CDROM or mass storage, the TargetVendor and TargetProduct is for Modem. Plug the device into linux system and do "dmesg" or "lsusb" to know the IDs.

Example: HUAWEI E1731 Modem Below is the log when plugged to PC

   [6663132.917033] usb 1-4: new high speed USB device number 10 using ehci_hcd
   [6663133.033394] usb 1-4: New USB device found, idVendor=12d1, idProduct=1446
[6663133.033400] usb 1-4: New USB device strings: Mfr=3, Product=2, SerialNumber=0
[6663133.033404] usb 1-4: Product: HUAWEI Mobile
[6663133.033407] usb 1-4: Manufacturer: HUAWEI Technology
[6663133.036040] scsi16 : usb-storage 1-4:1.0
[6663133.036652] scsi17 : usb-storage 1-4:1.1
[6663133.685546] usb 1-4: USB disconnect, device number 10
[6663137.665047] usb 1-4: new high speed USB device number 11 using ehci_hcd
[6663137.781645] usb 1-4: New USB device found, idVendor=12d1, idProduct=1436
[6663137.781651] usb 1-4: New USB device strings: Mfr=4, Product=3, SerialNumber=0
[6663137.781654] usb 1-4: Product: HUAWEI Mobile
[6663137.781657] usb 1-4: Manufacturer: HUAWEI Technology
[6663137.784476] option 1-4:1.0: GSM modem (1-port) converter detected
[6663137.784663] usb 1-4: GSM modem (1-port) converter now attached to ttyUSB0
[6663137.786425] cdc_ether 1-4:1.1: wwan0: register 'cdc_ether' at usb-0000:00:1d.7-4, Mobile Broadband Network Device, 02:50:f3:00:00:00
[6663137.788066] option 1-4:1.3: GSM modem (1-port) converter detected
[6663137.788268] usb 1-4: GSM modem (1-port) converter now attached to ttyUSB1
[6663137.788509] option 1-4:1.4: GSM modem (1-port) converter detected
[6663137.788646] usb 1-4: GSM modem (1-port) converter now attached to ttyUSB2
[6663137.789203] scsi22 : usb-storage 1-4:1.5
[6663137.789812] scsi23 : usb-storage 1-4:1.6
[6663138.790809] scsi 22:0:0:0: CD-ROM            HUAWEI   Mass Storage     2.31 PQ: 0 ANSI: 2
[6663138.791303] scsi 23:0:0:0: Direct-Access     HUAWEI   SD Storage       2.31 PQ: 0 ANSI: 2
[6663138.807169] sr1: scsi-1 drive
[6663138.808426] sr 22:0:0:0: Attached scsi CD-ROM sr1
[6663138.808593] sr 22:0:0:0: Attached scsi generic sg5 type 5
[6663138.809394] sd 23:0:0:0: Attached scsi generic sg6 type 0
[6663138.812181] sd 23:0:0:0: [sde] Attached SCSI removable disk

Below is the description of an example airtel.chat(dialer script) file for AirTel (INDIA)

TIMEOUT 10
' ' AT
OK ATE1
OK AT+CGDCONT=1,"IP","airtelgprs.com"
OK "ATD*99***1#"
CONNECT ' '

NOTE: the single quotes in the above chat file must be together. ie no space allowed.

This file is network service provider dependent, so modify the airtelgprs.com according to your service provider.

Usage

Below are the steps to perform once android boots up with the above necessary modifications

   mount -t usbfs usbfs /proc/bus/usb
   /system/xbin/usb_modeswitch -I -W -c /system/xbin/usb_modeswitch.conf

Mount the usbfs file system to /proc/bus/usb. This is necessary to avoid the “Couldn’t opendir()” error you get otherwise on running usb_modeswitch.
Once Mode Switch Succeeds, modem will be enumerated as /dev/ttyUSB* (* can be 0,1,2).
If you place the usb_modeswitch and usb_modeswitch.conf at other place, change the above command accordingly.

   /system/bin/pppd /dev/ttyUSB0 115200 persist defaultroute usepeerdns updetach crtscts noauth debug connect "/system/xbin/chat -v -s -f /system/etc/ppp/airtel.chat"
   setprop net.dns1 <IP1>
   setprop net.dns2 <IP2>

You are ready to browse that net after this if everything went well in the previous steps.
Enjoy the 3G fast speed surfing on your device.

Disclaimer

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

E2e.jpg For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article TI-Android-GingerBread-2.3.4-DevKit-2.1.1 PortingGuides here.
Hyperlink blue.png Links
ARM Microcontroller MCU ARM Processor Digital Media Processor Digital Signal Processing Microcontroller MCU Multi Core Processor
Ultra Low Power DSP 8 bit Microcontroller MCU 16 bit Microcontroller MCU 32 bit Microcontroller MCU

Leave a Comment
Personal tools
Namespaces
Variants
Actions
Navigation
Print/export
Toolbox