android_sdio_wifi_porting

/**
*android2.3.4 kernel:2.6.36
*/
一、kernel configured
[*] Networking support  --->
-*-   Wireless  ---> 
<*>   cfg80211 - wireless configuration API
[*]     cfg80211 regulatory debugging 
<*>   Common routines for IEEE802.11 drivers
[*]   lib80211 debugging messages
<*>   Generic IEEE 802.11 Networking Stack (mac80211) 
[*]   Enable LED triggers  
 
 Device Drivers  --->
 [*] Network device support  --->
 [*]   Wireless LAN  --->
 <*>   Marvell 8xxx Libertas WLAN driver support  
 <*>     Marvell Libertas 8385/8686/8688 SDIO 802.11b/g cards  
 <*>   IEEE 802.11 for Host AP (Prism2/2.5/3 and WEP/TKIP/CCMP)
 把wifi驱动编译进内核
 在hardware/libhardware_legacy/wifi/wifi.c中当insmod/rmmod时,
 直接return 0
  
 /drivers/net/wireless/libertas
  arch/arm/mach-s3c64xx/mach-smdk6410.c硬件用的是mmc1
 static struct platform_device *smdk6410_devices[] __initdata = {
 &s3c_device_hsmmc1,
 };
 二、download the firmware
 方法1:把Marvell 8686的固件放在内核里编译进内核
 Device Drivers  --->  
 Generic Driver Options  --->
 下面这两项不选,如果选择会avoid building firmware.
 [ ] Select only drivers that don't need compile-time external firmware                     
 [ ] Prevent firmware from being built
 [*]   Include in-kernel firmware blobs in kernel binary               
固件的名称以空格分开
(sd8686_helper.bin sd8686.bin) External firmware blobs to build into the kernel binary       
(firmware) Firmware blobs root directory
把固件sd8686_helper.bin sd8686.bin放到内核目录
android_kernel/firmware/

方法2:把固件放在文件系统,加载内核的时候从文件系统里获得
要配置固件的路径

三、HAL Configured
device/wolf/smdk6410/BoardConfig.mk
# Wi-Fi
BOARD_HAVE_LIBWIFI := true
BOARD_WPA_SUPPLICANT_DRIVER := WEXT

如果定义
WPA_SUPPLICANT_VERSION      := VER_0_6_X
This will set WPA_BUILD_SUPPLICANT to true in external/wpa_supplicant_6/Android.mk

如果不定义则默认编译external/wpa_supplicant/Android.mk WPA_BUILD_SUPPLICANT = true
若开始编译之后想换成默认的VER_0_5_X会出现错误
make: *** [out/target/product/smdk6410/obj/EXECUTABLES/
wpa_supplicant_intermediates/LINKED/wpa_supplicant] Error 1
删除之后再编译
rm -rf out/target/product/smdk6410/obj/EXECUTABLES/wpa_supplicant_intermediates/
rm -rf out/target/product/smdk6410/obj/EXECUTABLES/wpa_cli_intermediates/

如果wifi驱动编译成内核模块.ko进行如下配置
变量名将会在hardware/libhardware_legacy/wifi/Android.mk中用到
WIFI_DRIVER_MODULE_PATH     := "/system/etc/wifi/libertas_sdio.ko"
WIFI_DRIVER_MODULE_NAME     := "libertas_sdio"
四、配置wpa_supplicant.conf
wpa_supplicant是通过wpa_supplicant.conf中的ctrl_interface 来指定控制socket的
在/external/wpa_supplicant_6/wpa_supplicant/wpa_supplicant.conf下配置好编译
后会复制到system/etc/wifi下

update_config=1
ctrl_interface=wlan0
eapol_version=1
ap_scan=1
fast_reauth=1

network={
 ssid="Free Public WiFi"
 mode=1
 frequency=2462
 proto=WPA
 key_mgmt=WPA-NONE
 pairwise=NONE
 group=TKIP
 psk="secret passphrase"
}

#for the non-WAP or open wireless networks
network={
 key_mgmt=NONE
}
--------------------------------------------
运行的时候出现
E/WifiHW  (   92): Error changing group ownership of /data/misc/wifi/wpa_supplicant.conf
to 1010: Operation not permitted
解决(rootfs):cp system/etc/wifi/wpa_supplicant.conf data/misc/wifi/

五、配置init.rc的路径和权限
# give system access to wpa_supplicant.conf for backup and restore
    mkdir /system/etc/wifi 0777 wifi wifi
    chmod 0777 /system/etc/wifi
    chmod 0777 /system/etc/wifi/wpa_supplicant.conf
    chown wifi wifi /system/etc/wifi/wpa_supplicant.conf
 
#wpa_wupplicant control socket for android wifi.c
    mkdir /data/misc/wifi 0777 wifi wifi
    mkdir /data/misc/wifi/sockets 0777 wifi wifi
    chmod 0777 /data/misc/wifi
    chmod 0777 /data/misc/wifi/wpa_supplicant.conf
    chmod 0777 /data/misc/wifi/sockets
    chown wifi wifi /data/misc/wifi
    chown wifi wifi /data/misc/wifi/wpa_supplicant.conf
    mkdir /data/misc/dhcp 0777 dhcp dhcp
    chmod 0777 /data/misc/dhcp
在init.rc中启动wifi和 dhcp的服务
# 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 777 wifi wifi
    disabled
    oneshot
service dhcpcd_wlan0 /system/bin/dhcpcd -o domain_name_servers -t 120  -f /system/etc/dhcpcd/dhcpcd.conf -d wlan0
    group dhcp wifi system
    disabled
    oneshot

on property:init.svc.wpa_supplicant=stopped
    stop dhcpcd_wlan0
-----------------------------------
init: untracked pid 506 exited
有进程退出导致android 重启
# Define the Wi-Fi and other props
    setprop wifi.interface wlan0
    setprop wlan.interface wlan0
    setprop wlan.driver.status ok
 
六、 WiFi does not work when booting from an NFS file system use UBIFS or
other file system booting from flash

七、wpa_cli的使用
状态
# wpa_cli -p/data/system/wpa_supplicant -iwlan0 status
wpa_state=SCANNING

扫描
# wpa_cli scan
Using interface 'wlan0'
OK

扫描结果

# wpa_cli scan_results
Using interface 'wlan0'
bssid / frequency / signal level / flags / ssid
94:0c:6d:58:08:72       2437    193     [WPA-PSK-CCMP][WPA2-PSK-CCMP-preauth]   ad
e0:05:c5:e4:cd:62       2417    189     [WPA-PSK-CCMP]  kk
5a:9c:bb:bf:4e:26       2462    200     [IBSS]          Free Public WiFi

 

你可能感兴趣的:(android_sdio_wifi_porting)