http://blog.csdn.net/z642010820/article/details/7341476 http://blog.csdn.net/lanbo_g/article/details/6821840 http://blog.csdn.net/darkengine/article/details/7024459 http://blog./2010/04/porting-wifi-drivers-to-android.html 接下來在android4.0系統(tǒng)上調(diào)試,。 1.修改shell為root權(quán)限: 在init.rc中修改: service console /system/bin/sh console disabled user root group log 這樣shell就有root權(quán)限了 2. 仿造其它設(shè)備的做法,在device/***/****/BoardConfig.mk中添加了以下語句: BOARD_WPA_SUPPLICANT_DRIVER := NL80211 WPA_SUPPLICANT_VERSION := VER_0_8_X WIFI_DRIVER_LOAD_DYNAMIC := false BOARD_HOSTAPD_DRIVER := NL80211 NUFRONT_NUSMART := true BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_wext_nl80211 BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_wext_nl80211 BOARD_WLAN_DEVICE := wlan0 WIFI_DRIVER_FW_PATH_STA := "/system/etc/firmware/rt2870_sta.bin" WIFI_DRIVER_FW_PATH_AP := "/system/etc/firmware/rt2870.bin" 同時按照一篇老外的文檔修改了一些配置,,包括hardware下的wifi.c 編譯可以通過,,但是啟動系統(tǒng)后,,打開wifi時失敗:Failed to open wlan fw path param 這句話是wifi.c中報出來的,,主要是想通過寫驅(qū)動屬性文件fwpath的方法來傳遞firmware. 但是ralink在kernel3.0中自帶的驅(qū)動是沒有這個屬性的. 3.為了簡化調(diào)試,,我決定先調(diào)試wifi功能,所以在BoardConfig.mk中去掉了HOSATP相關(guān)的設(shè)置,。 但是無法啟動普通wifi功能,,主要報錯如下: E/SoftapController( 977): SIOCGIPRIV failed: -1 E/SoftapController( 977): Softap fwReload - failed: -1 E/WifiStateMachine( 1062): Failed to reload STA firmware java.lang.IllegalStateException: Error communicating to native daem E/WifiConfigStore( 1062): Error parsing configurationjava.io.FileNotFoundException: /data/misc/wifi/ipconfig.txt: open faile) E/wpa_supplicant( 1951): wpa_driver_nl80211_driver_cmd: failed to issue private commands E/wpa_supplicant( 1951): wpa_driver_nl80211_driver_cmd: failed to issue private commands E/wpa_supplicant( 1951): wpa_driver_nl80211_driver_cmd: failed to issue private commands E/wpa_supplicant( 1951): wpa_driver_nl80211_driver_cmd: failed to issue private commands E/WifiStateMachine( 1062): Failed to set frequency band 0 4.將wpa_driver_nl80211_driver_cmd函數(shù)入口處直接return 0后,sta模式可以工作,,但稍微有點不穩(wěn)定現(xiàn)象,。 接下來嘗試ap模式。 在frameworks/base/core/res/res/values/config.xml中設(shè)置config_tether_wifi_regexs項,添加<item>wlan0</item> 驗證了沒有RT2870STA.dat也可以正常工作 順便驗證了一些使用ap的firmware看sta功能是否可以使用,,答案是可以的,。但不知道android是否重新load了sta的firmware 5如果按照目前的設(shè)置,ap不成功,,報錯如下: E/SoftapController( 977): SIOCGIPRIV failed: -1 E/SoftapController( 977): Softap fwReload - failed: -1 E/WifiStateMachine( 1062): Exception in softap start java.lang.IllegalStateException: Error communicating to native daemon 6.修改了默認(rèn)的rt2870.bin為ap的firmware,。同時存放了RT2870AP.dat。 打開了hostapd,。 結(jié)果:失敗 log如下: E/WifiHW ( 977): Failed to open wlan fw path param (No such file or directory) E/SoftapController( 977): Softap fwReload - failed: -1 E/WifiStateMachine(1062): Exception in softap start java.lang.IllegalStateException: Error communicating to native daemon 又驗證了不打開hostapd,,也失敗了,,失敗信息和第5點一樣,。 7.接下來將softapcontroller.cpp中的fw reload函數(shù)直接返回成功,再進(jìn)行驗證,,同時打開了hostapd,。 wifi熱點建立成功了,但是無法連接,。 可能和沒有tethering目標(biāo)有關(guān)系,。 8.打開kernel中的相關(guān)選項后,ubuntu已經(jīng)完美實現(xiàn)Ap功能了,,同時可以利用eth0實現(xiàn)tethering. 但是android中,,可以建立ap成功,但是可能由于沒有tethering upstream 接口,,所以可以看到AP,,但是無法連接上。 但是ubuntu中沒有upstream也是可以連接上的,,難道android必須有upstream才能建立連接嗎,?還是說dhcp相關(guān)配置不對? 9.android中dhcp服務(wù)器使用的是dnsmasq,。 在ubuntu下嘗試了dnsmasq,,發(fā)現(xiàn)也無法分配地址。 命令:dnsmasq --conf-file=./etc/dnsmasq.conf 設(shè)置wlan0 ip為192.168.0.1 最后發(fā)現(xiàn)是因為dnsmasq.conf配置得不正確,,下面是我的正確配置: interface=wlan0 bind-interfaces except-interface=lo dhcp-range=192.168.0.0,192.168.0.150,12h dhcp-option=1,255.255.255.0 #subnet mask dhcp-option=28,192.168.0.255 #broadcast dhcp-option=3,192.168.0.1 #default gateway dhcp-option=6,192.168.0.1 #DNS 其中的關(guān)鍵就是dhcp-range要包括從192.168.0.0開始.現(xiàn)在在ubuntu上已經(jīng)可以分配IP了?。?! 如果Dnsmasq配置正確,,使用netstat -pan命令可以看到dnsmasq在監(jiān)聽端口67. 10.android的softap連接成功了,也分配了地址,。 我只是在system/netd/softapController.cpp中增加了一些hostapd.conf的設(shè)置: asprintf(&wbuf, "interface=%s\ndriver=nl80211\nssid=%s\nchannel=6\nhw_mode=g\nmacaddr_acl=0\nignore_broadcast_ssid=0\nauth_algs=1\n", iface, ssid); 并且打開了hostapd的debug信息,。同時去掉了hostapd/android.mk中的#L_CFLAGS += -DANDROID_BRCM_P2P_PATCH。 嘗試了幾次連接后,居然連接成功了,。真不知道是哪個改動生效了,。成功log如下: D/hostapd ( 1755): mgmt::assoc_req D/hostapd ( 1755): association request: STA=00:15:00:16:64:62 capab_info=0x401 listen_interval=10 D/hostapd ( 1755): new AID 1 D/hostapd ( 1755): nl80211: Set beacon (beacon_set=1) D/hostapd ( 1755): wpa_driver_nl80211_send_mlme: Sending frame using monitor interface/l2 socket D/hostapd ( 1755): mgmt::auth cb D/hostapd ( 1755): mgmt::assoc_resp cb I/hostapd ( 1755): wlan0: AP-STA-CONNECTED 00:15:00:16:64:62 D/hostapd ( 1755): IEEE 802.1X: Ignore STA - 802.1X not enabled or forced for WPS D/hostapd ( 1755): nl80211: Event message available D/hostapd ( 1755): nl80211: New station 00:15:00:16:64:62 D/hostapd ( 1755): wpa_driver_nl80211_send_mlme: Sending frame using monitor interface/l2 socket D/hostapd ( 1755): wpa_driver_nl80211_send_mlme: Sending frame using monitor interface/l2 socket [ 3095.000000] phy0 -> rt2x00usb_watchdog_tx_status: Warning - TX queue 2 status timed out, invoke forced tx handler D/hostapd ( 1755): wpa_driver_nl80211_send_mlme: Sending frame using monitor interface/l2 socket D/hostapd ( 1755): wpa_driver_nl80211_send_mlme: Sending frame using monitor interface/l2 socket D/hostapd ( 1755): wpa_driver_nl80211_send_mlme: Sending frame using monitor interface/l2 socket D/hostapd ( 1755): wpa_driver_nl80211_send_mlme: Sending frame using monitor interface/l2 socket D/hostapd ( 1755): wpa_driver_nl80211_send_mlme: Sending frame using monitor interface/l2 socket D/hostapd ( 1755): wpa_driver_nl80211_send_mlme: Sending frame using monitor interface/l2 socket D/Tethering( 1036): TetherModeAliveState.processMessage what=5 D/Tethering( 1036): chooseUpstreamType(false), preferredApn =5, got type=-1 D/Tethering( 1036): notifying tethered with iface =null D/Tethering( 1036): TetheredState.processMessage what=12 I/dnsmasq ( 1757): enter dhcp packet! E/dnsmasq ( 1757): enter dhcp reply! I/dnsmasq ( 1757): DHCPDISCOVER(wlan0) 192.168.43.99 00:15:00:16:64:62 I/dnsmasq ( 1757): DHCPOFFER(wlan0) 192.168.43.99 00:15:00:16:64:62 I/dnsmasq ( 1757): enter dhcp packet! E/dnsmasq ( 1757): enter dhcp reply! I/dnsmasq ( 1757): DHCPREQUEST(wlan0) 192.168.43.99 00:15:00:16:64:62 I/dnsmasq ( 1757): DHCPACK(wlan0) 192.168.43.99 00:15:00:16:64:62 ys-laptop |
|