本文讲述在Linux 3.10下Realek RTL8723A Linux Wifi 驱动的移植。
Prerequisites
硬件平台:Atmel SAMA5
软件平台:Linux 3.10 + Android 4.4
Wifi模组:RTL8723AU (USB接口)
Realtek RTL8723A Wi-Fi Software& Driver for Linux and Android
RTL8723A_WiFi_linux_v4.1.6_7336.20130426_CCC02.zip
目录结构
liaops@ubuntu-server:/media/android/liaops/temp/RTL8723A_WiFi_linux_v4.1.6_7336.20130426$tree -L 2
.
├──android_ref_codes_JB_4.1
│ ├── linux-3.0.42_STATION_INFO_ASSOC_REQ_IES.diff
│ ├── realtek_wifi_SDK_for_android_JB_4.1_20130306.tar.gz
│ └── Realtek_Wi-Fi_SDK_for_Android_JB_4_1.pdf
├──android_ref_codes_JB_4.2 // Android JB 4.2 Realtek Wifi移植
│ ├──linux-3.0.42_STATION_INFO_ASSOC_REQ_IES.diff
│ ├── realtek_wifi_SDK_for_android_JB_4.2_20130208.tar.gz
│ └──Realtek_Wi-Fi_SDK_for_Android_JB_4_2.pdf //移植文档
├──android_reference_codes
│ ├── realtek_wifi_SDK_for_android_20120618.tar.gz
│ └── realtek_wifi_SDK_for_android.txt
├──android_reference_codes_ICS_nl80211
│ ├── realtek_wifi_SDK_for_android_ICS_20120621.tar.gz
│ └── Realtek_Wi-Fi_SDK_for_Android_ICS.pdf
├── document
│ ├── HowTo_enable_driver_to_support_80211d.pdf
│ ├──HowTo_enable_driver_to_support_WIFI_certification_test.pdf
│ ├── HowTo_enable_the_power_saving_functionality.pdf
│ ├── HowTo_support_more_VidPids.pdf
│ ├── linux_dhcp_server_notes.txt
│ ├── Quick_Start_Guide_for_Bridge.pdf
│ ├──Quick_Start_Guide_for_Driver_Compilation_and_Installation.pdf
│ ├── Quick_Start_Guide_for_SoftAP.pdf
│ ├── Quick_Start_Guide_for_Station_Mode.pdf
│ ├── Realtek_WiFi_concurrent_mode_Introduction.pdf
│ ├── RTK_P2P_WFD_Programming_guide.pdf
│ ├── SoftAP_Mode_features.pdf
│ ├── Wireless_tools_porting_guide.pdf
│ └── wpa_cli_with_wpa_supplicant.pdf
├── driver
│ └──rtl8723A_WiFi_linux_v4.1.6_7336.20130426_CCC02.tar.gz // Realek RTL8723A Linux Wifi 驱动
├── hardware_wps_pbc
│ ├── Readme.txt
│ └── sample.c
├── install.sh
├── mp_tools
│ └── RTL8723A_MPDoc
├── readme.txt
├── ReleaseNotes.pdf
├──WiFi_Direct_User_Interface
│ ├── Android.mk
│ ├── install.sh
│ ├── p2p_api_test_linux.c
│ ├── p2p_test.h
│ ├── p2p_ui_test_linux.c
│ └── Start_Guide_P2P_User_Interface_Linux.pdf
├── wireless_tools
│ └──wireless_tools.30.rtl.tar.gz //Linux下对无线网络配置的工具,包括iwlist,iwpriv,iwconfig等
└──wpa_supplicant_hostapd
├── p2p_hostapd.conf
├── rtl_hostapd_2G.conf
├── rtl_hostapd_5G.conf
├── wpa_0_8.conf
├──wpa_supplicant_8_jb_4.1_rtw_r7281.20130424.tar.gz
├──wpa_supplicant_8_jb_4.2_rtw_r7279.20130424.tar.gz
└──wpa_supplicant_hostapd-0.8_rtw_r7048.20130424.tar.gz
内核配置
内核编译前确保Linux配置
# make menuconfig
使能WLAN网络支持:
[*] Networking support--->
-*- Wireless --->
使能Wireless LAN设备驱动:
Device Drivers --->
[*] Network device support --->
[*] Wireless LAN --->
使能RealTekRTL8712U无线网卡驱动:
Device Drivers --->
[*] Staging drivers --->
目的是打开CONFIG_WIRELESS_EXT=y和CONFIG_WEXT_PRIV=y
上述操作在内核中使能下述CONFIG选项:
CONFIG_WIRELESS=y
CONFIG_WLAN=y
CONFIG_WIRELESS_EXT=y
CONFIG_WEXT_CORE=y
CONFIG_WEXT_PROC=y
CONFIG_WEXT_PRIV=y
使能USB Host支持:
Device Drivers --->
[*] USB support --->
<*> Support for Host-side USB
<*> EHCI HCD (USB 2.0) support
编译内核
根据上述内核配置编译内核。
Wifi驱动配置与编译
解压缩驱动源码:rtl8723A_WiFi_linux_v4.1.6_7336.20130426_CCC02.tar.gz
进入驱动源码目录:
├──autoconf_rtl8723a_sdio_linux.h
├──autoconf_rtl8723a_usb_linux.h
├── clean
├── core
├── hal
├── ifcfg-wlan0
├── include
├── Kconfig
├──Kconfig_rtl8723a_sdio_linux
├──Kconfig_rtl8723a_usb_linux
├── make_drv
├── Makefile
├── os_dep
├── runwpa
└── wlan0dhcp
修改Makefile,添加AT91平台支持
@@-44,7 +44,7 @@ CONFIG_EXT_CLK = n
CONFIG_FTP_PROTECT =n
CONFIG_WOWLAN = n
-CONFIG_PLATFORM_I386_PC= y
+CONFIG_PLATFORM_I386_PC= n
CONFIG_PLATFORM_ANDROID_X86= n
CONFIG_PLATFORM_ARM_S3C2K4= n
CONFIG_PLATFORM_ARM_PXA2XX= n
@@-75,6 +75,7 @@ CONFIG_PLATFORM_ARM_SUN6I = n
CONFIG_PLATFORM_ACTIONS_ATM702X= n
CONFIG_PLATFORM_MN10300= n
CONFIG_PLATFORM_ACTIONS_ATV5201= n
+CONFIG_PLATFORM_ARM_AT91= y
CONFIG_DRVEXT_MODULE= n
@@-651,6 +652,14 @@ KVER := $(KERNEL_VER)
KSRC:=$(CFGDIR)/../../kernel/linux-$(KERNEL_VER)
endif
+ifeq($(CONFIG_PLATFORM_ARM_AT91), y)
+EXTRA_CFLAGS+= -DCONFIG_LITTLE_ENDIAN
+ARCH:= arm
+CROSS_COMPILE:= /usr/local/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-eabi-
+KSRC:= /media/android/liaops/miura/kernel
+MODULE_NAME:= wlan
+endif
+
ifneq($(USER_MODULE_NAME),)
MODULE_NAME :=$(USER_MODULE_NAME)
endif
修改autoconf_rtl8723a_usb_linux.h以使能STA+P2P并存模式:
@@-50,7 +50,7 @@
#defineSUPPORT_HW_RFOFF_DETECTED
-//#defineCONFIG_IOCTL_CFG80211
+#defineCONFIG_IOCTL_CFG80211
#ifdefCONFIG_PLATFORM_ARM_SUNxI
#ifndef CONFIG_IOCTL_CFG80211
#define CONFIG_IOCTL_CFG80211
@@-59,7 +59,7 @@
#ifdefCONFIG_IOCTL_CFG80211
//#define RTW_USE_CFG80211_STA_EVENT /* Indecate new sta asoc throughcfg80211_new_sta */
-#define CONFIG_CFG80211_FORCE_COMPATIBLE_2_6_37_UNDER
+//#define CONFIG_CFG80211_FORCE_COMPATIBLE_2_6_37_UNDER
//#define CONFIG_DEBUG_CFG80211
#define CONFIG_SET_SCAN_DENY_TIMER
#endif
@@-86,7 +86,7 @@
//#define CONFIG_DBG_P2P
#define CONFIG_P2P_PS
-//#define CONFIG_P2P_IPS
+#define CONFIG_P2P_IPS
#endif
// Added by Kurt20110511
@@-102,7 +102,7 @@
#defineCONFIG_LAYER2_ROAMING
#defineCONFIG_LAYER2_ROAMING_RESUME
-//#defineCONFIG_CONCURRENT_MODE
+#defineCONFIG_CONCURRENT_MODE
#ifdefCONFIG_CONCURRENT_MODE
#define CONFIG_TSF_RESET_OFFLOAD // For 2 PORT TSF SYNC.
//#define CONFIG_HWPORT_SWAP //Port0->Sec , Port1 -> Pri
编译驱动
make KSRC=<内核源代码码路径>
当前目录下得到Wifi驱动模块:wlan.ko
编译Android源代码
编译wireless_tools无线网络管理工具
解压缩wireless_tools.30.rtl.tar.gz到Android源代码 external/目录下
(1)tar zxvf wireless_tools.30.rtl.tar.gz
(2)cp wireless_tools.30.rtl
(3)cd
(4)make iwconfig iwlist iwpriv
安装Wifi驱动模块
将wlan.ko拷贝到Android文件系统out/target/product/sama5d3/system/lib/modules目录下
制作Android根文件系统并烧写到开发板
测试
启动后插入USB Wifi模块
usb 1-2: newhigh-speed USB device number 2 using atmel-ehci
usb 1-2: NewUSB device found, idVendor=0bda, idProduct=0724
usb 1-2: NewUSB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-2:Product: 802.11n WLAN Adapter
usb 1-2:Manufacturer: Realtek
usb 1-2:SerialNumber: 00e04c000001
加载模块前
root@sama5d3:/ # netcfg
eth0 UP 0.0.0.0/0 0x000010433a:1f:34:08:54:54
can0 DOWN 0.0.0.0/0 0x0000008000:00:00:00:00:00
sit0 DOWN 0.0.0.0/0 0x0000008000:00:00:00:00:00
lo UP 127.0.0.1/8 0x0000004900:00:00:00:00:00
加载模块
root@sama5d3:/# insmod /system/lib/modules/wlan.ko
usbcore:registered new interface driver rtl8723au
加载模块后
root@sama5d3:/# netcfg
wlan0 DOWN 0.0.0.0/0 0x00001002 00:02:72:3c:0c:c1
wlan1 DOWN 0.0.0.0/0 0x00001002 02:02:72:3c:0c:c1
eth0 UP 0.0.0.0/0 0x00001043 3a:1f:34:08:54:54
can0 DOWN 0.0.0.0/0 0x00000080 00:00:00:00:00:00
sit0 DOWN 0.0.0.0/0 0x00000080 00:00:00:00:00:00
lo UP 127.0.0.1/8 0x00000049 00:00:00:00:00:00
可以看到多了两个接口wlan0和wlan1。
打开wlan0
root@sama5d3:/# netcfg wlan0 up
IPv6:ADDRCONF(NETDEV_UP): wlan0: link is not ready
RTL871X:nolinked power save enter
执行命令iwlist wlan0 scanning,搜索可用的无线AP
部分结果如下:
root@sama5d3:/# iwlist wlan0 scanning
RTL871X:nolinked power save leave
wlan0Scan completed :
Cell 01 - Address: D8:15:0D:D9:1F:F0
ESSID:"Intest_Hardware"
Protocol:IEEE 802.11bgn
Mode:Master
Frequency:2.412 GHz (Channel 1)
Encryption key:on
Bit Rates:300 Mb/s
Extra:wpa_ie=dd160050f20101000050f20401000050f20401000050f202
IE: WPA Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
Extra:rsn_ie=30140100000fac040100000fac040100000fac020000
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: DD180050F204104A00011010440001021049000600372A000120
Quality=0/100 Signal level=-74 dBm
Cell 02 - Address: A8:57:4E:FC:4B:3E
ESSID:"\xBE\xDE\xC3\xC0\xB9\xFA\xBC\xCA"
Protocol:IEEE 802.11bgn
Mode:Master
Frequency:2.437 GHz (Channel 6)
Encryption key:on
Bit Rates:300 Mb/s
Extra:wpa_ie=dd160050f20101000050f20401000050f20401000050f202
IE: WPA Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
Extra:rsn_ie=30140100000fac040100000fac040100000fac020000
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown:DD9B0050F204104A0001101044000102103B0001031047001000000000000010000000A8574EFC4B101021000754502D4C494E4B1023000A544C2D5744523333323010240003312E3010420003312E301054000800060050F20400011011001A576972656C65737320526F7574657220544C2D57445233333230100800020086103C000101104900140024E26002000101600000020001600100020001
Quality=0/100 Signal level=-71 dBm
Cell 03 - Address: 1C:BD:B9:C7:84:98
ESSID:"hikvision"
Protocol:IEEE 802.11bgn
Mode:Master