本次修改基于厂商提供的
RTL8723BU_WiFi_linux_v4.3.16_14189.20150519_BTCOEX2015119-5844包
下载链接:http://download.csdn.net/detail/bhj1119/9761769
一 修改记录:
1.配置linux内核
(1)Networking support --->Wireless下增加802.11 协议栈的支持
---
Wireless
[*] nl80211 testmode command [*] enable warnings [*] cfg80211 regulatory debugging [*] enable powersave by default developer [ ] cfg80211 DebugFS entries [ ] use statically compiled regulatory rules database [*] cfg80211 wireless extensions compatibility [*] Wireless extensions sysfs files -*- Common routines for IEEE802.11 drivers [ ] lib80211 debugging messages [*] Allow reconnect while already connected [ ] PID controller based rate control algorithm [*] Minstrel [*] Minstrel 802.11n support Default rate control algorithm (Minstrel) ---> [*] Enable mac80211 mesh networking (pre-802.11s) support [*] Enable LED triggers [ ] Export mac80211 internals in DebugFS [ ] Select mac80211 debugging features ---> (2) 配置Device Drivers --->USB support ---><*> USB Wireless Device Management support 支持WIFI 2.将RTL8723BU_WiFi_linux_v4.3.16_14189.20150519_BTCOEX2015119-5844/driver下的压缩包拷贝到ANDROID_SDK/kernel_imx/drivers/net/wireless下,解压,修改其Makefile,编译wifi驱动模块,修改内容如下: CONFIG_PLATFORM_IMX6Q = y ifeq ($(CONFIG_PLATFORM_IMX6Q), y) EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DCONFIG_PLATFORM_ANDROID -- DRTW_USE_CFG80211_STA_EVENT DCONFIG_ANDROID -DCONFIG_CONCURRENT_MODE ARCH := arm CROSS_COMPILE := XXX/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi- KSRC := XXX/kernel_imx// MODULE_NAME := 8723bu endif 如果(1)中选项没有选上,会导致加载wifi模块时报如下错误: rtl8723bu: no symbol version for cfg80211_ready_on_channel rtl8723bu: Unknown symbol cfg80211_ready_on_channel (err -22) rtl8723bu: Unknown symbol odm_SwAntDetectInit (err 0) rtl8723bu: no symbol version for __ieee80211_get_channel rtl8723bu: Unknown symbol __ieee80211_get_channel (err -22) rtl8723bu: no symbol version for cfg80211_roamed rtl8723bu: Unknown symbol cfg80211_roamed (err -22) rtl8723bu: no symbol version for wiphy_register rtl8723bu: Unknown symbol wiphy_register (err -22) 原因就是:编译WiFi模块时会去KSRC所指的路径下找相应的库,若果相关的编译选项没有选上会导致某些库缺失,从而导致编出来的WiFi模块不完整。 上述是由于编译内核时内有勾选80211协议栈导致。 3.用厂商提供的hardware/realtek 替换hardware/realtek 4.用厂商提供的wpa_supplicant_8_kk_4.4_rtw_r12456.20141003替ANDROID_SDK/extern/wpa_supplicant_8,并修改文件夹的名字为wpa_supplicant_8。5.hardware/libhardware_legacy/wifi/Android.mk 修改内容如下: --- Android.mk (版本 170) +++ Android.mk (工作副本) @@ -49,15 +49,21 @@ LOCAL_CFLAGS += DWIFI_DRIVER_FW_PATH_PARAM=\\\"$(WIFI_DRIVER_FW_PATH_PARAM)\\\" endif -ifeq ($(BOARD_WLAN_DEVICE),UNITE) 换 - - LOCAL_C_INCLUDES $(LOCAL_PATH)/../../external/wpa_supplicant_ath/wpa_supplicant/src/common - LOCAL_SRC_FILES += wifi/wifi_unite.c -else ifeq ($(BOARD_WLAN_VENDOR), INTEL) - LOCAL_SRC_FILES += wifi/wifi_intel.c - LOCAL_C_INCLUDES $(LOCAL_PATH)/../../external/wpa_supplicant_8/src/common +#ifeq ($(BOARD_WLAN_DEVICE),UNITE) +# LOCAL_C_INCLUDES $(LOCAL_PATH)/../../external/wpa_supplicant_ath/wpa_supplicant/src/common +# LOCAL_SRC_FILES += wifi/wifi_unite.c +#else ifeq ($(BOARD_WLAN_VENDOR), INTEL) +# LOCAL_SRC_FILES += wifi/wifi_intel.c +# LOCAL_C_INCLUDES $(LOCAL_PATH)/../../external/wpa_supplicant_8/src/common += += += += +#else +# LOCAL_SRC_FILES += wifi/wifi.c +# LOCAL_C_INCLUDES $(LOCAL_PATH)/../../external/wpa_supplicant_8/src/common +#endif + +ifeq ($(BOARD_WIFI_VENDOR), realtek) +LOCAL_SRC_FILES += ../realtek/wlan/libhardware_legacy/wifi/wifi_realtek.c else - LOCAL_SRC_FILES += wifi/wifi.c - LOCAL_C_INCLUDES $(LOCAL_PATH)/../../external/wpa_supplicant_8/src/common +LOCAL_SRC_FILES += wifi/wifi.c endif += += 6.修改device/fsl/sabresd_6dq/BoardConfig.mk 修改内容如下: --- BoardConfig.mk (版本 170) +++ BoardConfig.mk (工作副本) @@ -26,6 +26,33 @@ TARGET_BOOTLOADER_BOARD_NAME := SABRESD PRODUCT_MODEL := SABRESD-MX6DQ + +BOARD_WIFI_VENDOR := realtek +ifeq ($(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_HOSTAPD_DRIVER := NL80211 +BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_rtl +#BOARD_WLAN_DEVICE := rtl8192cu +#BOARD_WLAN_DEVICE := rtl8192du +#BOARD_WLAN_DEVICE := rtl8192ce +#BOARD_WLAN_DEVICE := rtl8192de +#BOARD_WLAN_DEVICE := rtl8723as +#BOARD_WLAN_DEVICE := rtl8723au +#BOARD_WLAN_DEVICE := rtl8189es +#BOARD_WLAN_DEVICE := rtl8723bs +BOARD_WLAN_DEVICE := rtl8723bu +WIFI_DRIVER_MODULE_NAME := \"8723bu\" +WIFI_DRIVER_MODULE_PATH := \"/system/lib/modules/8723bu.ko\" +WIFI_DRIVER_MODULE_ARG := \"ifname=wlan0 if2name=p2p0\" +WIFI_FIRMWARE_LOADER := \"\" +WIFI_DRIVER_FW_PATH_STA := \"\" +WIFI_DRIVER_FW_PATH_AP := \"\" +WIFI_DRIVER_FW_PATH_P2P := \"\" +WIFI_DRIVER_FW_PATH_PARAM := \"\" +else # UNITE is a virtual device support both atheros and realtek wifi(ar6103 and rtl8723as) BOARD_WLAN_DEVICE := UNITE WPA_SUPPLICANT_VERSION := VER_0_8_UNITE @@ -39,6 +66,7 @@ BOARD_WPA_SUPPLICANT_PRIVATE_LIB_QCOM := lib_driver_cmd_qcwcn BOARD_HOSTAPD_PRIVATE_LIB_RTL := lib_driver_cmd_rtl BOARD_WPA_SUPPLICANT_PRIVATE_LIB_RTL := lib_driver_cmd_rtl +endif #for intel vendor ifeq ($(BOARD_WLAN_VENDOR),INTEL) BOARD_HOSTAPD_PRIVATE_LIB := private_lib_driver_cmd @@ -118,3 +146,4 @@ fs_use \\ untrusted_app.te \\ genfs_contexts 上述步骤完成后,到根目录下执行make 编译整个系统。 二 测试 1.安装cfg80211.ko,8723bu.ko依赖此模块,缺省会报如下错误: 8723bu: Unknown symbol cfg80211_ready_on_channel (err 0) 8723bu: Unknown symbol __ieee80211_get_channel (err 0) 8723bu: Unknown symbol cfg80211_roamed (err 0) 8723bu: Unknown symbol wiphy_register (err 0) 8723bu: Unknown symbol cfg80211_disconnected (err 0) 8723bu: Unknown symbol cfg80211_new_sta (err 0) 8723bu: Unknown symbol cfg80211_connect_result (err 0) 8723bu: Unknown symbol cfg80211_inform_bss_frame (err 0) 2.安装8723bu.ko模块,两个模块都安装好之后,执行netcfg,会看到多出wlan0和p2p0设备节点,他们是8723bu驱动创建出来的,放到sys/class/net/下。 lo UP 127.0.0.1/8 0x00000049 00:00:00:00:00:00 can0 DOWN 0.0.0.0/0 0x00000080 00:00:00:00:00:00 can1 DOWN 0.0.0.0/0 0x00000080 00:00:00:00:00:00 eth0 UP 0.0.0.0/0 0x00001043 1e:ed:19:27:1a:b3 wlan0 DOWN 0.0.0.0/0 0x00001002 7c:c7:09:30:c5:4d p2p0 DOWN 0.0.0.0/0 0x00001002 7e:c7:09:30:c5:4d 3.执行ifconfig wlan0 up,打开wlan0 4.执行system/bin/wpa_supplicant -Dnl80211 -iwlan0 - c/etc/wifi/wpa_supplicant.conf,启动wpa_supplicant进程。 启动过程报如下错误: E/wpa_supplicant( 3251): mkdir[ctrl_interface=wlan0]: Permission denied E/wpa_supplicant( 3251): Failed to initialize control interface 'wlan0'. E/wpa_supplicant( 3251): You may have another wpa_supplicant process already running or the file was E/wpa_supplicant( 3251): left by an unclean termination of wpa_supplicant in which case you will need E/wpa_supplicant( 3251): to manually remove this file before starting wpa_supplicant again. 错误原因:wpa_supplicant进程运行时的配置文件wpa_supplicant.conf文件中的ctrl_interface的路径不对,没有匹配成功,导致进程启动失败。原来ctrl_interface的路径是/var/run/wpa_supplicant,把ctrl_interface改成/data/misc/wifi/wpa_supplicant就可以了。 ctrl_interface在哪里?在工程下的 external/wpa_supplicant_8/wpa_supplicant/wpa_supplicant.conf中。 深入分析: wpa_supplicant_init_iface函数分析 init_iface初始化的第一个工作是解析运行时配置文件。其中,wpa_s->confname的值为“/data/misc/wifi/wpa_supplicant.conf”,解析函数是wpa_config_read。 wpa_s->ctrl_iface = wpa_supplicant_ctrl_iface_init(wpa_s); if (wpa_s->ctrl_iface == NULL) { wpa_printf(MSG_ERROR, \"Failed to initialize control interface '%s'.\\n\" \"You may have another wpa_supplicant process \" \"already running or the file was\\n\" \"left by an unclean termination of wpa_supplicant \" \"in which case you will need\\n\" \"to manually remove this file before starting \" \"wpa_supplicant again.\\n\ wpa_s->conf->ctrl_interface); return -1; } 如果是linux系统,可能没有wpa_supplicant工具,可参考wpa_supplicant-2.6交叉编译 ,移植此工具。 5.执行system/bin/wpa_cli -p/data/misc/wifi/wpa_supplicant,配置并连接wifi热点。 Could not connect to wpa_supplicant: wlan0 - re-trying wpa_cli v2.0-devel-4.4.2_rtw_r12456.20141003 Copyright (c) 2004-2013, Jouni Malinen This software may be distributed under the terms of the BSD license. See README for more details. Selected interface 'wlan0' Interactive mode 1)> scan OK <3>CTRL-EVENT-STATE-CHANGE id=-1 state=3 BSSID=00:00:00:00:00:00 SSID= <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= 2)> scan_results bssid / frequency / signal level / flags / ssid 78:eb:14:bd:f6:9e 2412 -58 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] B1412 bc:67:1c:41:29:4d 2437 -65 [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][WPS][ESS] systec-cisco e0:05:c5:23:fc:52 2452 -71 [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][WPS][ESS] 30:fc:68:0b:c9:f6 CCMP][ESS] gsdq 2437 -71 [WPA-PSK-CCMP][WPA2-PSK- ec:26:ca:53:ea:f1 2462 -72 [WPA-PSK-CCMP][WPA2-PSK-CCMP][WPS][ESS] TP-LINK_EAF1 00:1f:f3:bf:d0:6f 2462 -73 [WPA2-PSK-CCMP][ESS] tcs apple d4:ee:07:29:9b:4a 2442 -73 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] Cherry&Filippo 24:69:68:16:a9:1e 2462 -74 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] \\xe6\\xb2\\x83\\xe7\\x95\\x89 fc:d7:33:8d:0a:36 2412 -74 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] dangyuanweixin b0:c0:90:3a:24:a3 2422 -74 [WPA2-PSK- CCMP][ESS] 360\\xe8\\xa1\\x8c\\xe8\\xbd\\xa6\\xe8\\xae\\xb0\\xe5\\xbd\\x95\\xe4\\xbb\\xaa-A3 c8:3a:35:1f:5f:88 2422 -80 [WPA-PSK-CCMP][WPA2-PSK- CCMP][ESS] wangzihao c8:3a:35:06:a9:b0 2452 -82 [WPA-PSK-CCMP][ESS] Tenda_06A9B0 00:3a:99:9b:9b:40 2417 -45 [WEP][ESS] systec-AP 00:0c:43:30:50:a0 2437 -51 [ESS] Wii-Link_3050A0 08:10:78:e1:27:a5 2412 -74 [ESS] NETCORE_27A5 3)> add_network 0 4)> set_network 0 ssid \"systec-cisco\" OK 5)> set_network 0 psk \"XXX\" OK 6)> select_network 0 OK <3>CTRL-EVENT-STATE-CHANGE SSID=systec-cisco id=0 state=3 BSSID=00:00:00:00:00:00 <3>CTRL-EVENT-SCAN-RESULTS <3>WPS-AP-AVAILABLE <3>Trying to associate with bc:67:1c:41:29:4d (SSID='systec-cisco' freq=2437 MHz) <3>CTRL-EVENT-STATE-CHANGE SSID=systec-cisco id=0 state=5 BSSID=00:00:00:00:00:00 <3>CTRL-EVENT-STATE-CHANGE SSID=systec-cisco id=0 state=6 BSSID=00:00:00:00:00:00 <3>Associated with bc:67:1c:41:29:4d <3>CTRL-EVENT-STATE-CHANGE SSID=systec-cisco id=0 state=7 BSSID=bc:67:1c:41:29:4d <3>CTRL-EVENT-STATE-CHANGE SSID=systec-cisco id=0 state=8 BSSID=bc:67:1c:41:29:4d <3>WPA: Key negotiation completed with bc:67:1c:41:29:4d [PTK=CCMP GTK=TKIP] <3>CTRL-EVENT-CONNECTED - Connection to bc:67:1c:41:29:4d completed (auth) [id=0 id_str=] <3>CTRL-EVENT-STATE-CHANGE SSID=systec-cisco 7)enable_network 0 OK 查看链接状态: > status bssid=bc:67:1c:41:29:4d ssid=systec-cisco id=0 mode=station pairwise_cipher=CCMP id=0 state=9 BSSID=bc:67:1c:41:29:4d group_cipher=TKIP key_mgmt=WPA2-PSK wpa_state=COMPLETED p2p_device_address=7c:c7:09:30:c5:4d address=7c:c7:09:30:c5:4d <3>CTRL-EVENT-STATE-CHANGE SSID=systec-cisco id=0 state=9 BSSID=bc:67:1c:41:29:4d <3>CTRL-EVENT-CONNECTED - connection to bc:67:1c:41:29:4d completed (auth) [id=0 id_str=] 执行dhcpcd wlan0 分配IP,此时再netcfg查看,wlan0de ip 已经变成10.0.0.118 root@sabresd_6dq:/ # netcfg lo UP 127.0.0.1/8 0x00000049 00:00:00:00:00:00 can0 DOWN 0.0.0.0/0 0x00000080 00:00:00:00:00:00 can1 DOWN 0.0.0.0/0 0x00000080 00:00:00:00:00:00 eth0 UP 0.0.0.0/0 0x00001043 1e:ed:19:27:1a:b3 wlan0 UP 10.0.0.118/24 7c:c7:09:30:c5:4d p2p0 DOWN 0.0.0.0/0 7e:c7:09:30:c5:4d ping 一下看看通不通 root@sabresd_6dq:/ # ping 192.168.1.1 PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data. 64 bytes from 192.168.1.1: icmp_seq=1 ttl=63 time=29.1 ms 64 bytes from 192.168.1.1: icmp_seq=2 ttl=63 time=15.9 ms 64 bytes from 192.168.1.1: icmp_seq=3 ttl=63 time=16.4 ms 64 bytes from 192.168.1.1: icmp_seq=4 ttl=63 time=14.3 ms 0x00001002 0x00001043 64 bytes from 192.168.1.1: icmp_seq=5 ttl=63 time=14.0 ms ^C --- 192.168.1.1 ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4006ms rtt min/avg/max/mdev = 14.034/17.991/29.183/5.672 ms 至此wifi模块移植完毕,可以实现扫描,链接,分配IP 因篇幅问题不能全部显示,请点此查看更多更全内容