Rockie's Android Porting Guide(2)——add USB WIFI to your system
编译Android操作系统(2)——添加Wifi支持
Rockie Cheng
Now,zd1211b无线网卡已可使用wpa_supplicant连接无线网络,下一步要让android能够识别无线网卡。
Android默认使用wifi.c加载无线网卡驱动模块,如果直接编译进内核需要做一定修改。
btw:需要内核支持wifi和dhcp
(1)build/target/board/idea6410/BoardConfig.mk
add
# Wifi related defines
BOARD_WPA_SUPPLICANT_DRIVER := WEXT
(2)external/wpa_supplicant/.config
# CONFIG_NO_WPA=y
CONFIG_OS=unix
CONFIG_IEEE8021X_EAPOL=y
CONFIG_EAP_MD5=y
CONFIG_EAP_MSCHAPV2=y
CONFIG_EAP_TLS=y
CONFIG_EAP_PEAP=y
CONFIG_EAP_TTLS=y
CONFIG_EAP_GTC=y
CONFIG_EAP_OTP=y
CONFIG_EAP_SIM=y
CONFIG_EAP_AKA=y
CONFIG_EAP_PSK=y
CONFIG_EAP_SAKE=y
CONFIG_EAP_GPSK=y
CONFIG_EAP_PAX=y
CONFIG_EAP_LEAP=y
CONFIG_PKCS12=y
CONFIG_SMARTCARD=y
CONFIG_WIRELESS_EXTENSION=y
CONFIG_CTRL_IFACE=y
CONFIG_DRIVER_WEXT=y
it seems there is a problem with driver_wext.c in eclar,so I got one from cupcake.
(3)hardware/libhardware_legacy/wifi/wifi.c
将驱动直接编译进内核
int wifi_load_driver()
{
char driver_status[PROPERTY_VALUE_MAX];
int count = 100; /* wait at most 20 seconds for completion */
LOGE("wifi driver loaded !");
return 0;
}
int wifi_unload_driver()
{
int count = 20; /* wait at most 10 seconds for completion */
LOGE("wifi driver unloaded by rockie!");
return 0;
注意这个定义static const char IFACE_DIR[] = "/data/system/wpa_supplicant";
(4)编译整个android系统,确认编译完bin目录中含有wpa_supplicant、wpa_cli
(5)修改init.rc文件
add
mkdir /data/misc/wifi 0770 system system
mkdir /data/misc/wifi/sockets 0770 system system
mkdir /data/system/wpa_supplicant 0770 system system
chmod 0660 /data/misc/wifi/wpa_supplicant.conf
add at the end
service wpa_supplicant /system/bin/wpa_supplicant -Dwext -iwlan0 -d -c /data/misc/wifi/wpa_supplicant.conf
# user wifi
# group wifi system
socket wpa_eth0 dgram 0660 wifi system
disabled
oneshot
service dhcpcd /system/bin/dhcpcd -f /system/etc/dhcpcd/dhcpcd.conf -d wlan0
disabled
oneshot
on property:init.svc.wpa_supplicant=stopped
stop dhcpcd
(6)添加system/etc/wifi/wpa_supplicant.conf
update_config=1
ctrl_interface=/data/system/wpa_supplicant //这个一定要和IFACE_DIR对应并保证目录权限
eapol_version=1
ap_scan=1
fast_reauth=1
(7)/system/etc/dhcpcd/dhcpcd.conf 文件内容
interface wlan0
option subnet_mask, routers, domain_name_servers
(8)boot and try
存在的问题是无法获取wifi的信号强度
阿虚
rockie cheng