NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.

Android wireless build and porting guide

From Texas Instruments Wiki
Jump to: navigation, search
TIBanner.png
Android Wireless Build and Porting Guide
Sitara Android

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



This guide documents the steps to integrate Wireless SDK for WL1271 (WLAN and Bluetooth) into TI Android DevKit.

Refer to TI-Android-FroYo-DevKit-V2.2 UserGuide or TI-Android-GingerBread-2.3-DevKit-1.0 UserGuide for instructions on using WLAN and Bluetooth from Android environment


Important
The following instructions are for TI-Android-FroYo-DevKit-V2.2 and TI-Android-GingerBread-2.3-DevKit-1.0 only. For instructions regarding newer versions of TI Android DevKit refer to the respective Porting Guide.



Prerequisites[edit]

  • TI Android DevKit sources (TI-Android-FroYo-DevKit-V2.2 or TI-Android-GingerBread-2.3-DevKit-1.0)
  • OMAP3EVM (AM37x) revG board with wireless module

Build android for omap3evm (am37x) target <syntaxhighlight lang='bash'> $ cd $ROWBOAT $ make TARGET_PRODUCT=omap3evm OMAPES=5.x </syntaxhighlight> The android kernel supplied with the devkit is already patched to include support for WL1271 WLAN and Bluetooth on AM37x.

Ensure that the kernel is built for omap3evm before proceeding.

Building wireless drivers[edit]

<syntaxhighlight lang='bash'> $ chmod a+x V3.00.01.06-WL6.1.6.0-Linux-x86-Install $ ./V3.00.01.06-WL6.1.6.0-Linux-x86-Install --mode console </syntaxhighlight> The installer will confirm that the SDK will be installed. Enter 'Y' to continue. The default installation path is ~/V3.00.01.06-WL6.1.6.0. Accept the default by pressing Enter.

This will install V3.00.01.06-WL6.1.6.0 on your computer.  Continue? [n/Y] y

Where do you want to install V3.00.01.06-WL6.1.6.0? [/home/testuser/V3.00.01.06-WL6.1.6.0]

Installing V3.00.01.06-WL6.1.6.0...
Installing Program Files...
Installation complete.

The SDK is installed. Continue with extracting the SDK sources. <syntaxhighlight lang='bash'> $ cd V3.00.01.06-WL6.1.6.0/software $ tar xvzf OMAP35x_WL1271_6.1.0.0.144.tar.gz </syntaxhighlight> <syntaxhighlight lang='bash'> $ cd MS_TI_OMAP35x_WL1271_6.1.0.0.144/MS_TI_WL1271_Sources </syntaxhighlight>

<syntaxhighlight lang='bash'> tar xvzf WL1271Android-patches.tar.gz -C V3.00.01.06-WL6.1.6.0/software/MS_TI_OMAP35x_WL1271_6.1.0.0.144/MS_TI_WL1271_Sources </syntaxhighlight> Copy the files WLAndroidBuild.sh and wl1271-android.patch into MS_TI_WL1271_Sources directory if the files are extracted into a subdirectory.

  • Go to the build directory (if not already done)

<syntaxhighlight lang='bash'> $ cd V3.00.01.06-WL6.1.6.0/software/MS_TI_OMAP35x_WL1271_6.1.0.0.144/MS_TI_WL1271_Sources </syntaxhighlight>

  • Update the $ROWBOAT_ROOT_PATH variable in WLAndroidBuild.sh with the correct path to rowboat android sources
ROWBOAT_TOP=/home/<username>/rowboat
  • Build wlan drivers

<syntaxhighlight lang='bash'> $ ./WLAndroidBuild.sh build wlan </syntaxhighlight>

Installing wireless drivers[edit]

  • After build is complete, the drivers are copied into image/WL1271_demo_01/wlan directory. Copy them into the android filesystem

<syntaxhighlight lang='bash'> $ cp image/WL1271_demo_01/wlan/tiwlan_drv.ko $ROWBOAT/out/target/product/omap3evm/system/etc/wifi $ cp image/WL1271_demo_01/wlan/tiwlan.ini $ROWBOAT/out/target/product/omap3evm/system/etc/wifi $ cp image/WL1271_demo_01/wlan/firmware.bin $ROWBOAT/out/target/product/omap3evm/system/etc/wifi </syntaxhighlight> Note: Do not copy wpa_supplicant.conf file

  • Copy the Bluetooth firmware

<syntaxhighlight lang='bash'> $ mkdir -p $ROWBOAT/out/target/product/omap3evm/system/lib/firmware $ cp common/BT_firmware/TIInit_7.2.31.bts $ROWBOAT/out/target/product/omap3evm/system/lib/firmware $ cp common/tools/wl1271bt_enable $ROWBOAT/out/target/product/omap3evm/root </syntaxhighlight>

Proceed with creating the roofs tar file as per instructions in the Android DevKit User Guide. See the step Prepare the root filesystem

WLAN Calibration[edit]

To generate the WLAN calibration NVS file, follow steps listed below. These are based on the steps given here.

  • Enable WLAN from Android UI. Ensure that the driver is loaded by checking the messages on the serial console.
  • Start the wireless configuration utility wlan_cu on the serial console and enter the commands as follows
Text to be entered on the console is in red colour.
  # wlan_cu -itiwlan0 -b
 user_main, start
 \> Driver/, Connection/, Management/, Show/, Privacy/, scAn/, roaminG/, qOs/, poWer/, eVents/, Bt coexsistance/, Report/, dEbug/, biT/, aboUt, Quit
 / w p 1 l 2 f 2
 \> Driver/, Connection/, Management/, Show/, Privacy/, scAn/, roaminG/, qOs/, poWer/, eVents/, Bt coexsistance/, Report/, dEbug/, biT/, aboUt, Quit
 .../poWer> set_Power_mode, set_powersave_powerLevel, set_deFault_powerlevel, set_doZe_mode_in_auto, traffic_Thresholds, eNable, Disable, set_dcO_itrim
 / t r h 0 7
 \> Driver/, Connection/, Management/, Show/, Privacy/, scAn/, roaminG/, qOs/, poWer/, eVents/, Bt coexsistance/, Report/, dEbug/, biT/, aboUt, Quit
 .../biT> Bip/, Radio debug/
 .../Radio debug> Get hdk version, cHannel tune, Tx debug/, rx Statistics/
 Channel tune of channel 7 was performed OK
 / t b b 375 128 0
 \> Driver/, Connection/, Management/, Show/, Privacy/, scAn/, roaminG/, qOs/, poWer/, eVents/, Bt coexsistance/, Report/, dEbug/, biT/, aboUt, Quit
 .../biT> Bip/, Radio debug/
 .../Bip> update Buffer calref point, Tx bip, Rx bip/
 BufferCalReferencePoint was configured succesfully
 / t b t 1 0 0 0 0 0 0 0
 \> Driver/, Connection/, Management/, Show/, Privacy/, scAn/, roaminG/, qOs/, poWer/, eVents/, Bt coexsistance/, Report/, dEbug/, biT/, aboUt, Quit
 .../biT> Bip/, Radio debug/
 .../Bip> update Buffer calref point, Tx bip, Rx bip/
 Entering FillMACAddressToNVS
 Mac[0]=08
 Mac[1]=00
 Mac[2]=28
 Mac[3]=12
 Mac[4]=34
 Mac[5]=56
 exiting FillMACAddressToNVS
 /
 \> Driver/, Connection/, Management/, Show/, Privacy/, scAn/, roaminG/, qOs/, poWer/, eVents/, Bt coexsistance/, Report/, dEbug/, biT/, aboUt, Quit
 q
 #
  • Copy the generated nvs_map.bin to /system/etc/wifi
  # mv nvs_map.bin /system/etc/wifi
  • Modify wlan_loader service in init.rc as follows:
  service wlan_loader /system/bin/wlan_loader \
      -e /system/etc/wifi/nvs_map.bin \
      -f /system/etc/wifi/firmware.bin \
      -i /system/etc/wifi/tiwlan.ini
      disabled
      oneshot

With the new settings, when WLAN is enabled, the following log is seen on the console

# TIWLAN: driver init
TIWLAN: 1986.373128: wlanDrvIf_Open()
TIWLAN: 1986.463766: pInitParams->RoamingScanning_2_4G_enable 0
SDIO clock Configuration is now set to 24Mhz
TIWLAN: 1986.688985: CHIP VERSION... set 1273 chip top registers
TIWLAN: 1986.695486: Working on a 1273 PG 2.0 board.
TIWLAN: 1986.700246: Starting to process NVS...
TIWLAN: 1986.704549: NVS found, EEPROM Image addr=0xc8aaca00, EEPROM Len=0x0x1d4
TIWLAN: 1986.712148: Chip ID is 0x4030111.
TIWLAN: 1986.716299: FEM Type 1
TIWLAN: 1986.719534: Starting to download firmware...
TIWLAN: 1986.792226: Starting to download firmware...
TIWLAN: 1986.812399: Starting to download firmware...
TIWLAN: 1986.817403: Starting to download firmware...
TIWLAN: 1986.827993: Starting to download firmware...
TIWLAN: 1986.835073: Starting to download firmware...
TIWLAN: 1986.841543: Finished downloading firmware.
TIWLAN: 1986.846212: Firmware running.
TIWLAN: 1986.865896:
TIWLAN: 1986.867940: --------------------------------------------------------------------
TIWLAN: 1986.875906: Driver Version  : WiLink_Driver_6.1.0.0.144
TIWLAN: 1986.881704: Firmware Version: Rev 6.1.0.0.335
TIWLAN: 1986.886617: Station ID      : 08-00-28-12-34-56
TIWLAN: 1986.891683: --------------------------------------------------------------------
TIWLAN: 1986.899648:
TIWLAN: 1986.922140: Interrogate TX/RX parameters
TIWLAN: 1988.937246: wlanDrvIf_Release()
TIWLAN: 1988.942800: wlanDrvIf_Open()

Porting guide[edit]

This section describes the changes done in Android to enable WLAN and Bluetooth on AM37x.

For convenience, the changes are categorized on the basis of the android project in which the changes appear.

Project: device/ti/omap3evm[edit]

BoardConfig.mk[edit]

  • WL1271 WLAN is enabled in android with the following settings in BoardConfig.mk
# Wifi
USES_TI_WL1271 := true
BOARD_WPA_SUPPLICANT_DRIVER := CUSTOM
ifdef USES_TI_WL1271
BOARD_WLAN_DEVICE           := wl1271
endif
WPA_SUPPLICANT_VERSION      := VER_0_6_X
WIFI_DRIVER_MODULE_PATH     := "/system/etc/wifi/tiwlan_drv.ko"
WIFI_DRIVER_MODULE_NAME     := "tiwlan_drv"
WIFI_FIRMWARE_LOADER        := "wlan_loader"

The setting BOARD_WLAN_DEVICE := wl1271 enables building of android components required to support the WL1271 WLAN including the firmware loader. Test apps etc.

  • Bluetooth is enabled with the following setting in BoardConfig.mk
# Bluetooth
BOARD_HAVE_BLUETOOTH := true

omap3evm.mk[edit]

  • Additional settings to copy the permission settings xml files for WLAN and Bluetooth

init.rc[edit]

  • Set owner/group and permissions for various files required to run WLAN and Bluetooth
  • Setup services for WLAN and Bluetooth
WLAN[edit]

The following services are registered in init.rc for WLAN operation:

  • wlan interface tiwlan0
setprop wifi.interface tiwlan0
  • wlan_loader - This service loads the WLAN firmware in WL1271
service wlan_loader /system/bin/wlan_loader -n \
    -f /system/etc/wifi/firmware.bin \
    -i /system/etc/wifi/tiwlan.ini
    disabled
    oneshot
  • wpa_supplicant
service wpa_supplicant /system/bin/wpa_supplicant -Dtiwlan0 -itiwlan0 -c/data/misc/wifi/wpa_supplicant.conf -dd
    socket wpa_tiwlan0 dgram 660 wifi wifi
    disabled
    oneshot
  • dhcpcd
service dhcpcd /system/bin/dhcpcd  -ABKL tiwlan0
    disabled
    oneshot
Bluetooth[edit]

The following services are registered in init.rc for Bluetooth operation:

  • dbus
  • bluetoothd
  • hciattach - This service attaches the BT UART HCI interface to the bluetooth stack. It is also responsible for loading the BT firmware on WL1271. Specify the UART device node the bluetooth module is interfaced to and the baudrate. On omap3evm the settings are /dev/ttyS1 and 3000000 baud.
service hciattach /system/bin/hciattach -n /dev/ttyS1 texas 3000000
    user root
# changing user to root from bluetooth is a potential security issue
    group bluetooth net_bt_admin misc
    disabled
    oneshot
  • btpwr - This service runs the wl1271bt_enable app to power-on/power-off the BT module in WL1271. See Bluedroid section below for more information. This is not required if your kernel supports rfkill interface to power on/off the BT module.
# rfkill is not supported, use this instead
service btpwr /wl1271bt_enable /dev/ttyS1
    disabled
    oneshot
  • opush - BT Object Push Profile
  • hfag and hsag - Audio Gateway service for Hands-free profile, Headset profile. This feature is available only on Gingerbread release of TI Android DevKit

Project: system/bluetooth[edit]

Bluedroid[edit]

Bluedroid is used by Android UI to enable/disable Bluetooth. It uses the linux kernel rfkill infrastructure for this. The current kernel supplied with TI Android DevKit does not support rfkill, hence bluedroid is modified to use the wl1271bt_enable app provided with the Wireless SDK. The wl1271bt_enable app is registered as a service named btpwr in init.rc.

Refer the sources for Bluedroid at system/bluetooth/bluedroid for implementation.

Project: external/bluetooth/bluez[edit]

patch for TI-specific hciattach tool

Project: kernel[edit]

The kernel patch from the Wireless SDK is applied to the TI Android DevKit kernel sources. This adds WLAN and BT support for AM37x evm revG.

The following kernel configs are enabled for WLAN:

CONFIG_IP_MULTICAST=y
CONFIG_IP_ADVANCED_ROUTER=y
CONFIG_ASK_IP_FIB_HASH=y
CONFIG_NETFILTER=y
CONFIG_NETFILTER_ADVANCED=y
CONFIG_NETFILTER_NETLINK=y
CONFIG_NETFILTER_NETLINK_QUEUE=y
CONFIG_NETFILTER_NETLINK_LOG=y
CONFIG_NF_CONNTRACK=y
CONFIG_NETFILTER_XTABLES=y
CONFIG_NETFILTER_XT_TARGET_HL=y
CONFIG_NETFILTER_XT_MATCH_HL=y
CONFIG_NF_DEFRAG_IPV4=y
CONFIG_NF_CONNTRACK_IPV4=y
CONFIG_NF_CONNTRACK_PROC_COMPAT=y
CONFIG_IP_NF_QUEUE=y
CONFIG_IP_NF_IPTABLES=y
CONFIG_IP_NF_MATCH_ADDRTYPE=y
CONFIG_IP_NF_MATCH_AH=y
CONFIG_IP_NF_MATCH_ECN=y
CONFIG_IP_NF_MATCH_TTL=y
CONFIG_IP_NF_FILTER=y
CONFIG_IP_NF_TARGET_REJECT=y
CONFIG_IP_NF_TARGET_LOG=y
CONFIG_IP_NF_TARGET_ULOG=y
CONFIG_NF_NAT=y
CONFIG_NF_NAT_NEEDED=y
CONFIG_IP_NF_TARGET_MASQUERADE=y
CONFIG_IP_NF_TARGET_NETMAP=y
CONFIG_IP_NF_TARGET_REDIRECT=y
CONFIG_NF_NAT_SNMP_BASIC=y
CONFIG_IP_NF_MANGLE=y
CONFIG_IP_NF_TARGET_ECN=y
CONFIG_IP_NF_TARGET_TTL=y
CONFIG_IP_NF_RAW=y
CONFIG_IP_NF_ARPTABLES=y
CONFIG_IP_NF_ARPFILTER=y
CONFIG_IP_NF_ARP_MANGLE=y
CONFIG_WIRELESS_EXT=y
CONFIG_WEXT_CORE=y
CONFIG_WEXT_PROC=y
CONFIG_WEXT_SPY=y
CONFIG_WEXT_PRIV=y
CONFIG_WIRELESS_EXT_SYSFS=y
CONFIG_WL1271_WLAN=y

The following kernel configs are enabled for Bluetooth support:

CONFIG_BT=y
CONFIG_BT_L2CAP=y
CONFIG_BT_SCO=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_BCSP=y
CONFIG_BT_HCIUART_LL=y
CONFIG_BT_WL1271=y
CONFIG_SND_SOC_WL1271BT=y

The following kernel configs are enabled for Bluetooth AVRCP support:

CONFIG_INPUT_MISC=y
CONFIG_INPUT_UINPUT=y

Project: hardware/ti/omap3[edit]

NoteNote: The following information applies to TI-Android-GingerBread-2.3-DevKit-1.0 release only.

ALSA HAL is modified to add the Bluetooth SCO audio device. The correct device name is returned when android requests to use Bluetooth SCO device.

File: modules/alsa/alsa_module.cpp
static alsa_handle_t _defaults[] = {
    {
        module      : 0,
        devices     : OMAP3_OUT_SCO,
        curDev      : 0,
        curMode     : 0,
        handle      : 0,
        format      : SND_PCM_FORMAT_S16_LE, // AudioSystem::PCM_16_BIT
        channels    : 2,
        sampleRate  : 8000,
        latency     : 200000, // Desired Delay in usec
        bufferSize  : DEFAULT_SAMPLE_RATE / 5, // Desired Number of samples
        modPrivate  : (void *)&setScoControls,
    },
    ...
    {
        module      : 0,
        devices     : OMAP3_IN_SCO,
        curDev      : 0,
        curMode     : 0,
        handle      : 0,
        format      : SND_PCM_FORMAT_S16_LE, // AudioSystem::PCM_16_BIT
        channels    : 1,
        sampleRate  : AudioRecord::DEFAULT_SAMPLE_RATE,
        latency     : 250000, // Desired Delay in usec
        bufferSize  : 2048, // Desired Number of samples
        modPrivate  : (void *)&setScoControls,
    },
    ...


Refer to the sources for implementation details.

Bluetooth SCO Audio[edit]

NoteNote: The following information is for TI-Android-GingerBread-2.3-DevKit-1.0 and is not valid for earlier releases.

This section provides additional information on audio over SCO link. This is used in Bluetooth Headset profile or Handsfree profile (BT HSP/HFP).

The kernel patch from Wireless SDK creates an additional audio device for bluetooth.

# alsa_aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: omap3evm [omap3evm], device 0: TWL4030 twl4030-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: omap3evm [omap3evm], device 1: WL1271 BT PCM wl1271bt-1 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

It is possible to use alsa utilities to record/play audio on bluetooth directly once SCO connection with the headset is established. Use BluetoothSCOApp application to establish SCO link with an active Bluetooth headset.

To play audio on bluetooth headset over SCO

  # alsa_aplay -D hw:0,1 <filename>

Only 16-bit, 8kHz PCM audio (wav format) is supported for bluetooth audio over sco.

You can use the Android Sound Recorder or Voice Recorder application to record audio.

  • Sound Recorder app saves the audio in 3gp format. This audio file cannot be played over SCO. However regular analog audio out and A2DP can be used for playback
  • Voice Recorder app saves audio in wav format. When it is configured to save in 16-bit, 8kHz PCM format, the resulting file can be played over SCO with alsa_aplay as shown above.
E2e.jpg {{
  1. switchcategory:MultiCore=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article Android wireless build and porting guide here.

Keystone=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article Android wireless build and porting guide here.

C2000=For technical support on the C2000 please post your questions on The C2000 Forum. Please post only comments about the article Android wireless build and porting guide here. DaVinci=For technical support on DaVincoplease post your questions on The DaVinci Forum. Please post only comments about the article Android wireless build and porting guide here. MSP430=For technical support on MSP430 please post your questions on The MSP430 Forum. Please post only comments about the article Android wireless build and porting guide here. OMAP35x=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Android wireless build and porting guide here. OMAPL1=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Android wireless build and porting guide here. MAVRK=For technical support on MAVRK please post your questions on The MAVRK Toolbox Forum. Please post only comments about the article Android wireless build and porting guide here. For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article Android wireless build and porting guide here.

}}

Hyperlink blue.png Links

Amplifiers & Linear
Audio
Broadband RF/IF & Digital Radio
Clocks & Timers
Data Converters

DLP & MEMS
High-Reliability
Interface
Logic
Power Management

Processors

Switches & Multiplexers
Temperature Sensors & Control ICs
Wireless Connectivity