This article takes the RealTek 8192cu WiFi module as an example to introduce the debugging notes of USB WiFi in jelly bean 4.1.
1. Overview of wifi disconnection
If the Wi-Fi cannot be opened, you can select the WiFi option under the settings of the UI and set it to on, but the final result is automatically turned off), enabling Wi-Fi, scanning, and so on.
2. Problem Analysis Process
Wi-Fi cannot be opened. hardware and software are usually used first. Overall analysis process
3. confirm that the hardware can be identified
The 8192cu WiFi module is based on the USB interface. The wifi is set to the on status on the UI, and the device can be identified by entering lsusb through the serial port.
The red mark bus 002 device 003: Id 0133: 8176 is the vid and PID of 8192cu USB wifi on the platform. It indicates that the system can normally identify 8192cu USB WiFi devices, and the hardware is correct.
4. confirm that the driver is loaded.
After confirming that the hardware is correct, check whether the driver is loaded, lsmod.
When you place WiFi in the settings of the ui in the on state, if it can be opened normally, enter lsmod in the serial port, the following results will be displayed:
Marked 8192cu KO in red, indicating that the 8192cu WiFi driver has been successfully loaded. If this Ko file is not displayed, switch to the platform/system/lib/directory, check whether Ko of 8192cu exists in this directory.
We can see that the platform has 8192cu. Ko. If you have this file under the platform, go to Step 5 for further analysis. If your platform does not have this file, go to step 6 for further analysis.
5. The driver Ko file is available in the platform/system/lib.
First, make sure that the permission is at least-RW-r -- (that is, 644). If the permission is incorrect, modify the permission as follows:
Chmod644 8192cu. Ko
If these operations are normal, manually load them first.
Manual loading instructions: First switch to the platform/system/lib/directory, and then perform the following operations:
Insmod8192cu. Ko
If the manual loading is successful, go to a for the next analysis. If the manual loading fails, go to B for the next analysis.
A. Manual loading is successful, indicating that the UI loading is unsuccessful because the system configuration file is incorrect and the driver is not loaded to the specified path.
If you are using Android 4.1, configure as follows:
Make sure that the following configuration exists in the boardconfig. mk file under the device \ XXX directory:
Wifi_driver: = rtl8192cu
Wifi_driver_module_path: =/system/lib/8192cu. Ko
Wifi_driver_module_name: = 8192cu
Wifi_driver specifies the driver to be loaded when you enable WiFi from the UI; wifi_driver_module_path indicates where the Ko file of the driver is to be loaded; wifi_driver_module_name indicates the name of the driver module.
B. the driver cannot be loaded manually. Generally, there are two reasons:
(1) The protocol was not compiled into the kernel during kernel compilation. the G18 public board is configured by default. If no configuration is available, you should first enter the common directory before compiling the kernel, enter make menuconfig with the content in networkingsupport.
(2) The compiling driver kernel is not the same code as the running kernel on your current platform. This can be clearly seen from the manual loading failure log, therefore, make sure that the compiling driver kernel is the same code as the kernel running on your current platform. The safest way is to repackage and upgrade
For which of the two reasons, the log that fails to load the driver can easily see that the magic number does not match.
6. No driver Ko file in platform/system/lib
You need to compile the Ko file of 8192cu, and the driver is in the common/Drivers/NET/wireless/rtl8xxx_cu. Copy it to the/system/lib/directory and modify its permissions. The command to modify permissions is as follows:
Chmod644 8192cu. Ko
Note: when compiling the 8192cu driver, ensure that the kernel code of the compilation driver is the same as the kernel code currently running by the system. Otherwise, the Ko file cannot be loaded, an error message indicating that the compiled driver does not match the kernel version of the current system is displayed.
If this operation still fails to be loaded, follow the steps below to package and upgrade.
(1) configure the corresponding file according to a in Step 6.
(2) Compile 8192cu driver 8192cu. Ko and copy it to device \ XXX.
(3) package and upgrade.
7. Hardware OK and driver loaded
After positioning and solving the above problems, it is no problem to load the WiFi driver from the settings of the UI, under normal circumstances, the UI page displays the different APS scanned by WiFi, but it is not ruled out that WiFi cannot be opened. At this time, the following phenomena are involved, when a flash is found, it turns off again, and "Wi-Fi is being enabled..." is displayed on the interface ...... ", there is also the display is scanning, the problem may occur in the wpa_supplicant, please go to 8 for further analysis.
8. wpa_supplicant Analysis
8.1 wpa_supplicant-related documents and service Validation
(1) confirm the existence of wpa_supplicant on the platform/system/bin:
The procedure is as follows:
130 | [email protected]:/system/bin # ls-l wpa_supplicant
-Rwxr-XR-x root shell 686672
Make sure that the file operation attribute is at least-rwxr-XR-X (755)
(2) for Android 4.1, check that init. RC under device \ XXX contains the following service:
Service p2p_supplicant/system/bin/wpa_supplicant \
-Ip2p0-dnl80211-C/data/MISC/WiFi/p2p_supplicant.conf \
-E/data/MISC/WiFi/entropy. bin-puse_p2p_group_interface = 1 \
-N-iwlan0-Dnl80211-C/data/MISC/WiFi/wpa_supplicant.conf
Class main
Socket wpa_wlan0 dgram 0660 WiFi
Disabled
Oneshot
Service wpa_supplicant/system/bin/wpa_supplicant \
-Iwlan0-dnl80211-C/data/MISC/WiFi/wpa_supplicant.conf \
-E/data/MISC/WiFi/entropy. Bin
Class main
Socket wpa_wlan0 dgram 0660 WiFi
Disabled
P2p_supplicant is the service when WiFi is started as the P2P function, and wpa_supplicant is the service when WiFi is started as the station function.
8.2 change wifi to on, and then turn off after a flash
There are two main situations for this phenomenon:
(1) The wpa_supplicant and p2p_supplicant configuration files are missing on the platform.
Check whether the wpa_supplicant.conf and p2p_supplicant.conf files exist in the platform/data/MISC/WiFi/directory, and confirm the operation permissions of these files. The operation instructions are as follows:
130 | [email protected]:/data/MISC/WiFi # ls-L * supplicant. conf
-RW ---- system WiFi 219 2013-07-03 03: 28p2p_supplicant.conf
-RW ---- system WiFi 374 1970-01-02 00: 35wpa_supplicant.conf
(2) confirm the interfaces provided by WiFi:
This part mainly requires you to know what functions WiFi serves, that is, whether WiFi is only used as the station function, or whether to enable the P2P function. When WiFi is used as the station function, wpa_supplicant service is enabled, p2p_supplicantf is enabled when WiFi is used as the P2P function.
Wpa_supplicant is enabled when WiFi is used as the station function. In this case, no interface error occurs, because wlan0 is used only in the wpa_supplicant service, even if the wlan0 underlying driver is not defined on the upper layer, the wlan0 interface is generated by default.
When p2p_supplicant is enabled as the P2P function, an interface error may occur. Because p2p_supplicant Service uses the p2p0 interface, you need to define p2p0 in advance.
If you do not define the p2p0 interface, but sometimes the p2p_supplicant service is started during loading, the p2p_supplicant service will use the p2p0 interface, so loading fails. So how can we make the system not start the p2p_supplicant service first, but start the wpa_supplicant service first? This is because your platform/etc/permisssions/directory contains android. hardware. wiFi. direct. to delete or rename an XML file, you must reboot the file before it takes effect. The operation instructions are as follows:
130 | [email protected]:/etc/permissions # ls-l
-RW-r -- root Root 158 amlogic. libplayer. xml
-RW-r -- root Root 150 2008-08-01 12: 00amlogic. pppoe. xml
-RW-r -- root Root 168 2008-08-01 12: 00amlogic. Subtitle. xml
-RW-r -- root Root 975 Android. Hardware. USB. accessory. xml
-RW-r -- root Root 868 Android. Hardware. USB. Host. xml
-RW-r -- root Root 843 Android. Hardware. Wifi. Direct. xml
-RW-r -- root Root 829 Android. Hardware. Wifi. xml
-RW-r -- root Root 1050 Android. Software. live_wallpaper.xml
-RW-r -- root Root 880 2008-08-01 12: 00android. Software. Sip. VoIP. xml
-RW-r -- root Root 828 2008-08-01 12: 00com. Android. Location. provider. xml
-RW-r -- root Root 828 2008-08-01 12: 00com. Google. widevine. Software. DRM. xml
-RW-r -- root Root 10536 platform. xml
-RW-r -- root Root 2614 2008-08-01 12: 00tablet_core_hardware.xml
How can I determine whether p2p_supplicant or wpa_supplicant is started? Because you start the p2p_supplicant service when p2p0 is not defined, the following log is clearly displayed in the log:
Wpa_supplicant (4316): p2p0: failed to initialize Driver Interface
Tip: To avoid loading failure due to the interface, follow the following settings to avoid such errors:
For Android 4.1, make sure boarconfig. mk in the device \ XXX directory contains the following content:
Wifi_driver_module_arg: = "ifname = wlan0 if2name = p2p0"
9. "enabling Wi-Fi..." on the UI ......"
This phenomenon generally has the following situations:
(1) the configuration file is missing: Confirm according to steps 8
(2) failed to load the driver, so that no underlying network interface is generated, so that supplicant fails to initialize the underlying network interface, but supplicant will try to reinitialize the interface several times, if the initialization still fails after a period of time, the supplicant will exit and the WiFi on the UI will become off.
How to check whether the interfaces of the Wi-Fi module on the platform are generated? Enter the netcfg command in the serial port as follows:
130 | [email protected]:/# netcfg
Lo up 127.0.0.1/8 0x00000049 00: 00: 00: 00: 00: 00
Eth0 down 0.0.0.0/0 0 0x00001002 00: 56: 0b: D9: 59: 65
Sit0 down 0.0.0.0/0 0 0x00000080 00: 00: 00: 00: 00: 00
Ip6tnl0 down 0.0.0.0/0 0x0000008000: 00: 00: 00: 00: 00
Wlan0 up 192.168.0.138/24 0x00001043 34: 08: 04: DF: 9A: 63
P2p0 up 0.0.0.0/0 0x00001003 36: 08: 04: DF: 9A: 63
This is my operation result on my own machine. The wlan0 and p2p0 interfaces marked in red are two interfaces for communication with supplicant generated by the WiFi module.
(3) The underlying WiFi module has already produced corresponding interfaces in the system, but supplicant fails to initialize these interfaces, mainly because the underlying driver has a problem with the interface functions provided to supplicant, this problem is generally caused by the underlying driver. Please report it to the author for further analysis.
10. "scanning ap..." on the UI ......"
Generally, this problem occurs because the communication between supplicant and the underlying WiFi driver is faulty. Please report it to the author for analysis.
USB WiFi debugging notes