九鼎创展论坛

标题: [Android]移植wifi芯片8686时遇到的一些错误 [打印本页]

作者: armeasy    时间: 2011-12-23 17:58
标题: [Android]移植wifi芯片8686时遇到的一些错误
网上有很多详细的介绍如何为Android移植WIFI芯片驱动的文章,以 Porting Wifi drivers to android比较全面一些,在这里就不详细记录移植过程,仅记录遇到的几个问题,相信能找到这里来的朋友,也是和我遇到同样的问题。

1 在Android里启用wifi,无法取得扫描结果,wifi开关不断的开与关..
在后台消息可以看到这样子的提示:
D/wpa_supplicant( 2239): wpa_driver_priv_driver_cmd RSSI-APPROX len = 4096
E/wpa_supplicant( 2239): wpa_driver_priv_driver_cmd failed
D/wpa_supplicant( 2239): wpa_driver_priv_driver_cmd LINKSPEED len = 4096
E/wpa_supplicant( 2239): wpa_driver_priv_driver_cmd failed
D/wpa_supplicant( 2239): wpa_driver_priv_driver_cmd MACADDR len = 4096
E/wpa_supplicant( 2239): wpa_driver_priv_driver_cmd failed
V/WifiStateTracker( 1883): Connection to supplicant established, state=SCANNING
D/NetworkStateTracker( 1883): setDetailed state, old =DISCONNECTED and new state=SCANNING
D/wpa_supplicant( 2239): wpa_driver_priv_driver_cmd RXFILTER-ADD 0 len = 4096
E/wpa_supplicant( 2239): wpa_driver_priv_driver_cmd failed
D/wpa_supplicant( 2239): wpa_driver_priv_driver_cmd BTCOEXSCAN-STOP len = 4096
E/wpa_supplicant( 2239): wpa_driver_priv_driver_cmd failed
I/wpa_supplicant( 2239): CTRL-EVENT-DRIVER-STATE HANGED
V/WifiMonitor( 1883): Event [CTRL-EVENT-DRIVER-STATE HANGED]
D/ConnectivityService( 1883): Dropping ConnectivityChange for WIFI: DISCONNECTED/SCANNING
E/WifiStateTracker( 1883): Wifi Driver reports HUNG - reloading.
以上消息是在external/wpa_supplicant/driver_wext.c中的wpa_driver_priv_driver_cmd输出的,在函数中这样子一段语句:
    iwr.u.data.pointer = buf;
iwr.u.data.length = buf_len;
    if ((ret = ioctl(drv->ioctl_sock, SIOCSIWPRIV, &iwr)) < 0) {
perror("ioctl[SIOCSIWPRIV]");
wpa_printf(MSG_ERROR, "ioctl[SIOCSIWPRIV]:%s", strerror(errno));
}
    if (ret < 0) {
wpa_printf(MSG_ERROR, "%s failed", __func__);
drv->errors++;
        if (drv->errors > WEXT_NUMBER_SEQUENTIAL_ERRORS) {
drv->errors = 0;
wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "HANGED");
}
    }
看来这是由于liberats驱动没有提供SIOCSIWPRIV接口而造成的错误,那这就比较简单可以解决掉,在liberatas驱动里做个空接口函数用来响应SIOCSIWPRIV命令。
patch fo driver/net/wireless/libertas/wext.c
--- wext.c.orig 2010-06-03 12:56:51.000000000 +0800
+++ wext.c      2010-07-30 14:05:46.431773120 +0800
@@ -2135,6 +2135,20 @@
return ret;
}

+/**
+ * @brief android private interface
+ *
+ * @param dev                  A pointer to net_device structure
+ * @param info                        A pointer to iw_request_info structure
+ * @param vwrq                A pointer to iw_param structure
+ * @param extra               A pointer to extra data buf
+ * @return                    0 --success, otherwise fail
+ */
+static int android_handler_private(struct net_device *dev, struct iw_request_info *info,
+                         struct iw_point *dwrq, char *extra)
+{
+       return 0;
+}
/*
* iwconfig settable callbacks
*/
@@ -2151,7 +2165,7 @@
(iw_handler) NULL,      /* SIOCGIWSENS */
(iw_handler) NULL,      /* SIOCSIWRANGE */
(iw_handler) lbs_get_range,     /* SIOCGIWRANGE */
-       (iw_handler) NULL,      /* SIOCSIWPRIV */
+       (iw_handler) android_handler_private , /* SIOCSIWPRIV */
(iw_handler) NULL,      /* SIOCGIWPRIV */
(iw_handler) NULL,      /* SIOCSIWSTATS */
(iw_handler) NULL,      /* SIOCGIWSTATS */

2.DHCP问题,在获取IP后,后台消息却提示超时
D/dhcpcd ( 2247): sending DHCP_DISCOVER with xid 0xf7faf029, next in 4.17 seconds
D/dhcpcd ( 2247): offered 192.168.0.152 from 192.168.0.1 `My Host'
D/dhcpcd ( 2247): sending DHCP_REQUEST with xid 0xf7faf029, next in 4.49 seconds
D/dhcpcd ( 2247): acknowledged 192.168.0.152 from 192.168.0.1 `My Host'
D/dhcpcd ( 2247): checking 192.168.0.152 is available on attached networks
D/dhcpcd ( 2247): sending ARP probe (1 of 3), next in 1.66 seconds
D/dhcpcd ( 2247): sending ARP probe (2 of 3), next in 1.70 seconds
D/dhcpcd ( 2247): sending ARP probe (3 of 3), next in 2.00 seconds
D/dhcpcd ( 2247): leased 192.168.0.152 for 604800 seconds
D/dhcpcd ( 2247): adding IP address 192.168.0.152/24
D/dhcpcd ( 2247): adding route to 0.0.0.0/0 via 192.168.0.1
D/dhcpcd ( 2247): executing `/system/etc/dhcpcd/dhcpcd-run-hooks', reason BOUND
D/dhcpcd ( 2247): forking to background
D/dhcpcd ( 2276): sending ARP announce (1 of 2), next in 2.00 seconds
D/dhcpcd ( 2276): sending ARP announce (2 of 2)
D/dhcpcd ( 2276): renew in 604776 seconds
I/WifiStateTracker( 1885): DhcpHandler: DHCP request failed: Timed out waiting for DHCP to finish
解决:在init.rc中增加
setprop wifi.interface eth1






欢迎光临 九鼎创展论坛 (http://bbs.9tripod.com/) Powered by Discuz! X3.2