How To Tune The SDIO Wifi PDF
How To Tune The SDIO Wifi PDF
How To Tune The SDIO Wifi PDF
Application Notes
Amlogic, Inc.
3930 Freedom Circle
Santa Clara, CA 95054
U.S.A.
www.amlogic.com
Legal Notices
© 2013 Amlogic, Inc. All rights reserved. Amlogic ® is registered trademarks of Amlogic, Inc. All other
registered trademarks, trademarks and service marks are property of their respective owners.
This document is Amlogic Company confidential and is not intended for any external distribution.
Table of Contents
Table of Contents................................................................................................................................................................... 2
1. Overview.............................................................................................................................................................................4
1.1 Purpose of this document........................................................................................................................................... 4
2. Software operation............................................................................................................................................................ 5
2.1 Kernel 配置.................................................................................................................................................................. 5
config 文件 配置.............................................................................................................................................................5
BSP 文件配置................................................................................................................................................................. 5
2.2 Rootfs 配置(android 4.1)............................................................................................................................................ 7
Init.rc 配置......................................................................................................................................................................7
BoadConfig.mk 配置...................................................................................................................................................... 9
xxxx.mk 配置..................................................................................................................................................................9
2.3 Rootfs 配置(android 4.2)..................................................................................................................................... 10
Init.rc 配置................................................................................................................................................................... 11
Xxxx.mk.........................................................................................................................................................................11
3. Sample.............................................................................................................................................................................. 12
3.1 Android 4.1 AP6181 移植......................................................................................................................................... 12
Revision history
1. Overview
1.1 Purpose of this document
This document tells users how to tune the SDIO wifi
2. Software operation
2.1 Kernel 配置
config 文件 配置
CONFIG_AM_WIFI=y
CONFIG_AM_WIFI_SD_MMC=y
CONFIG_SDIO_DHD_CDC_WIFI_40181_MODULE=m
CONFIG_SDIO_DHD_CDC_WIFI_AP6xxx_MODULE=m(4.1 上的 AP6xxx 使用该 config)
CONFIG_BCM40181_WIFI=y
CONFIG_SDIO_HARD_IRQ=n
CONFIG_BCM40181_HW_OOB=y
CONFIG_BCM40181_OOB_INTR_ONLY=y
CONFIG_BCM40181_POWER_ALWAYS_ON=y(这个 config,只有在硬件上支持系统休眠时,能对 wifi 持续供
电的情况下,才添加)
BSP 文件配置
SDIO 卡配置
.card_wp_input_mask = 0,
.card_extern_init = 0,
},
#if 1
[1] = {
.name = "sdio_card",
.work_mode = CARD_HW_MODE,
.io_pad_type = SDHC_GPIOX_0_9,
.card_ins_en_reg = 0,
.card_ins_en_mask = 0,
.card_ins_input_reg = 0,
.card_ins_input_mask = 0,
.card_power_en_reg = 0,
.card_power_en_mask = 0,
.card_power_output_reg = 0,
.card_power_output_mask = 0,
.card_power_en_lev = 0,
.card_wp_en_reg = 0,
.card_wp_en_mask = 0,
.card_wp_input_reg = 0,
.card_wp_input_mask = 0,
.card_extern_init = sdio_extern_init,
},
#endif
};
//set pull-up
aml_clr_reg32_mask(P_PAD_PULL_UP_REG4,0xf|1<<8|1<<9|1<<11|1<<12);
aml_clr_reg32_mask(P_PAD_PULL_UP_REG2,1<<7|1<<8|1<<9);
}
WIFI 上电函数
在 sdio_extern_init 函数中添加
gpio_set_status(PAD_GPIOX_11,gpio_status_in);
gpio_irq_set(PAD_GPIOX_11,GPIO_IRQ(4,GPIO_IRQ_HIGH));
Init .rc 配置
Init.rc
on boot
setprop wifi.interface wlan0
mkdir /data/misc/dhcp 0770 dhcp dhcp
chmod 0770 /data/misc/dhcp
hostap 服务添加
service hostapd /system/bin/hostapd_wps /data/misc/wifi/hostapd.conf
class main
disabled
oneshot
BoadConfig .mk 配置
BoadConfig.mk
#WIFI_DRIVER := bcm40181
#WIFI_DRIVER_MODULE_PATH := /system/lib/dhd.ko
#WIFI_DRIVER_MODULE_NAME := dhd
#WIFI_DRIVER_MODULE_ARG := "firmware_path=/etc/wifi/40181/fw_bcm40181a2.bin
nvram_path=/etc/wifi/40181/nvram.txt"
#WIFI_DRIVER_FW_PATH_STA :=/etc/wifi/40181/fw_bcm40181a2.bin
#WIFI_DRIVER_FW_PATH_AP :=/etc/wifi/40181/fw_bcm40181a2_apsta.bin
#WIFI_DRIVER_FW_PATH_P2P :=/etc/wifi/40181/fw_bcm40181a2_p2p.bin
BOARD_WLAN_DEVICE := bcmdhd
WIFI_DRIVER_FW_PATH_PARAM := "/sys/module/dhd/parameters/firmware_path"
WPA_SUPPLICANT 设置
WPA_SUPPLICANT_VERSION := VER_0_8_X
BOARD_WPA_SUPPLICANT_DRIVER := NL80211
BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_bcmdhd
BOARD_HOSTAPD_DRIVER := NL80211
BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_bcmdhd
xxxx.mk 配置
xxx.mk
40183/nvram.txt \
40183/fw_bcm40183b2.bin \
40183/fw_bcm40183b2_apsta.bin \
40183/fw_bcm40183b2_p2p.bin \
wl \
dhd \
wpa_supplicant.conf
PRODUCT_PACKAGES += \
40181/nvram.txt \
40181/fw_bcm40181a2.bin \
40181/fw_bcm40181a2_apsta.bin \
40181/fw_bcm40181a2_p2p.bin \
wl \
dhd \
wpa_supplicant.conf
PRODUCT_COPY_FILES += hardware/amlogic/wifi/AP6xxx/AP6181/Wi-
Fi/fw_bcm40181a2.bin:system/etc/wifi/40181/fw_bcm40181a2.bin
PRODUCT_COPY_FILES += hardware/amlogic/wifi/AP6xxx/AP6181/Wi-
Fi/fw_bcm40181a2_apsta.bin:system/etc/wifi/40181/fw_bcm40181a2_apsta.bin
PRODUCT_COPY_FILES += hardware/amlogic/wifi/AP6xxx/AP6181/Wi-
Fi/fw_bcm40181a2_p2p.bin:system/etc/wifi/40181/fw_bcm40181a2_p2p.bin
PRODUCT_COPY_FILES += hardware/amlogic/wifi/AP6xxx/AP6181/Wi-
Fi/nvram_ap6181.txt:system/etc/wifi/40181/nvram.txt
添加 wifi 的 xml 文件
PRODUCT_COPY_FILES += \
frameworks/native/data/etc/android.hardware.wifi.xml:system/etc/permissions/android.hardware.wifi.xml \
frameworks/native/data/etc/android.hardware.wifi.direct.xml:system/etc/permissions/android.hardware.wifi.dire
ct.xml \
(注:android.hardware.wifi.direct.xml 需要平台支持 wifi p2p 才添加)
拷贝驱动模块
PRODUCT_COPY_FILES += $(LOCAL_PATH)/dhd.ko:system/lib/dhd.ko
Init.rc 配置
Init.rc 配置与 android 4.1 一样,请参考 4.1 的配置
Xxxx.mk
3. Sample
3.1 Android 4.1 AP6181 移植
Config 文件修改
BSP 文件修改
#ifdef CONFIG_AM_WIFI
extern_wifi_set_enable(1);
#endif
}
#if 1
[1] = {
.name = "sdio_card",
.work_mode = CARD_HW_MODE,
.io_pad_type = SDHC_GPIOX_0_9,
.card_ins_en_reg = 0,
.card_ins_en_mask = 0,
.card_ins_input_reg = 0,
.card_ins_input_mask = 0,
.card_power_en_reg = 0,
.card_power_en_mask = 0,
.card_power_output_reg = 0,
.card_power_output_mask = 0,
.card_power_en_lev = 0,
.card_wp_en_reg = 0,
.card_wp_en_mask = 0,
.card_wp_input_reg = 0,
.card_wp_input_mask = 0,
.card_extern_init = sdio_extern_init,
},
#endif
};
时钟及上电 GPIO 设置
.....
void wifi_dev_init(void)
{
DBG_LINE_INFO();
wifi_clock_enable(1);
udelay(200);
wifi_gpio_init();
BoardConfig.mk 修改
WIFI_DRIVER := bcm40181
WIFI_DRIVER_MODULE_PATH := /system/lib/dhd.ko
WIFI_DRIVER_MODULE_NAME := dhd
WIFI_DRIVER_MODULE_ARG := "firmware_path=/etc/wifi/40181/fw_bcm40181a2.bin
nvram_path=/etc/wifi/40181/nvram.txt"
WIFI_DRIVER_FW_PATH_STA :=/etc/wifi/40181/fw_bcm40181a2.bin
WIFI_DRIVER_FW_PATH_AP :=/etc/wifi/40181/fw_bcm40181a2_apsta.bin
WIFI_DRIVER_FW_PATH_P2P :=/etc/wifi/40181/fw_bcm40181a2_p2p.bin
BOARD_WLAN_DEVICE := bcmdhd
WIFI_DRIVER_FW_PATH_PARAM := "/sys/module/dhd/parameters/firmware_path"
WPA_SUPPLICANT_VERSION := VER_0_8_X
BOARD_WPA_SUPPLICANT_DRIVER := NL80211
BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_bcmdhd
BOARD_HOSTAPD_DRIVER := NL80211
BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_bcmdhd
xxxx.mk 修改
# WiFi
PRODUCT_PACKAGES += \
40181/nvram.txt \
40181/fw_bcm40181a2.bin \
40181/fw_bcm40181a2_apsta.bin \
40181/fw_bcm40181a2_p2p.bin \
wl \
dhd \
wpa_supplicant.conf
PRODUCT_COPY_FILES += \
frameworks/native/data/etc/android.hardware.wifi.xml:system/etc/permissions/android.hardware.wifi.xml \
frameworks/native/data/etc/android.hardware.wifi.direct.xml:system/etc/permissions/android.hardware.wifi.dire
ct.xml \
PRODUCT_COPY_FILES += hardware/amlogic/wifi/AP6xxx/AP6181/Wi-
Fi/fw_bcm40181a2.bin:system/etc/wifi/40181/fw_bcm40181a2.bin
PRODUCT_COPY_FILES += hardware/amlogic/wifi/AP6xxx/AP6181/Wi-
Fi/fw_bcm40181a2_apsta.bin:system/etc/wifi/40181/fw_bcm40181a2_apsta.bin
PRODUCT_COPY_FILES += hardware/amlogic/wifi/AP6xxx/AP6181/Wi-
Fi/fw_bcm40181a2_p2p.bin:system/etc/wifi/40181/fw_bcm40181a2_p2p.bin
PRODUCT_COPY_FILES += hardware/amlogic/wifi/AP6xxx/AP6181/Wi-
Fi/nvram_ap6181.txt:system/etc/wifi/40181/nvram.txt
PRODUCT_COPY_FILES += $(LOCAL_PATH)/dhd.ko:system/lib/dhd.ko
Init.rc 修改
on post-fs-data
mkdir /data/misc/wifi 0770 wifi wifi
mkdir /data/misc/wifi/sockets 0770 wifi wifi
chmod 0770 /data/misc/wifi
chmod 0660 /data/misc/wifi/wpa_supplicant.conf
chown wifi wifi /data/misc/wifi
chown wifi wifi /data/misc/wifi/sockets
chown wifi wifi /data/misc/wifi/wpa_supplicant.conf
on boot
setprop wifi.interface wlan0
mkdir /data/misc/dhcp 0770 dhcp dhcp
chmod 0770 /data/misc/dhcp
Service 添加
service p2p_supplicant /system/bin/wpa_supplicant \
-iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
-N -ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf -e/data/misc/wifi/entropy.bin -
puse_p2p_group_interface=1
# user wifi
# group wifi inet keystore
class main
socket wpa_wlan0 dgram 0660 wifi wifi
disabled
oneshot