Android platform USB WiFi drive porting and usage

Source: Internet
Author: User
Tags chmod mkdir
A. Android platform WiFi Basic code path

1. wpa_supplicant Source Section

external/wpa_supplicant_6/

Build library libwpa_client.so and daemon wpa_supplicant

2. WiFi HAL Layer Code

Located in hardware/libhardware_legary/wifi/

3. The JNI part of WiFi

Located in Frameworks/base/core/jni/android_net_wifi_wifi.cpp

4. Java section

Located in frameworks/base/services/java/com/android/server/
frameworks/base/wifi/java/android/net/wifi/

5. WiFi Setup Section

Located in packages/apps/settings/src/com/android/settings/wifi/


Two. Linux kernel configuration

With the original Android kernel support, add the WiFi kernel configuration as follows:

1. Networkingsupport--->wireless to increase the support of the 802.11 protocol stack


2. USB Support WiFi configuration

USB WiFi-enabled configuration options are located under the device DRIVERS>USB Support configuration menu USB Wireless

Device Management Support.


3. Mdev and firmware support configuration for user space

Enter the Devicedriver > Generic Driver Options Configuration menu and configure user space as shown in the following figure

Mdev and firmware support.


4. WIFI Device Support Configuration

Devicedrivers---> Network devicesupport---> Wireless LAN---> Ralink driver Support--->ralinkrt2800 (USB) Support (experimental)--->rt2800usb-include support forrt30xx (USB) devices

And the IEEE 802.11 for Host AP (PRISM2/2.5/3 andwep/tkip/ccmp) in the WIRELESS LAN directory is selected to open Config_wireless_ext=y Config_wext_ Priv=y

three. Driver Configuration and compilation

1. Modify the configuration file in the Driver SDK package

1.1 Modify ENV.MK, set Rt28xx_dir to the current directory, Rt28xx_dir = $ (shell pwd).

1.2 Modifying the corresponding kernel and cross compiler paths in makefile

1.3 Modifying GCC and LD variables in the config.mk of the Os/linux directory

1.4 Open Os/linux directory in Config.mk has_wpa_supplicant and Has_native_wpa_supplicant_support macros

2. Modify driver source in the Driver SDK package

2.1 Modify the Rtusb_urb_alloc_buffer and Rtusb_urb_free_buffer macros in rt_linux.h to define the following

#define Rtusb_urb_alloc_buffer (Pusb_dev,bufsize, pdma_addr) usb_alloc_coherent (pusb_dev,bufsize, GFP_ATOMIC, PDma_ Addr

#defineRTUSB_URB_FREE_BUFFER (Pusb_dev, BufSize, Ptransferbuf, dma_addr) usb_free_coherent (Pusb_dev, BUFSIZE,PTRANSF Erbuf, DMA_ADDR)

2.2 Modify RT_MAIN_DEV.C, directly mainvirtualif_close function empty, return 0, solve the problem can not be repeatedly turned off wifi.

2.3 Modify the Rtmposnetdevattach function in rt_linux.c to add devname assignment. strcpy (Pnetdev->name, "mlan0"); Note: (the name used here should be consistent with the node name used by the upper level, here is a description of the top of the main points in the use of the node name:

1,\frameworks\base\wifi\java\android\net\wifiwifistatetracker.java

2,init.rc start the Wpa_supplicant daemon inside and start the DHCPCD service

3,DHCPCD service configuration file, dhcpcd.conf inside

4,init.rc set SetProp wifi.interface "Mlan0")

3. Compiling method

Source Env.mk;make can be, drive is in the path of Os/linux under the Rt3070sta.ko. The driver name used here should be consistent with the driver name specified by the HAL layer WIFI.C


Four. Wap_supplicant Related configuration

Modification of 3.1 wpa_supplicant.conf configuration file

Used in Ctrl_interface=dir=/data/system/wpa_supplicantgroup=wifi #这个路径在wifi. C

3.2 The entire environment must be compiled for Wext type-related code.  That is, to open WEXT related macro config_driver_wext. That is, add in device/hisi/hi3716c/boardconfig.mk:
Board_have_wifi: = True
Board_wpa_supplicant_driver: = Wext

The purpose of this configuration is to make External/wpa_supplicant/android.mk set Wpa_build_supplicant to True.

3.3 Adding Wpa_supplicant daemon and dhcpcd process inside init.rc

3.4 in init.rc to add WiFi related file permission settings, set as follows:

chmod 0771/system/etc/wifi

chmod 0660/system/etc/wifi/wpa_supplicant.conf

Chown wifiwifi/system/etc/wifi/wpa_supplicant.conf #wifi的原始配置文件

#wpa_supplicantsocket

Mkdir/data/system/wpa_supplicant 0770 WiFi WiFi

chmod 0771/data/system/wpa_supplicant #放置wifiinterface的地方

Mkdir/data/misc/wifi 0770 WiFi WiFi

chmod 0771/data/misc/wifi

chmod 0660/data/misc/wifi/wpa_supplicant.conf #wifi的配置文件, the file will be written by wpa_supplicant according to the actual configuration

Chown Wifiwifi/data/misc/wifi

Chown wifiwifi/data/misc/wifi/wpa_supplicant.conf

Mkdir/data/misc/wifi/sockets 0770 WiFi WiFi #与上层通过socket通信的路径

cp/system/etc/wifi/wpa_supplicant.conf/data/misc/wifi/

MKDIR/DATA/MISC/DHCP 0777 DHCP DHCP

Chown DHCPDHCP/DATA/MISC/DHCP

# preparefor WiFi

Setpropwifi.interface "Mlan0"

SetProp Wlan.driver.status "OK"

3.5 Start wpa_supplicant daemon and DHCPCD service

Add wpa_supplicant start in init.rc:

Service wpa_supplicant/system/bin/logwrapper/system/bin/wpa_supplicant \

-dwext-imlan0-c/data/misc/wifi/wpa_supplicant.conf-dd

User root

Group System WiFi inet

Socket wpa_mlan0 Dgram 660 WiFi wifi

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.