Transplantation of rt2870 USB wifi on mx53 Android platform
There are a lot of porting tutorials for USB wifi on the Linux platform online, but there are few complete tutorials for porting on Android. It took a whole week to transplant this driver, here are the detailed transplant notes for this week.
I. Compile the WiFi driver source code to generate the Ko File
The/etc directory exists in the Linux root file system, while the/etc directory in the android root directory is linked from the/system/etc directory.
You need to modify the WiFi source code so that the driver can find the configuration file under/system/etc.
Find the/etc/wireless file, find the following file, and change all to/system/etc/wireless:
Root @ lqm:/opt/Program/tools/rt3070_linux_sta # grep-r '/mnt/etc './
./Include/OS/rt_drv.h: # define sta_profile_path "/etc/wireless/rt2870sta/rt2870sta. dat"
./Include/OS/rt_drv.h: # define card_info_path "/etc/wireless/rt2870sta/rt2870stacard. dat"
./Include/OS/rt_drv.h: # define eeprom_bin_file_name "/etc/wireless/rt2870sta/e2p. bin"
./Include/OS/rt_linux.h: # define sta_profile_path "/etc/wireless/rt2870sta/rt2870sta. dat"
./Include/OS/rt_linux.h: # define card_info_path "/etc/wireless/rt2870sta/rt2870stacard. dat"
./Include/OS/rt_linux.h: # define eeprom_bin_file_name "/etc/wireless/rt2870sta/e2p. bin"
./OS/Linux/makefile.6: dat_path =/etc/wireless/RT $ (chipset_dat) sta
./OS/Linux/makefile.6: $ (shell [! -F/etc/wireless] & mkdir/etc/wireless)
Binary file./OS/Linux/rt_profile.o match
./OS/Linux/makefile: dat_path =/mnt/etc/wireless/RT $ (chipset_dat) sta
./OS/Linux/makefile: $ (shell [! -F/etc/wireless] & mkdir/etc/wireless)
Binary file./OS/Linux/rt3070sta. o Match
Binary file./OS/Linux/rt3070sta. Ko match
./OS/Linux/makefile.4: dat_path =/etc/wireless/RT $ (chipset_dat) sta
./OS/Linux/makefile.4: $ (shell [! -F/etc/wireless] & mkdir/etc/wireless)
Binary file./common/rtmp_init_inf.o match
./Rt2870stacard. DAT: 00 cardid =/etc/wireless/rt2870sta/rt2870sta1. dat
./Rt2870stacard. DAT: 01 cardid =/etc/wireless/rt2870sta/rt2870sta2. dat
./Rt2870stacard. DAT: 02 cardid =/etc/wireless/rt2870sta/rt2870sta3. dat
./Rt2870stacard. DAT: 00mac00: 0e: 2E: C3: D0: 48 =/etc/wireless/rt2870sta/rt2870sta1. dat
./Rt2870stacard. DAT: 01mac00: 40: F4: FF: AA: 40 =/etc/wireless/rt2870sta/rt2870sta2. dat
./Rt2870stacard. DAT: 02mac00: 0C: 43: 10: 11: 5C =/etc/wireless/rt2870sta/rt2870sta3. dat
./Rt2870stacard. DAT: 00 cardtypebgn =/etc/wireless/rt2870sta/rt2870sta1. dat
./Rt2870stacard. DAT: 01 cardtypebgn =/etc/wireless/rt2870sta/rt2870sta2. dat
./Rt2870stacard. DAT: 02 cardtypeabgn =/etc/wireless/rt2870sta/rt2870sta3. dat
Root @ lqm:/opt/Program/tools/rt3070_linux_sta #
Ii. Modify the init. RC file
Directly modify out /.... /Root init. RC file:
# Mkdir/data/MISC/WiFi 0770 WiFi # lqm changed property.
Mkdir/data/MISC/WiFi 0771 WiFi
# Chmod 0770/data/MISC/WiFi
Chmod 0771/system/etc/WiFi # lqm changed path
# Chmod 0660/data/MISC/WiFi/wpa_supplicant.conf # lqm changed path
Chmod 0660/system/etc/WiFi/wpa_supplicant.conf
Chown WiFi/system/etc/WiFi/wpa_supplicant.conf # lqm added.
On Boot
# Basic network init
IFUP Lo
Hostname localhost
Domainname localdomain
Mkdir/data/system 0775 System
Mkdir/data/system/wpa_supplicant 0771 WiFi # lqm added.
# Set DNS
# Setprop net. dns1 192.168.128.2 # lqm changed.
Setprop net. dns1 192.168.1.1
# Prepare for WiFi
Setprop wifi. Interface ra0
# Mkdir/data/MISC/WiFi/sockets 0770 WiFi
Mkdir/data/MISC/WiFi/sockets 0771 WiFi # lqm changed property
# Mkdir/data/MISC/DHCP 0770 DHCP
# Chown DHCP/data/MISC/DHCP
Mkdir/data/MISC/DHCP 0771 system # lqm changed.
# Lqm changed.
Service wpa_supplicant/system/bin/wpa_supplicant-dd-dwext-ira0-C/system/etc/WiFi/wpa_supplicant.conf
Group system WiFi inet
Disabled
Oneshot
# Lqm changed.
Service dhcpcd/system/bin/dhcpcd ra0
Group system DHCP
Disabled
Oneshot
By default, wlan0 is used in init. RC, and the Network Name of rt2860 is ra0. Therefore, you must replace all values with ra0.
3. Modify the hardware/libhardware_legacy/WiFi/wifi. c file.
Redefinition of the wifi_driver_module_path and wifi_driver_module_name macros is as follows:
# Ifndef wifi_driver_module_path
# Define wifi_driver_module_path "/system/lib/modules/rt3070sta. Ko"
# Endif
# Ifndef wifi_driver_module_name
# Define wifi_driver_module_name "rt3070sta"
# Endif
Wifi. C is used to automatically load the Ko module when it is started. Here, the manual loading method is used temporarily, and the automatic loading function will be updated later.
4. Add a line in the/device/FSL/imx53_loco/boardconfig. mk file (set according to your wireless network card type ):
Board_wpa_supplicant_driver: = wext
At the same time, screen out the relevant information. The modified code is as follows:
# Wifi_driver_module_path: = "/system/lib/modules/ar6000.ko" # lqm changed.
Wifi_driver_module_path: = "/system/lib/modules/rt3070sta. Ko"
Wifi_driver_module_arg: = ""
# Wifi_driver_module_name: = "ar6000" # lqm changed.
Wifi_driver_module_name: = "rt3070sta"
Wifi_firmware_loader: = ""
# Wpa_supplicant_version: = ver_0_6_atheros # lqm masked.
# Board_wlan_atheros_sdk: = system/WLAN/atheros/ar6ksdk. 3.0 _ rc.298 # lqm masked.
# Board_wlan_chip: = ar6003 # lqm masked.
Board_wpa_supplicant_driver: = wext
Note that wpa_supplicant_version must be blocked. Otherwise, wpa_supplicant for atheros will be used.
5. Compile wpa_supplicant separately and replace the default wpa_wupplicant for atheros file:
Source build/envsetup. Sh
Mm external/wpa_supplicant/PRODUCT-imx53_loco-eng
In this case /.... Generate a new wpa_supplicant file under/system/bin.
If the default wpa_supplicant is used, the following error will pop up during execution:
==> Rt_ioctl_giwscan. 4 (4) BSS returned, data-> length = 663
IOCTL [siocsiwgenie]: operation not su ==> rt_ioctl_giwscan. 4 (4) BSS returned, 3
Pported on transport endpoint
==> Rt_ioctl_giwscan. 4 (4) BSS returned, data-> length = 663
IOCTL [siocsiwgenie]: operation not ==> rt_ioctl_giwscan. 4 (4) BSS returned, da3
Supported on transport endpoint
==> Rt_ioctl_giwscan. 4 (4) BSS returned, data-> length = 663
IOCTL [siocsiwgenie]: operation not su ==> rt_ioctl_giwscan. 4 (4) BSS returned, 3
Pported on transport endpoint
==> Rt_ioctl_giwscan. 4 (4) BSS returned, data-> length = 663
IOCTL [siocsiwgenie]: operation not su ==> rt_ioctl_giwscan. 4 (4) BSS returned, 3
Pported on transport endpoint
==> Rt_ioctl_giwscan. 5 (5) BSS returned, data-> length = 843
IOCTL [siocsiwgenie]: operation not ==> rt_ioctl_giwscan. 5 (5) BSS returned, da3
Supported on transport endpoint
And repeated execution.
6. Create the wpa_supplicant.conf file. The content is as follows:
# WPA-PSK/TKIP
Ctrl_interface =/system/bin/wpa_supplicant
Network = {
SSID = "armeasy"
Scan_ssid = 1
Key_mgmt = WPA-EAP WPA-PSK ieee8021x none
Pairwise = TKIP CCMP
Group = ccmp tkip wep104 wep40
PSK = "phosphor"
}
Note that the SSID is the route name and phosphor is the route password. Set the route password according to your own.
Copy the wpa_supplicant.conf file to/out /.... /System/etc/WiFi directory
7. Copy the rt3070sta. Ko file generated in step 1 to/out /.... /System/lib/modules directory
8. Re-compile the android source code and burn the generated uramdisk. IMG to the SD card:
Sudo dd If =/tftpboot/uramdisk. IMG of =/dev/sdb bs = 1 m seek = 6
Burn the new system. IMG to the SD card:
Sudo dd If =/tftpboot/system. IMG of =/dev/sdb2
9. Restart the Development Board. after entering the file system, load the driver.
Manually load the driver as follows:
/System/lib/modules # insmod rt3070sta. Ko
Rt3070sta: module license 'Unspecified 'taints kernel.
Disabling lock debugging due to kernel taint
Rt3070sta: Unknown symbol usb_alloc_urb (ERR 0)
Rt3070sta: Unknown symbol usb_free_urb (ERR 0)
Rt3070sta: Unknown symbol usb_alloc_coherent (ERR 0)
Rt3070sta: Unknown symbol usb_register_driver (ERR 0)
Rt3070sta: Unknown symbol usb_put_dev (ERR 0)
Rt3070sta: Unknown symbol usb_get_dev (ERR 0)
Rt3070sta: Unknown symbol usb_submit_urb (ERR 0)
Rt3070sta: Unknown symbol usb_free_coherent (ERR 0)
Rt3070sta: Unknown symbol usb_control_msg (ERR 0)
Insmod: init_module 'rt3070sta. krt3070sta: Unknown symbol usb_deregister (ERR 0)
Rt3070sta: Unknown symbol usb_kill_urb (ERR 0)
O 'failed' (no such file or directory)
This is because GPL authorization is not added. You need to add the following line of code at the beginning of the driver source code file OS/Linux/usb_main_dev.c:
Module_license ("GPL ");
Then re-compile and re-load to get the correct results.
The normal loading information is as follows:
/# Insmod system/lib/modules/rt3070sta. Ko
Rtusb init rt2870->
=== Pad = d4a62000, size = 511440 ====
<-Rtmpalloctxrxringmemory, status = 0
<-Rtmpallocadapterblock, status = 0
Usbcore: registered new interface driver rt2870
/#
After the driver is loaded properly, run the following command to check whether the driver is loaded properly:
CAT/proc/NET/dev
The normal print is as follows:
/# Cat/proc/NET/dev
Inter-| receive | transmit
Face | bytes packets errs drop FIFO frame compressed multicast | bytes packets errs drop FIFO colls carrier compressed
Lo: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Eth0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Usb0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Sit0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Ra0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
/#
We can see that there is another ra0, which is the rt2860 driver we need.
10. Configure the IP address and enable the network port
/# Ifconfig ra0 192.168.1.5 up
(Efuse for 3062/3562/3572) size = 0x2d [2d0-2fc]
Rtmp_timerlistadd: Add timer OBJ d4aa9fb0!
Rtmp_timerlistadd: Add timer OBJ d4aa9fe0!
Rtmp_timerlistadd: Add timer OBJ d4aaa010!
Rtmp_timerlistadd: Add timer OBJ d4aa9f80!
Rtmp_timerlistadd: Add timer OBJ d4aa9ef0!
Rtmp_timerlistadd: Add timer OBJ d4aa9f20!
Rtmp_timerlistadd: Add timer OBJ d4a74b24!
Rtmp_timerlistadd: Add timer OBJ d4a63e5c!
Rtmp_timerlistadd: Add timer OBJ d4a63e94!
Rtmp_timerlistadd: Add timer OBJ d4a74bc8!
Rtmp_timerlistadd: Add timer OBJ d4a74ac4!
Rtmp_timerlistadd: Add timer OBJ d4a74b94!
-> Rtusbvenderreset
<-Rtusbvenderreset
Key1str is invalid key length (0) or type (0)
Key2str is invalid key length (0) or type (0)
Key3str is invalid key length (0) or type (0)
Key4str is invalid key length (0) or type (0)
1. PHY mode = 5
2. PHY mode = 5
PHY mode> error! The chip does not support 5G band 5!
Rtmpsetphymode: channel is out of range, use first channel = 1
(Efuse for 3062/3562/3572) size = 0x2d [2d0-2fc]
3. PHY mode = 9
MCS set = ff 00 00 00 01
<=== Rt28xx_init, status = 0
0 × 1300 = 00064300
/#
You can check whether the load is normal:
/# Ifconfig ra0
Ra0: IP 192.168.1.5 mask 255.255.255.0 flags [up broadcast running Multicast]
/#
Eleven: Port wireless_tools.29 to the Android system
Step 1: Download The wireless_tools source code package online, store it in the/externaldirectory, and decompress it. Use wireless_tools.29.tar.gz here
Download from the following URL:
Http://bbs.9tripod.com/viewthread.php? Tid = 126 & extra = Page % 3d1
Step 2: Decompress the file and generate a new wireless_tools.29 directory in the external directory.
Step 3: Create the Android. mk file in the wireless_tools.29 directory. The content is as follows:
Local_path: = $ (call my-DIR)
################## Build iwlib ###################
Include $ (clear_vars)
Local_src_files: = iwlib. c
Local_cflags + =-wstrict-prototypes-wmissing-prototypes-wshadow-wpointer-Arith-wcast-qual-winline-MMD-FPIC
Local_module: = libiw
Local_static_libraries: = libcutils libc libm
Include $ (build_static_library)
################## Build iwconfig ###################
Include $ (clear_vars)
Local_src_files: = iwconfig. c
Local_cflags + =-wstrict-prototypes-wmissing-prototypes-wshadow-wpointer-Arith-wcast-qual-winline-MMD-FPIC
Local_module: = iwconfig
Local_static_libraries: = libcutils libc libm libiw
# Local_force_static_executable: = true
Local_module_path: = $ (target_out_optional_executables) # Install to system/xbin
# Local_unstripped_path: = $ (target_root_out_unstripped)
# Local_module_tags: = ENG user
Include $ (build_executable)
################## Build iwlist ###################
Include $ (clear_vars)
Local_src_files: = iwlist. c iwlib. h
Local_cflags + =-wstrict-prototypes-wmissing-prototypes-wshadow-wpointer-Arith-wcast-qual-winline-MMD-FPIC
Local_module: = iwlist
Local_static_libraries: = libcutils libc libm libiw
# Local_force_static_executable: = true
Local_module_path: = $ (target_out_optional_executables) # Install to system/xbin
# Local_unstripped_path: = $ (target_root_out_unstripped)
# Local_module_tags: = ENG user
Include $ (build_executable)
Step 4: modify source code
1. Rename wireless.22.h to wireless. h.
2. Modify ifrename. C and add the Getline function. The code can be obtained from external/genext2fs/genext2fs. C.
3. Modify iwlib. h and change # include <net/Ethernet. h> to # include <net/if_ether.h>.
4. In iwlib. H, move the following code to # ifndef iw_ev_lcp_pk_len ...... # Make sure the following code takes effect outside the endif macro. Otherwise, the system prompts that the compilation cannot find the macro definition errors:
Struct iw_pk_event
{
_ 2010len;/* real lenght of this stuff */
_ 2010cmd;/* wireless IOCTL */
Union iwreq_data U;/* IOCTL fixed payload */
} _ Attribute _ (packed ));
Struct iw_pk_point
{
Void _ User * pointer;/* pointer to the data (in user space )*/
_ 2010length;/* number of fields or size in bytes */
_ 2010flags;/* optional Params */
} _ Attribute _ (packed ));
# Define iw_ev_lcp_pk2_len (sizeof (struct iw_pk_event)-sizeof (Union iwreq_data ))
# Define iw_ev_point_pk2_len (iw_ev_lcp_pk2_len + sizeof (struct iw_pk_point)-iw_ev_point_off)
In fact, we only need to move # endif to this code.
Step 5: In the root directory of the android source code package, execute the following code compilation files:
Source build/envsetup. Sh
MM bionic/libm PRODUCT-imx53_loco-eng
Mm external/wireless_tools.29/PRODUCT-imx53_loco-eng
After compilation is completed, iwlist, iwconfig, and other wireless tools will be generated under out/target/product/imx53_loco/system/xbin.
Step 6: Use ADB push or re-download the system. IMG image file to use wireless_tools normally.
Run the following command to find the nearby AP:
Iwlist ra0 Scan
Print the following information:
/# Iwlist ra0 Scan
==> Rt_ioctl_giwscan. 4 (4) BSS returned, data-> length = 711
Ra0 scan completed:
Cell 01-Address: B0: 48: 7A: 51: BA: 72
Protocol: 802.11b/G/n
Essid: "armeasy"
Mode: managed
Frequency: 2.412 GHz (Channel 1)
Quality = 100/100 signal level =-43 dBm noise level =-92 dBm
Encryption key: On
Bit Rates: 54 MB/S
IE: WPA version 1
Group cipher: CCMP
Pairwise ciphers (1): CCMP
Authentication suites (1): PSK
IE: IEEE 802.11i/wpa2 version 1
Group cipher: CCMP
Pairwise ciphers (1): CCMP
Authentication suites (1): PSK
IE: Unknown: dd0e0050f20da-4a0001101044000102
Cell 02-Address: 74: Ea: 3A: 1f: 6B: Fa
Protocol: 802.11b/g
Essid: "szyltf_100 ″
Mode: managed
Frequency: 2.412 GHz (Channel 1)
Quality = 47/100 signal level =-71 dBm noise level =-79 dBm
Encryption key: On
Bit Rates: 54 MB/S
IE: WPA version 1
Group cipher: CCMP
Pairwise ciphers (1): CCMP
Authentication suites (1): PSK
IE: IEEE 802.11i/wpa2 version 1
Group cipher: CCMP
Pairwise ciphers (1): CCMP
Authentication suites (1): PSK
Preauthentication supported
Cell 03-Address: 94: 0C: 6d: 69: 0b: A6
Protocol: 802.11b/g
Essid: "yltf_100 ″
Mode: managed
Frequency: 2.412 GHz (Channel 1)
Quality = 47/100 signal level =-71 dBm noise level =-66 dBm
Encryption key: On
Bit Rates: 54 MB/S
IE: WPA version 1
Group cipher: TKIP
Pairwise ciphers (2): TKIP CCMP
Authentication suites (1): PSK
IE: IEEE 802.11i/wpa2 version 1
Group cipher: TKIP
Pairwise ciphers (2): TKIP CCMP
Authentication suites (1): PSK
Preauthentication supported
Cell 04-Address: 00: 25: 86: 33: 5D: 16
Protocol: 802.11b/g
Essid: "TP-LINK_335D16 ″
Mode: managed
Frequency: 2.437 GHz (Channel 6)
Quality = 7/100 signal level =-87 dBm noise level =-82 dBm
Encryption key: On
Bit Rates: 54 MB/S
IE: WPA version 1
Group cipher: TKIP
Pairwise ciphers (2): TKIP CCMP
Authentication suites (1): PSK
IE: IEEE 802.11i/wpa2 version 1
Group cipher: TKIP
Pairwise ciphers (2): TKIP CCMP
Authentication suites (1): PSK
Preauthentication supported
/#
The first one is the AP we need to find.
12: Use the powerful wpa_supplicant to connect to the network:
/# Wpa_supplicant-dwext-ira0-C/system/etc/WiFi/wpa_supplicant.conf &
/#==> Rt_ioctl_giwscan. 4 (4) BSS returned, data-> length = 635
IOCTL [siocsiwgenie] ==> rt_ioctl_siwfreq: siocsiwfreq (Channel = 1)
: Operation not supported on transport endpoint
/#
Note that the wpa_supplicant here must be a recompiled file. If the default file is used, it is for the atheros,
The preceding error message is displayed, and the error message is printed repeatedly.
We can ping the route to test whether it works properly:
/# Ping 192.168.1.1
Ping 192.168.1.1 (192.168.1.1): 56 data bytes
Rtmp_timerlistadd: Add timer OBJ d4ad873c!
RCV wcid (1) addbareq
Start seq = 00000000
Rtmp_timerlistadd: Add timer OBJ d4ada74c!
64 bytes from 192.168.1.1: seq = 0 TTL = 64 time = 89.936 MS
64 bytes from 192.168.1.1: seq = 1 TTL = 64 time = 2.154 MS
64 bytes from 192.168.1.1: seq = 2 TTL = 64 time = 6.433 MS
64 bytes from 192.168.1.1: seq = 3 TTL = 64 time = 0.899 MS
^ C
-192.168.1.1 Ping statistics-
4 packets transmitted, 4 packets received, 0% packet loss
Round-trip min/AVG/max = 0.899/24.855/89.936 MS
/#
Thirteen: Add DNS and gateway
Before adding DNS and gateway, you cannot ping the internet. Run the following command:
Busybox IP Route add default via 192.168.1.1
Setprop net. dns1 192.168.1.1
After the settings, ping the Sina homepage to test whether the Internet can be accessed properly:
/# Ping 58.63.236.42
Ping 58.63.236.42 (58.63.236.42): 56 data bytes
64 bytes from 58.63.236.42: seq = 0 TTL = 51 time = 122.108 MS
64 bytes from 58.63.236.42: seq = 1 TTL = 51 time = 15.205 MS
64 bytes from 58.63.236.42: seq = 2 TTL = 51 time = 7.797 MS
64 bytes from 58.63.236.42: seq = 3 TTL = 51 time = 11.878 MS
^ C
-58.63.236.42 Ping statistics-
4 packets transmitted, 4 packets received, 0% packet loss
Round-trip min/AVG/max = 7.797/39.247/122.108 MS
/#
At this point, the entire USB WiFi process has passed. Because the mx53_qsb Development Board does not have an LCD screen, it can only be displayed on a computer display.
The Development Board only has one USB interface that can be used by the host. Therefore, USB WiFi cannot be used with the mouse after being connected to the USB port, so it cannot
Perform online operations on the UI. These steps will be tested after the LCD screen is available in the future. The Wi-Fi driver debugging has come to an end.