博通蓝牙驱动linux,基于Android8.1的博通bcm89342蓝牙驱动的驱动移植记录-Go语言中文社区...

本文档详细记录了在Android 8.1系统上移植博通bcm89342蓝牙驱动的过程,包括kernel配置、电源管理驱动编写、Android源码修改以及HAL层的移植。在移植过程中,关键步骤涉及蓝牙电源管理的rfkill驱动、关闭低功耗模式以及解决Ti Jacinto6平台特有的问题。完成移植后,蓝牙设备可以正常工作。
摘要由CSDN通过智能技术生成

说明

本文档是基于Android 8.1版本的一款博通蓝牙的驱动移植全过程记录。本驱动是通过/dev/ttyS2和蓝牙进行通信。因为较android以前的版本有很大变化尤其是上层关于蓝牙协议栈的部分,以前老版本用Bluez再到后来的BlueDroid,到现在的集到/system/bt下。蓝牙的固件烧录方式也有变化,以前broadcom蓝牙用systembluetoothbrcm_patchram_plus目录下编译出的可执行程序brcm_patchram_plus进行.hcd格式的蓝牙固件烧录,现在android 8.1版本是由hardware/broadcom/libbt/src/下的工程进行固件烧录和pskey(蓝牙寄存器初始化配置)设置。

一 、软硬件平台

系统软件:android-8.1、linux-4.4.117

硬件平台:Ti jacinto6

蓝牙芯片:cyw89342(bcm89342)

二、蓝牙移植流程

2.1 kernel 对蓝牙的驱动支持配置

对蓝牙的驱动支持配置((UART)H4 、BCSP、HCILL等)要全部确保勾选:

Bluetooth subsystem support —>

cf311711ce70877c5790cf5ddb9d931f.png

RF switch subsystem support —>

e24f1a593fcfa857bea4f683f6ff4efd.png

2.2 kernel层编写蓝牙电源管理(bt rfkill)驱动

将蓝牙电源管理添加到linux rfkill(无线设备电源开关)子系统。主要是通过bt_reg_on 这个gpio管脚控制蓝牙的上电、下电。添加rfkill驱动后,就可以在命令行执行echo操作进行蓝牙的开启和关闭。因为蓝牙设备默认是 /sys/class/rfkill/rfkill0所以通过:cat /sys/class/rfkill/rfkill0/name 确认是否是自己驱动创建的rfkill设备,我这里是bcm89342_bt_rfkill。(详细驱动代码见下载文件)确认后可执行开关操作:

蓝牙上电: echo 1 > /sys/class/rfkill/rfkill0/state

蓝牙下电 : echo 0 > /sys/class/rfkill/rfkill0/state

rfkill驱动bcm89342_bt_rfkill.c部分源代码如下:

#include

#include

#include

#include

#include

#include

#define BT_REG_ON 169

static int rfkill_set_power(void *data, bool blocked);

static struct platform_device *rfkill_pdev;

static struct rfkill *rfkill; /* for driver only */

static struct rfkill_ops rfkill_ops = {

.set_block = rfkill_set_power,

};

static int bt_gpio_init(void)

{

int ret;

ret = gpio_request_one(BT_REG_ON, GPIOF_OUT_INIT_LOW, "BT_REG_ON");

if (ret == 0) {

printk("Yangql obtain gpio for BT_REG_ON n");

gpio_export(BT_REG_ON, 0);

} else {

pr_err("could not obtain gpio for BT_REG_ONn");

}

#if 0

ret = gpio_request_one(BT_HOST_WAKE, GPIOF_IN, "BT_HOST_WAKE");

<
########################BT FM ########################## Download the image using command: 1 # Flash Image Put the board in Flashing mode. Refer below Appendix - 1 cd <your path>/Nvidia_Demo/android_gb_cardhu_os_image sudo ./nvflash --bct flash.bct --setbct --odmdata 0x40080105 --configfile flash.cfg --create --bl bootloader.bin --go #################################################################################################################################################################################################### Appendix - 1 Nvidia Board in Flashing Mode #################################################################################################################################################################################################### 1. Connect the Debug board to Cardhu board. 2. Connect the power supply and Micro USB to Cardhu 3. On the Debug Board Press S12 (FRC RCV), Keeping this pressed Press and release S7 (RESET), Now Release S12. 4. Now Device is in Flashing mode, We can start nvflash command now. #################################################################################################################################################################################################### Appendix - 2 Nvidia Board Keys (On Debug Board) #################################################################################################################################################################################################### 1. S7 (RESET) --> is the RESET button. 2. S5 (ROW1) --> is the BACK button. 2. S10 (ROW2) --> is the Home button. 4. S6 (ON KEY) --> is Wake up button. #################################################################################################################################################################################################### Appendix - 3 Nvidia Board unavailable Keys workaround #################################################################################################################################################################################################### 1.To execute teh specific keys, provide the key inputs from adb shell. Provide the keyevent for the desired key.Refer teh key list below. Eg: for MENU key run adb shell #input keyevent 82 { "STAR", 17 }, { "POUND", 18 }, { "DPAD_UP", 19 }, { "DPAD_DOWN", 20 }, { "DPAD_LEFT", 21 }, { "DPAD_RIGHT", 22 }, { "DPAD_CENTER", 23 }, { "VOLUME_UP", 24 }, { "VOLUME_DOWN", 25 }, { "POWER", 26 }, { "CAMERA", 27 }, { "CLEAR", 28 }, { "HEADSETHOOK", 79 }, { "FOCUS", 80 }, { "PLUS", 81 }, { "MENU", 82 }, { "NOTIFICATION", 83 }, { "SEARCH", 84 }, { "MEDIA_PLAY_PAUSE", 85 }, { "MEDIA_STOP", 86 }, { "MEDIA_NEXT", 87 },
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值