Android Wifi Driver Porting

刘安志
2023-12-01

 

1. 修改 build/target/board/generic/BoardConfig.mk
定义使用 wireless extension 作为wpa_supplicant 的driver.
# Wifi related defines
BOARD_WPA_SUPPLICANT_DRIVER := WEXT

 

2.  修改hardware/libhardware_legacy/wifi/wifi.c

wifi.c 是 wifi 的hardware 抽像层,必须修改 wifi_load() . wifi_unload()

两个函数来装载特定 wifi chip 的FW , 以及insmod wifi driver.

 

3. 配置 wpa_supplicant

3.1 修改out/target/product/generic/root/init.rc

 

# For wifi
    mkdir /data/misc/wifi 0770 wifi wifi
    mkdir /data/misc/wifi/sockets 0770 wifi wifi
    mkdir /data/system/wpa_supplicant 0770 wifi wifi

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

 

service wpa_supplicant /system/bin/logwrapper /system/bin/wpa_supplicant /
        -Dwext -iwlan0 -c /data/misc/wifi/wpa_supplicant.conf
    disabled
    oneshot

 

这里wpa_supplicant 使用wireless extension 作为 driver, wlan0 为intercace, /data/misc/wifi/wpa_supplicant.conf
 作为配置文件

 

3.2  wpa_supplicant.conf

wpa_supplicant 的配置文件内容如下

 

-----------------------------------------------------------------------------------

# This option can be used to allow wpa_supplicant to overwrite configuration
# file whenever configuration is changed (e.g., new network block is added with
# wpa_cli or wpa_gui, or a password is changed). This is required for
# wpa_cli/wpa_gui to be able to store the configuration changes permanently.
# Please note that overwriting configuration file will remove the comments from
# it.
update_config=1

# Parameters for the control interface. If this is specified, wpa_supplicant
# will open a control interface that is available for external programs to
# manage wpa_supplicant. The meaning of this string depends on which control
# interface mechanism is used. For all cases, the existance of this parameter
# in configuration is used to determine whether the control interface is
# enabled.
# When configuring both the directory and group, use following format:
# DIR=/var/run/wpa_supplicant GROUP=wheel
# DIR=/var/run/wpa_supplicant GROUP=0
# (group can be either group name or gid)

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

-----------------------------------------------------------------------------------

第一个参数表明,ap 配置会被最近一次的修改覆盖, 第二个参数指定wpa_supplicant 可被其他系统服务访问的管道以及访问的Group权限是AID_WIFI用户(GROUP=1010)

 

 

4. 配置 dhcpc

4.1 修改out/target/product/generic/root/init.rc

 

mkdir /data/misc/dhcp 0770 dhcp dhcp
chown dhcp dhcp /data/misc/dhcp

service dhcpcd /system/bin/logwrapper /system/bin/dhcpcd -BK -f /system/etc/dhcpcd/dhcpcd-wlan0.conf wlan0
    disabled
    oneshot

 

4.2 dhcpcd 配置文件 dhcpcd-wlan0.conf

 

-------------------------------------------------------------------------------

# dhcpcd configuration for Android Wi-Fi interface
# See dhcpcd.conf(5) for details.
interface wlan0

# dhcpcd-run-hooks uses these options.
option subnet_mask, routers, domain_name_servers

--------------------------------------------------------------------------------

 

 

 

 

 类似资料:

相关阅读

相关文章

相关问答