【原创】调试ralink 5370 wifi芯片 二
参考文档: http://blog.csdn.net/z642010820/article/details/7341476http://blog.csdn.net/lanbo_g/article/details/6821840 http://blog.csdn.net/darkengine/article/details/7024459 http://blog.linuxconsulting.ro/2010/04/porting-wifi-drivers-to-android.html 接下来在android4.0系统上调试。 1.修改shell为root权限:在init.rc中修改: service console /system/bin/sh console disabled user root group log 这样shell就有root权限了 2. 仿造其它设备的做法,在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 编译可以通过,但是启动系统后,打开wifi时失败:Failed to open wlan fw path param 这句话是wifi.c中报出来的,主要是想通过写驱动属性文件fwpath的方法来传递firmware. 但是ralink在kernel3.0中自带的驱动是没有这个属性的. 3.为了简化调试,我决定先调试wifi功能,所以在BoardConfig.mk中去掉了HOSATP相关的设置。 但是无法启动普通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函数入口处直接return 0后,sta模式可以工作,但稍微有点不稳定现象。 接下来尝试ap模式。 在frameworks/base/core/res/res/values/config.xml中设置config_tether_wifi_regexs项,添加<item>wlan0</item> 验证了没有RT2870STA.dat也可以正常工作 顺便验证了一些使用ap的firmware看sta功能是否可以使用,答案是可以的。但不知道android是否重新load了sta的firmware 5如果按照目前的设置,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.修改了默认的rt2870.bin为ap的firmware。同时存放了RT2870AP.dat。 打开了hostapd。 结果:失败 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函数直接返回成功,再进行验证,同时打开了hostapd。 wifi热点建立成功了,但是无法连接。 可能和没有tethering目标有关系。 8.打开kernel中的相关选项后,ubuntu已经完美实现Ap功能了,同时可以利用eth0实现tethering. 但是android中,可以建立ap成功,但是可能由于没有tethering upstream 接口,所以可以看到AP,但是无法连接上。 但是ubuntu中没有upstream也是可以连接上的,难道android必须有upstream才能建立连接吗?还是说dhcp相关配置不对? 9.android中dhcp服务器使用的是dnsmasq。 在ubuntu下尝试了dnsmasq,发现也无法分配地址。 命令:dnsmasq --conf-file=./etc/dnsmasq.conf 设置wlan0 ip为192.168.0.1 最后发现是因为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 其中的关键就是dhcp-range要包括从192.168.0.0开始.现在在ubuntu上已经可以分配IP了!!! 如果Dnsmasq配置正确,使用netstat -pan命令可以看到dnsmasq在监听端口67. 10.android的softap连接成功了,也分配了地址。 我只是在system/netd/softapController.cpp中增加了一些hostapd.conf的设置: 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
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报 。