android上USBWifi调试记录
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
android上USBWifi调试记录
android上USB Wifi调试记录
.内容描述:
2014-12-15,操作记录_android上TL-WN725N USB Wifi调试过程。
初始现象:
Linux下能连接网络,Wifi Setting 界面无法设置wifi。
操作1:android wifi配置及启动脚本以适应TL-WN725N网卡。
android-4.2.2_r1\device\friendly-
arm\tiny4412\BoardConfig.mk
中加入:
BOARD_USES_REALTEK_WIFI := true
BoardConfigCommon.mk中加入
BOARD_WIFI_VENDOR := realtek:
WPA_SUPPLICANT_VERSION := VER_0_8_X
BOARD_WPA_SUPPLICANT_DRIVER := NL80211
CONFIG_DRIVER_WEXT :=y
BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_rtl
BOARD_WLAN_DEVICE := rtl8192cu
WIFI_DRIVER_MODULE_NAME:= "wlan"
WIFI_DRIVER_MODULE_PATH := "/system/lib/modules/8188eu.ko"
WIFI_DRIVER_MODULE_ARG := "ifname=wlan0"
WIFI_FIRMWARE_LOADER := ""
WIFI_DRIVER_FW_PATH_STA := ""
WIFI_DRIVER_FW_PATH_PARAM := ""
init.tiny4412.rc 加入:
#peng++
mkdir /data/system/wpa_supplicant 0777 wifi wifi
chmod 0777 /data/system/wpa_supplicant
chown wifi wifi /data/system/wpa_supplicant
操作2:TL-WN725N WIFI HAL层移植
1)RTL8188EUS_linux_v4.1.4_6773.20130222\android_ref_cod es_JB_4.2\rea
ltek_wifi_SDK_for_android_JB_4.2_20130208.tar.gz拷贝到
android-4.2.2_r1\hardware目录,解压改名为realtek
android-
4.2.2_r1\hardware\libhardware_legacy\wifi\Android.mk中
LOCAL_SRC_FILES += wifi/wifi.c
改为
ifeq ($(BOARD_WIFI_VENDOR), realtek)
LOCAL_SRC_FILES
+= ../realtek/wlan/libhardware_legacy/wifi/wifi_realtek.c else
LOCAL_SRC_FILES += wifi/wifi.c
Endif
2)针对界面无法打开Wifi问题,为方便调试,修改为手动加载卸载驱动:
让wifi_load_driver,rmmod直接返回0(成功)。
int wifi_load_driver()
{
return 0;
}
static int rmmod(const char *modname)
{
return 0;
}
操作3:wpa_supplicant层移植。
1)备份原有源码android-4.2.2_r1\external\wpa_supplicant_8,复制
rtl8188EUS_linux_v4.1.4_6773.20130222\wpa_supplicant_ho stapd\wpa_supplicant _8_jb_4.2_rtw_r8680.20130821.tar.gz到android-4.2.2_r1\external
解压并更名为wpa_supplicant_8
2)wpa_supplicant_8\wpa_supplicant\android.config中加入以下配置:CONFIG_DRIVER_WEXT=y
CONFIG_DRIVER_NL80211=y
#CONFIG_P2P=y
#CONFIG_AP=y
改为
CONFIG_P2P=n
CONFIG_AP=n
然后:
cp android.config .config
此时重新编译wpa_supllicant
3)运行wpa_supllicant时应有
….
drivers:
wext = Linux wireless extensions (generic)
nl80211 = Linux nl80211/cfg80211
…
操作3:wpa_supplicant运行调试。
问题一:文件目录权限问题。
1)运行wpa_supplicant -Dwext -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf -dd -B 无反应
# ps后没发现wpa_supplicant
使用strace 调试,
strace wpa_supplicant -Dwext -iwlan0 -
c/data/misc/wifi/wpa_supplicant.conf -dd –B 发现:
mkdir("wlan0", 0770) = -1 EACCES (Permission denied) write(2, "mkdir[ctrl_interface]", 21mkdir[ctrl_interface]) = 21 write(2, ": ", 2: ) = 2
write(2, "Permission denied", 17Permission denied) = 17
ls /data/system 查看是否有目录wpa_supplicant,并确保读写权限,所有人,所属组为Wifi。
mkdir /data/system/wpa_supplicant
chmod 660 /data/system/wpa_supplicant
chown 1010 /data/system/wpa_supplicant
chgrp 1010 /data/system/wpa_supplicant
问题二:wpa_supplicant.conf 配置问题。
运行wpa_supplicant -Dwext -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf -dd –B 依旧提示:mkdir("wlan0", 0770) = -1 EACCES (Permission denied) write(2, "mkdir[ctrl_interface]", 21mkdir[ctrl_interface]) = 21 write(2, ": ", 2: ) = 2
write(2, "Permission denied", 17Permission denied) = 17
vi /etc/wifi/wpa_supplicant.conf
ctrl_interface=wlan0(android标准)
改为
ctrl_interface=DIR=/data/system/wpa_supplicant GROUP=wifi (Unix标准)
问题三:不能启动supplicant。
提示:E/WifiStateMachine(442): Failed to start supplicant!
经调试,发现错误发生在:
android-
4.2.2_r1\hardware\realtek\wlan\libhardware_legacy\wifi\wifi_real tek.c中wifi_start_supplicant的
if (p2p_supported && wifi_ifname(SECONDARY) == NULL)
android-
4.2.2_r1\external\wpa_supplicant_8\wpa_supplicant\Makefile中
#peng-- CFLAGS += -DANDROID -DANDROID_P2P -DREALTEK_WIFI_VENDOR
-DCONFIG_ANDROID_4_2_PERSISTENT_IOT
改为
CFLAGS += -DANDROID -DREALTEK_WIFI_VENDOR
-DCONFIG_ANDROID_4_2_PERSISTENT_IOT
改完后运行logcat提示
I/wpa_supplicant(1744): Successfully initialized wpa_supplicant
ps 可以看到
1157 1010 0:00 wpa_supplicant -Dwext -iwlan0 -c/data/misc/wifi/wpa_supplicant
此时运行wpa_cli -p/data/system/wpa_supplicant -iwlan0
会进入
Interactive mode
> status
wpa_state=DISCONNECTED
address=08:57:00:98:6b:31
<3>CTRL-EVENT-STATE-CHANGE id=-1 state=0 BSSID=00:00:00:00:00:00 SSID=
> scan
OK
<3>CTRL-EVENT-STATE-CHANGE id=-1 state=3 BSSID=00:00:00:00:00:00 SSID=
> [ 71.550000] ==> rtl8188e_iol_efuse_patch
[ 71.825000] RTL871X: nolinked power save leave
<3>CTRL-EVENT-SCAN-RESULTS
<3>WPS-AP-AVAILABLE
<3>CTRL-EVENT-STATE-CHANGE id=-1 state=2 BSSID=00:00:00:00:00:00 SSID=
> scan_results
bssid / frequency / signal level / flags / ssid
20:dc:e6:b7:74:ec 2437 -63 [WPA2-PSK-CCMP][WPS][ESS] uthandwriter
14:75:90:ae:ed:bc 2412 -71
[WPA-PSK-CCMP][WPA2-PSK-CCMP][WPS][ESS] UCF-TESTP 04:da:d2:75:f4:10 2412 -71 [WPA2-PSK-CCMP][ESS] 7F-LAN 04:da:d2:75:fc:70 2412 -72 [WPA2-PSK-CCMP][ESS] 7F-LAN bc:f6:85:9f:3a:da 2462 -72
[WPA-PSK-TKIP+CCMP][WPA2-PSK-TKIP+CCMP][ESS] zlghserver
28:e3:47:ad:b4:10 2457 -83 [WPA2-PSK-CCMP][ESS]
360\xe5\x85\x8d\xe8\xb4\xb9WiFi-XG
1c:fa:68:cd:50:02 2457 -45 [WPS][ESS] HELLO_TL-WN725N 14:75:90:20:0a:8a 2437 -73 [ESS] maize
> add_network
> set_network 0 ssid "HELLO_TL-WN725N"
OK
> s et_network 0 key_mgmt NONE
Or //set_network 0 key_mgmt WPA-PSK
//set_network 0 psk '"12345678"'
OK
> select_network 0
OK
<3>CTRL-EVENT-STATE-CHANGE id=0 state=3 BSSID=00:00:00:00:00:00
SSID=HELLO_TL-WN725N
> <3>CTRL-EVENT-SCAN-RESULTS
<3>WPS-AP-AVAILABLE
> [ 336.215000] RTL871X: set ssid [HELLO_TL-WN725N] fw_state=0x00000008 [ 336.215000] RTL871X: set bssid:1c:fa:68:cd:50:02
[ 336.225000] RTL871X: start auth
[ 336.230000] RTL871X: auth success, start assoc
[ 336.230000] RTL871X: assoc success
[ 336.230000] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready [ 336.240000] UpdateHalRAMask8188EUsb => mac_id:0, networkType:0x0b, mask:0x000fffff
[ 336.240000] ==> rssi_level:0, rate_bitmap:0x000ff005
<3>Trying to associate with 1c:fa:68:cd:50:02 (SSID='HELLO_TL-WN725N' freq=2457 MHz)
<3>CTRL-EVENT-STATE-CHANGE id=0 state=5 BSSID=00:00:00:00:00:00
SSID=HELLO_TL-WN725N
<3>CTRL-EVENT-STATE-CHANGE id=0 state=6 BSSID=00:00:00:00:00:00
SSID=HELLO_TL-WN725N
<3>Associated with 1c:fa:68:cd:50:02
<3>CTRL-EVENT-CONNECTED - Connection to 1c:fa:68:cd:50:02 completed (auth) [id=0 id_str=]
<3>CTRL-EVENT-STATE-CHANGE id=0 state=9 BSSID=1c:fa:68:cd:50:02
SSID=HELLO_TL-WN725N
>save
OK //测试会在data/misc/wifi/ 生成wpa_supplicant.conf
>quit
UT@utcooker:/data # dhcpcd wlan0
…
dhcpcd[1358]: wlan0: NAK: from 192.168.1.1
dhcpcd[1358]: wlan0: sending IPv6 Router Solicitation
dhcpcd[1358]: wlan0: broadcasting for a lease
dhcpcd[1358]: wlan0: offered 0.0.0.1 from 192.168.1.101
dhcpcd[1358]: wlan0: acknowledged 0.0.0.1 from 192.168.1.101
UT@utcooker:/data/misc/wifi # ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1): 56 data bytes
64 bytes from 192.168.1.1: seq=0 ttl=64 time=3.437 ms
64 bytes from 192.168.1.1: seq=1 ttl=64 time=1.351 ms
问题四:不能connect supplicant。
提示:Supplicant not running, cannot connect
E/WifiStateMachine(442): Failed to setup control channel, restart supplicant
此时ps能看到wpa_supplicant在运行
Wpa_cli操作配置网络正常。
Android界面Setting能打开但无法搜索Wifi。
经调试:
在android-4.2.2_r1\hardware\realtek\wlan\libhardware_legacy\wifi\wifi_real tek.c 中
if (property_get(supplicant_prop_name, supp_status, NULL) && strcmp(supp_status, "running") == 0) {
return 0;
}
检查得知wpa_supplicant服务正在运行
UT@utcooker:/data/misc/wifi #
getprop init.svc.wpa_supplicant Running
故修改:
static const char SUPPLICANT_NAME[] = "rtw_suppl"; /*
without p2p concurrent */
static const char SUPP_PROP_NAME[] = "init.svc.%s";
为:
static const char SUPPLICANT_NAME[] = "wpa_supplicant"; /* peng add */
static const char SUPP_PROP_NAME[] = "init.svc.wpa_supplicant";//peng add 此时能搜索wifi,有以下信息01-0113:03:08.305: D/WifiStateMachine(376): setWifiState: enabled
问题五:Setting不能连接wifi
提示:nl80211: Failed to set interface 6 to mode 2: -19
wpa_supplicant -Dnl80211 -iwlan0 -c/data/misc/wifi/wpa_suppplicant.conf -dd –B 此时使用nl80211方式启动wpa_supplicant时出现如下错误:
01-01 12:31:39.660: W/wpa_supplicant(2099):
======>UT:wpa_driver_nl80211_set_mode
01-01 12:31:39.660: D/wpa_supplicant(2099): nl80211: Set mode ifindex 6 iftype 2 (STATION)
01-01 12:31:39.660: W/wpa_supplicant(2099): nl80211: nl80211_cmd(drv, msg, 0, NL80211_CMD_SET_INTERFACE);
01-01 12:31:39.660: W/wpa_supplicant(2099): nl80211: send_and_recv_msgs
ret=-19
01-01 12:31:39.660: D/wpa_supplicant(2099): nl80211: Failed to set interface 6 to mode 2: -19 (No such device)
01-01 12:31:39.660: W/wpa_supplicant(2099): ======>UT:if (res == -ENODEV)
01-01 12:31:39.660: W/wpa_supplicant(2099): UT:wpa_driver_nl80211_set_mode, res == -ENODEV
01-0112:31:39.660: E/wpa_supplicant(2099): wlan0: Failed to
initialize driver interface01-01 12:31:39.660: D/wpa_supplicant(2099): nl80211: Failed to set interface 6 to mode 2: -19 (No such device)
程序执行到send_and_recv_msgs时出错,经测试发现调用的为wpa_supplicant 自身的函数,而
hardware\realtek\wlan\wpa_supplicant_8_lib\driver_cmd_nl 80211.c中也有
send_and_recv_msgs函数。
而在BoardConfigCommon.mk中,有
BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_rtl
external/wpa_supplicant_ /wpa_supplicant/Android.mk中有: LOCAL_STATIC_LIBRARIES += $(BOARD_WPA_SUPPLICANT_PRIVATE_LIB)
在/vendor/friendly-arm/exynos4412/prebuilt/Android.mk有:$(call
add-friendlyarm-
file,$(BOARD_WPA_SUPPLICANT_PRIVATE_LIB).a,STATIC_LIBRARI ES) 而\vendor\friendly-arm\exynos4412\prebuilt\目录下有lib_driver_cmd_fanl.a
原有BoardConfigCommon.mk中,有
BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_fanl
把vendor/friendly-arm/exynos4412/prebuilt/Android.mk有:$(call
add-friendlyarm-
file,$(BOARD_WPA_SUPPLICANT_PRIVATE_LIB).a,STATIC_LIBRARI ES) 改为
$(call add-friendlyarm-file, lib_driver_cmd_fanl.a,STATIC_LIBRARIES)
此时重新生成编译烧写内核。
就可以在Setting界面配置连接wifi。
正常使用,去除多余调试信息。
RTL8188EUS_new_4.1.7\driver\rtl8188EUS_rtl8189ES_linux_v 4.1.7_9024.20130916\ hal\OUTSRC\odm_debug.c :
pDM_Odm->DebugLevel = ODM_DBG_TRACE;
打印等级改为
pDM_Odm->DebugLevel = ODM_DBG_WARNING;
\RTL8188EUS_new_4.1.7\driver\rtl8188EUS_rtl8189ES_linux_
v4.1.7_9024.20130916 \autoconf_rtl8188e_usb_linux.h中//peng-- #define DBG 1
//peng-- #define CONFIG_DEBUG
//peng-- #define CONFIG_DEBUG_RTL871X
wpa_supplicant –Dnl80211 -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf -dd -B。