一、Android wl1271 wifi驱动移植

1,
在Texas官网
http://processors.wiki.ti.com/index.php/OMAP35x_Wireless_Connectivity_Downloads

下载并安装最新的V3.00.01.06-WL6.1.6.0-Linux-x86-Install.bin

这个软件包是在evm板上验证wl1271 wifi bluetooth功能.系统是linux 我们要移植到android系统。

2,
把android的kernel打上包里补丁PSP-linux-03.00.01.06-wl1271-support.patch

PSP-linux-03.00.01.06-wl1271-support.patch是针对omap3_evm_defconfig的,我们需要修改成omap3_evm_android_defconfig 。改好后进入kernel目录
patch -p1 < PSP-linux-03.00.01.06-wl1271-support.patch

移植到自己的板,根据硬件需要更改WLAN ENABLE GPIO和 WLAN IRQ GPIO

调试时首先要验证硬件正常。wifi模块正常工作WLAN ENABLE GPIO必须高, WLAN IRQ GPIO 应为低。
SDIO接口也需要注意,例如不能加电容。

.config 增加

CONFIG_WIRELESS=y
CONFIG_WIRELESS_EXT=y
CONFIG_WEXT_CORE=y
CONFIG_WEXT_PROC=y
CONFIG_WEXT_SPY=y
CONFIG_WEXT_PRIV=y
# CONFIG_CFG80211 is not set
CONFIG_WIRELESS_EXT_SYSFS=y
# CONFIG_LIB80211 is not set
CONFIG_WLAN=y
CONFIG_WL1271_WLAN=y
CONFIG_RFKILL=y
CONFIG_RFKILL_PM=y

board_omap3evm.c修改


define DM37_WIFI_PMENA_GPIO 23//150
define DM37_WIFI_IRQ_GPIO 21//149



static int __init dm37evm_wlan_init(void)
{
int ret;
omap_mux_init_gpio(DM37_WIFI_PMENA_GPIO, OMAP_PIN_OUTPUT);
omap_mux_init_gpio(DM37_WIFI_IRQ_GPIO, OMAP_PIN_INPUT);

printk("%s: start\n", __func__);
ret = gpio_request(DM37_WIFI_IRQ_GPIO, "wifi_irq");
if (ret < 0) {
printk("%s: can't reserve GPIO: %d\n", __func__,
DM37_WIFI_IRQ_GPIO);
return ret;
}
ret = gpio_request(DM37_WIFI_PMENA_GPIO, "wifi_pmena");
if (ret < 0) {
printk("%s: can't reserve GPIO: %d\n", __func__,
DM37_WIFI_PMENA_GPIO);
gpio_free(DM37_WIFI_IRQ_GPIO);
return ret;
}
gpio_direction_input(DM37_WIFI_IRQ_GPIO);
gpio_direction_output(DM37_WIFI_PMENA_GPIO, 1);

printk("%s:---------WLAN IRQ&PMEN INIT-----------\n",__func__);

return 0 ;

}

编译kernel

3,
在host_platform.h中修改成硬件对应的GPIO


define PMENA_GPIO 23//150 /* WLAN_ENABLE */
define IRQ_GPIO 21//149 /* WLAN_IRQ */


set_wl1271_build_env.sh 更改ARM_TOOLCHAIN_PATH和KERNEL_EXTRACTED_SOURCE_PATH,KERNEL_UNEXTRACTED_SOURCE 为自己的编译器和kenel路径

sh WL1271Build.sh build wlan

编译后得到
tiwlan_drv.ko ,firmware.bin ,tiwlan.ini ,wpa_supplicant.txt

4,
BoardConfig.mk增加

BOARD_HAVE_WIFI := true
USES_TI_WL1271 := true
BOARD_WPA_SUPPLICANT_DRIVER := WEXT
BOARD_WLAN_DEVICE := wl1271
WIFI_FIRMWARE_LOADER := "wlan_loader"
WIFI_DRIVER_MODULE_PATH := "/system/lib/modules/tiwlan_drv.ko"
WIFI_DRIVER_MODULE_NAME := "tiwlan_drv"

编译android

5,android 启动后

执行下面命令

insmod /system/lib/modules/tiwlan_drv.ko

wlan_loader -f /system/lib/modules/firmware.bin -i /system/lib/modules/tiwlan.ini

ifconfig tiwlan0 up

wpa_supplicant -Dwext -itiwlan0 -c /system/etc/wifi/wpa_supplicant.conf -dd &

6,运行Ti WLAN CLI 命令集测试wifi功能
执行 wlan_cu
/ a s t //scan
/ c b //see bssid_list
bssid_list显示搜到的热点。

[编辑] 二、Android wl1271 bluetooth驱动移植


1,
board_omap3evm.c增加 bluetooth rfkill电源管理设备,初始化BT_EN GPIO .如下:

static struct wl127x_rfkill_platform_data evm_wl1271_pdata = {
.bt_nshutdown_gpio = EVM_WL1271_NSHUTDOWN_GPIO,
.fm_enable_gpio = -1,
.bt_hw_init = evm_wl1271_init,
.bt_hw_release = evm_wl1271_release,
.bt_hw_enable = evm_wl1271_enable,
.bt_hw_disable = evm_wl1271_disable,
};

static struct platform_device evm_wl1271_device = {
.name = "wl127x-rfkill",
.id = 0,
.dev.platform_data = &evm_wl1271_pdata,
};

static void __init evm_bt_init(void)
{
platform_device_register(&evm_wl1271_device);
}


.config增加


CONFIG_BT=y
CONFIG_BT_L2CAP=y
CONFIG_BT_SCO=y
CONFIG_BT_RFCOMM=y
CONFIG_BT_RFCOMM_TTY=y
CONFIG_BT_BNEP=y
CONFIG_BT_BNEP_MC_FILTER=y
CONFIG_BT_BNEP_PROTO_FILTER=y
CONFIG_BT_HIDP=y

CONFIG_BT_HCIUART=y
CONFIG_BT_HCIUART_H4=y
CONFIG_BT_HCIUART_BCSP=y
CONFIG_BT_HCIUART_LL=y

CONFIG_BT_WL1271=y

编译kernel
3,
BoardConfig.mk增加
BOARD_HAVE_BLUETOOTH := true

编译android

4,
android 启动后

执行
echo "1" > /sys/class/rfkill/rfkill0/state //bluetooth enable

evm bluetooth是uart2,自己板是uart1 。把TIInit_7.2.31.bts 放在/system/lib/firmware/下(bts目录在hciattach_ti.c中指定)。uart用相应的波特率。

hciattach /dev/ttyS0 texasalt 115200 &

hciattach成功后就生成hci0节点。然后

hciconfig hci0 up
hciconfig hci0 pscan
hcitool scan
scan到设备后
hcitool cc 53:16:00:88:a1:24 连接设备

hcitool conn查看连接

调试过程可以用hcidump -XV&查看hci层log

Logo

更多推荐