Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Android KitKat 4.4 Wifi移植之Wifi driver

Android KitKat 4.4 Wifi移植之Wifi driver

編輯:關於Android編程

本文講述在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 --->

RealTek RTL8712U (RTL8192SU) Wireless LAN NICdriver

目的是打開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 /external/

(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

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved