您的位置:首页 > 移动开发 > Android开发

Porting Wifi driver on Android

2010-11-03 15:04 423 查看

[android-porting] Porting Wifi driver on
Android

Gaan

Tue, 23 Feb 2010 12:05:26
-0800

Hi everyone,

    I'm porting wifi driver (Ralink chip) on Android 2.0.1 board.

first of all I made some modifies

(1)   modify build/target/board/generic/BoardConfig.mk

add H***E_CUSTOM_WIFI_DRIVER_2 := true

(2)   Android using wpa_supplicant to management wifi. Make sure

external/wpa_supplicant/.config is looking like this

# CONFIG_NO_WPA=y

CONFIG_OS=unix

CONFIG_IEEE8021X_EAPOL=y

CONFIG_EAP_MD5=y

CONFIG_EAP_MSCHAPV2=y

CONFIG_EAP_TLS=y

CONFIG_EAP_PEAP=y

CONFIG_EAP_TTLS=y

CONFIG_EAP_GTC=y

CONFIG_EAP_OTP=y

CONFIG_EAP_SIM=y

CONFIG_EAP_AKA=y

CONFIG_EAP_PSK=y

CONFIG_EAP_SAKE=y

CONFIG_EAP_GPSK=y

CONFIG_EAP_PAX=y

CONFIG_EAP_LEAP=y

# CONFIG_EAP_FAST=y

CONFIG_PKCS12=y

# CONFIG_PCSC=y

CONFIG_SMARTCARD=y

CONFIG_WIRELESS_EXTENSION=y

CONFIG_CTRL_IFACE=y

# CONFIG_DRIVER_HOSTAP=y

# CONFIG_DRIVER_HERMES=y

# CONFIG_DRIVER_MADWIFI=y

# CONFIG_DRIVER_ATMEL=y

CONFIG_DRIVER_WEXT=y

# CONFIG_DRIVER_NDISWRAPPER=y

# CONFIG_DRIVER_BROADCOM=y

# CONFIG_DRIVER_IPW=y

# CONFIG_DRIVER_BSD=y

# CONFIG_DRIVER_NDIS=y

# CONFIG_DRIVER_TEST=y

# CONFIG_DRIVER_CUSTOM=y

# CONFIG_DEBUG_FILE=y

# CONFIG_INTERNAL_LIBTOMMATH=y

(3)   Enable wpa_supplicant compile option, modify external/

wpa_supplicant/Android.mk

(3.1)

LOCAL_PATH := $(call my-dir)

WPA_BUILD_SUPPLICANT := true

ifneq ($(TARGET_SIMULATOR),true)

  ifneq ($(BOARD_WPA_SUPPLICANT_DRIVER),)

    WPA_BUILD_SUPPLICANT := true

    CONFIG_DRIVER_$(BOARD_WPA_SUPPLICANT_DRIVER) = y

  endif

(3.2) remove mark symbol, and look like this

########################

local_target_dir := $(TARGET_OUT)/etc/wifi

include $(CLEAR_VARS)

LOCAL_MODULE := wpa_supplicant.conf

LOCAL_MODULE_TAGS := user

LOCAL_MODULE_CLASS := ETC

LOCAL_MODULE_PATH := $(local_target_dir)

LOCAL_SRC_FILES := $(LOCAL_MODULE)

include $(BUILD_PREBUILT)

#

########################

(4)   Modify wpa_supplicant setting file, and out/target/product/

generic/system/etc/wifi/ will be created after #make in step (3) out/

target/product/generic/system/etc/wifi/wpa_supplicant.conf

(4.1)

# The value can be set to, e.g., udp (ctrl_interface=udp)

#

# For Windows Named Pipe: This value can be used to set the security

descriptor

# for controlling access to the control interface. Security descriptor

can be

# set using Security Descriptor String Format (see http://msdn.microsoft.com/

# library/default.asp?url=/library/en-us/secauthz/security/

# security_descriptor_string_format.asp). The descriptor string needs

to be

# prefixed with SDDL=. For example, ctrl_interface=SDDL=D: would set

an empty

# DACL (which will reject all connections). See README-Windows.txt for

more

# information about SDDL string format.

#

#ctrl_interface=wlan0

ctrl_interface=DIR=/data/system/wpa_supplicant/ GROUP=system

(4.2) setting default AccessPoint value:

# Only WPA-PSK is used. Any valid cipher combination is accepted.

network={

       ssid="example"         // AP name

       proto=WPA            //encypted method

       key_mgmt=WPA-PSK   //using psk

       pairwise=CCMP TKIP

       group=CCMP TKIP WEP104 WEP40

 

psk=06b4be19da289f475aa46a33cb793029d4ab3db7a23ee92382eb0106c72ac7bb

       priority=2

}

(5)   Add directory which is needed when enable wifi under linux,

System/core/rootdir/init.rc

    # give system access to wpa_supplicant.conf for backup and restore

    mkdir /data/misc/wifi 0770 wifi wifi

    chmod 0770 /data/misc/wifi

    chmod 0660 /data/misc/wifi/wpa_supplicant.conf

    mkdir /data/misc/wifi/sockets 0770 wifi wifi

    mkdir /data/misc/android 0770 wifi wifi

    mkdir /data/system/wpa_supplicant 0770 wifi wifi

    mkdir /data/misc/dhcp 0770 dhcp dhcp

    chown dhcp dhcp /data/misc/dhcp

    chmod 0555 /system/bin/busybox

(6)   Modify HAL code, hardware/libhardware_legacy/wifi/wifi.c

Re-define the include path

#ifndef WIFI_DRIVER_MODULE_PATH

//#define WIFI_DRIVER_MODULE_PATH        "/system/lib/modules/wlan.ko"

#define WIFI_DRIVER_MODULE_PATH      "/lib/modules/rt3070sta.ko"

#endif

#ifndef WIFI_DRIVER_MODULE_NAME

//#define WIFI_DRIVER_MODULE_NAME         "wlan"

#define WIFI_DRIVER_MODULE_NAME         "ra0"

#endif

#ifndef WIFI_DRIVER_MODULE_ARG

#define WIFI_DRIVER_MODULE_ARG          ""

#endif

#ifndef WIFI_FIRMWARE_LOADER

#define WIFI_FIRMWARE_LOADER            ""

#endif

#define WIFI_TEST_INTERFACE             "sta"

(7)   Make and place driver relative file after boot.

place rt3070sta.ko at /lib/modules/

place RT2870STA.dat at  /etc/Wireless/RT2870STA/  (it is driver

needed)

place libiw.so.29 at /lib  (it is driver needed)

(8) select "Settings" -> "Wireless&networks" -> "Wi-Fi" in Android

I found the wifi module has been inserted. and I got the logcat.

====================

D/SettingsWifiEnabler( 1153): Received wifi state changed from

Disabled to Enabling

rtusb init --->

ra0 (usb): not using net_device_ops yet

usbcore: registered new interface driver rt2870

====================

but soon it fail and throws the log

====================

init: no such service 'wpa_supplicant'

====================
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: