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.
- Currently only station mode is supported.
Android WLAN Sub-System Overview
Android uses a modified wpa_supplicant (external/wpa_supplicant_6) daemon for wifi support which is controlled through a socket by hardware/libhardware_legacy/wifi/wifi.c (WiFiHW) that gets controlled from Android UI through android.net.wifi package from frameworks/base/wifi/java/android/net/wifi and it's corresponding JNI implementation in frameworks/base/core/jni/android_net_wifi_Wifi.cpp Higher level network management is done in 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/WL1271_compat
- Make sure the following options are not enabled in the Kernel:
CONFIG_CFG80211 CONFIG_LIB80211 CONFIG_MAC80211
Else corresponding Wireless Compat driver modules will not build.
- On the other hand following Config options should be enabled in Kernel:
CONFIG_WIRELESS_EXT=y CONFIG_WEXT_CORE=y CONFIG_WEXT_PROC=y CONFIG_WEXT_PRIV=y
- On AM37 WL1271 SDIO is connected to MMC2 bus. Its relevant initialization and pin-muxing is done at arch/arm/mach-omap2/board-omap3evm.c under CONFIG_WL12XX_PLATFORM_DATA macro. Do take care of this initialization and pin-muxing if using any other MMC bus e.g. MMC3.
Android WiFi HAL Configuration
- Enable building of wpa_supplicant in your BoardConfig.mk
This is by simply adding following options in BoardConfig.mk:
BOARD_WPA_SUPPLICANT_DRIVER:= WEXT WPA_SUPPLICANT_VERSION := VER_0_6_X WIFI_DRIVER_MODULE_PATH := "/system/etc/wifi/wl12xx_sdio.ko" WIFI_DRIVER_MODULE_ARG := "" WIFI_DRIVER_MODULE_NAME := "wl12xx_sdio" WIFI_DRIVER_FW_STA_PATH := "/system/etc/firmware/ti-connectivity/wl1271-fw-2.bin"
This will set WPA_BUILD_SUPPLICANT to true in external/wpa_supplicant_6/Android.mk enabling building of driver_wext.c. 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 from WIFI_DRIVER_FW_STA_PATH
- Android uses SIOCSIWPRIV ioctl to send commands to modify driver behaviour and receive information like signal strength, mac address of the AP, link speed etc. This ioctl is usually not implemented. A quick workaround was to emulate this ioctl functionality in WPA_supplicant itself. Here is the corresponding patch Added emulation of Android private ioctls for generic WiFi drivers
- 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 from init.rc
# 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 system wifi /data/misc/wifi chown system 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
- Start wpa_supplicant and dhcpcd_wlan0 from init.rc.
# wpa_supplicant and dhcp daemon service wpa_supplicant /system/bin/wpa_supplicant -Dwext -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf -dd socket wpa_wlan0 dgram 660 system wifi group system wifi inet disabled
#service dhcpcd_${iface} /system/bin/dhcpcd -o domain_name_servers -ABKL ${iface} service dhcpcd_wlan0 /system/bin/dhcpcd -ABKL wlan0 disabled oneshot
http://processors.wiki.ti.com/index.php/TI-Android-GingerBread-2.3.4-DevKit-2.1_PortingGuides#Introduction_2