android蓝牙移植,全志平台ap6476模组 bluetooth功能调试(1)驱动移植配置修改
1. 前言
蓝牙移植内核修改的较少,
android层由于使用broadcom提供bplus,framework和package改动较多,
android部份的移植只提及重要的修改。
2. 内核配置
修改.config文件以支持蓝牙的low power mode和唤醒休眠主控功能和支持android4.2 hid设备。
蓝牙low power mode和唤醒休眠主控的支持。
linux-3.3目录下,输入make ARCH=arm menuconfig
选择 -> Networking support (NET [=y])
-> Bluetooth subsystem support (BT [=y])
-> Bluetooth device drivers
-> Bluetooth Low Power Manager Support
An inverter between bt hostwake pin and cpu
ap6476模组是支持蓝牙唤醒休眠主控,需要在wakeup_src_para主键下把蓝牙的唤醒源添加上,唤醒源要跟wifi配置下的ap6xxx_bt_host_wake一致。
linux-3.3目录下,输入make ARCH=arm menuconfig
选择 -> Device Drivers --->
-> HID Devices --->
-> User-space I/O driver support for HID subsystem
3. sys_config修改
sys_config.fex是系统的配置文件,蓝牙功能是否有、蓝牙功能脚、接口定义等均是在sys_config.fex中设定。
;--------------------------------------------------------------------------------
;blue tooth
;bt_used ---- blue tooth used (0- no used, 1- used)
;bt_uard_id ---- uart index
;--------------------------------------------------------------------------------
[bt_para]
bt_used = 1
bt_uart_id = 2
bt_wakeup =
bt_gpio =
bt_rst =
bt_para是蓝牙配置的主键名,在sys_config.fex中是唯一的,会在脚本解释中被用到。
bt_used子键值为1代指平台使用蓝牙功能,值为0代指平台无蓝牙功能,bt_used会被rf电源管理驱动通过脚本解释读取其值,若值为0则不注册rfkill,直接返回空。
bt_uart_id子键值代指使用哪一路串口作为数据交互的通道,会在uart注册时被读取。
[uart_para2]
uart_used = 1
uart_port = 2
uart_type = 4
uart_tx = port:PG06<2><1>
uart_rx = port:PG07<2><1>
uart_rts = port:PG08<2><1>
uart_cts = port:PG09<2><1>
蓝牙使用第2路串口,需要把uart_used子键值设成1,代指第2路串口会被使用,若uart_used值设成0,在系统启动时会由于资源跑空导致系统挂掉
[wakeup_src_para]
cpu_en = 0
cpu_freq = 48
; (cpu:apb:ahb)
pll_ratio = 0x111
dram_selfresh_en = 1
dram_freq = 36
wakeup_bt = port:PL07<2><1>
ap6476模组是支持蓝牙唤醒休眠主控,需要在wakeup_src_para主键下把蓝牙的唤醒源添加上,唤醒源要跟wifi配置下的ap6xxx_bt_host_wake一致。
4. 驱动修改
(1)sw_uart.c
修改drivers/tty/serial/sw_uart.c文件中的sw_uart_probe函数,让btlmp.c获取蓝牙数据串口的句柄。
@@ -1185,7 +1185,9 @@ void sw_uart_procfs_remove(struct sw_uart_port *sw_uport)
remove_proc_entry(proc_root, NULL);
}
#endif
-
+#ifdef CONFIG_BT_LPM
+extern void bluesleep_setup_uart_port(struct platform_device *uart_dev);
+#endif
static int __devinit sw_uart_probe(struct platform_device *pdev)
{
u32 id = pdev->id;
@@ -1236,6 +1238,20 @@ static int __devinit sw_uart_probe(struct platform_device *pdev)
#ifdef CONFIG_PROC_FS
sw_uart_procfs_attach(sw_uport);
#endif
+
+#ifdef CONFIG_BT_LPM
+ script_item_value_type_e type;
+ script_item_u val;
+ type = script_get_item("bt_para", "bt_uart_id", &val);
+ if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
+ SERIAL_MSG("failed to fetch bt uart configuration.");
+ return -1;
+ }
+ if (val.val != 0 && val.val == sw_uport->id) {
+ bluesleep_setup_uart_port(pdev);
+ }
+#endif
+
SERIAL_DBG("add uart%d port, port_type %d, uartclk %d\n",
(2)rf电源管理修改
rf电源管理要添加ap6476的支持,包括两个方面,一是蓝牙电源管理的支持,二是把主控的32K时钟打开。
ap6476 蓝牙电源管理的支持需要在bt_pm.c中做修改,修改的地方如下。
@@ -51,6 +51,13 @@ static int rfkill_set_power(void *data, bool blocked)
wifi_pm_gpio_ctrl("ap6xxx_bt_regon", 0);
}
break;
+ case 10: /* ap6476 */
+ if (!blocked) {
+ wifi_pm_gpio_ctrl("ap6xxx_bt_regon", 1);
+ } else {
+ wifi_pm_gpio_ctrl("ap6xxx_bt_regon", 0);
+ }
+ break;
default:
RF_MSG("no bt module matched !!\n");
由电路原理图看,蓝牙的32K时钟是由主控的PM07提供,需要在系统启动时就把32K时钟打开,要注意的是32K时钟还会对应一个电压源的,也要把电压源打开。
32K时钟的开启在wifi_pm_ap6xxx.c中实现,修改如下。
@@ -15,6 +15,50 @@ static int ap6xxx_wl_regon = 0;
static int ap6xxx_bt_regon = 0;
static char * axp_name = NULL;
+static void ap6xxx_pm7_32k_clkout(void)
+{
+ struct regulator* ldo = NULL;
+ int ret = 0;
+ u32 clk_index = GPIOM(7);
+
+ ldo = regulator_get(NULL, "axp22_dldo4");
+ if (!ldo) {
+ ap6xxx_msg("request axp axp22_ldoio1 fail\n");
+ goto out2;
+ }
+ ret = regulator_set_voltage(ldo, 1800000, 1800000);
+ if (ret < 0) {
+ ap6xxx_msg("set voltage for axp gpio1/ldo fail\n");
+ goto out2;
+ }
+ ret = regulator_enable(ldo);
+ if (ret < 0) {
+ ap6xxx_msg("enable for axp gpio1/ldo fail\n");
+ goto out2;
+ }
+
+ ap6xxx_msg("enable bt 32khz clk, power form axp22_dldo4.\n");
+ if (0 != gpio_request(clk_index, NULL)) {
+ ap6xxx_msg("request clk gpio failed\n");
+ goto out2;
+ }
+
+ if (0 != sw_gpio_setcfg(clk_index, 3)) {
+ ap6xxx_msg("set clk gpio function to 3 failed\n");
+ goto out1;
+ }
+
+ *(volatile int*)0xf1f014f0 = 0x80000000;
+
+out1:
+ gpio_free(clk_index);
+out2:
+ if (!ldo) {
+ regulator_put(ldo);
+ }
+ return;
+}
+
@@ -156,4 +200,7 @@ void ap6xxx_gpio_init(void)
ops->power = ap6xxx_power;
ap6xxx_module_power(1);
+
+ //ap6xxx_msg("open 32k clk for bt\n");
+ ap6xxx_pm7_32k_clkout();
}
5. 安卓端配置修改
(1)BoardConfig.mk
BoardConfig.mk是android系统平台配置文件,需要在BoardConfig.mk中添加蓝牙功能的支持。
# 2. Bluetooth Configuration
BOARD_HAVE_BLUETOOTH := true
BOARD_HAVE_BLUETOOTH_BCM := true
BLUETOOTH_USE_BPLUS := true
BOARD_HAVE_BLUETOOTH值为ture代指平台带蓝牙功能,值为true framework蓝牙部份的代码才得到编译;
BOARD_HAVE_BLUETOOTH_BCM值为true代指使用broadcom蓝牙,/device/common/libbt下的代码才会得到编译;
BLUETOOTH_USE_BPLUS值为true代指使用bplus,/external/bluetooth/bluedroid代码不会编译,也就是用bplus替换了android4.2原生实现的profile。
(2)fiber_xxx.mk
fiber_xxx.mk文件添加蓝牙相关文件的拷贝。
PRODUCT_COPY_FILES += \
hardware/broadcom/wlan/firmware/ap6476/bcm2076b1.hcd:system/vendor/modules/bcm2076b1.hcd
PRODUCT_COPY_FILES += \
device/softwinner/fiber-a31st/ap6476/bplus.default.so:system/lib/hw/bplus.default.so \
device/softwinner/fiber-a31st/ap6476/iop_bt.db:system/etc/bluetooth/iop_bt.db \
external/bluetooth/bluedroid/conf/auto_pair_devlist.conf:system/etc/bluetooth/auto_pair_devlist.conf \
external/bluetooth/bluedroid/conf/bt_did.conf:system/etc/bluetooth/bt_did.conf \
external/bluetooth/bluedroid/conf/bt_stack.conf:system/etc/bluetooth/bt_stack.conf \
external/bluetooth/bluedroid/conf/bt_vendor.conf:system/etc/bluetooth/bt_vendor.conf
(3)init.sun6i.rc
init.sun6i.rc文件中添加对蓝牙接口、电源管理和相关目录的执行权限的修改。
# bluetooth
# UART device
chmod 0660 /dev/ttyS2
chown bluetooth net_bt_stack /dev/ttyS2
# power up/down interface
chmod 0660 /sys/class/rfkill/rfkill0/state
chmod 0660 /sys/class/rfkill/rfkill0/type
chown bluetooth net_bt_stack /sys/class/rfkill/rfkill0/state
chown bluetooth net_bt_stack /sys/class/rfkill/rfkill0/type
# bluetooth LPM
chmod 0220 /proc/bluetooth/sleep/lpm
chmod 0220 /proc/bluetooth/sleep/btwrite
chown bluetooth net_bt_stack /proc/bluetooth/sleep/lpm
chown bluetooth net_bt_stack /proc/bluetooth/sleep/btwrite
android蓝牙移植,全志平台ap6476模组 bluetooth功能调试(1)驱动移植配置修改相关推荐
- android系统检测到xx多次异常退出,全志平台ap6476模组 bluetooth功能调试(2)调试记录异常问题处理...
1. 前言 这篇主要是解决&分析具体的调试遇到的一些问题 2. 蓝牙打开失败-32k时钟 问题: 蓝牙无法打开. 问题分析: 1.android4.2上蓝牙的调试要看android层的打印信息 ...
- android+wifi驱动移植,全志平台ap6476 wifi模组调试(2)驱动移植 配置文件修改
1. 前言 基于上篇的环境,继续修改: 这里主要是修改驱动模块和配置文件 2. driver修改 当前broadcom系统的ap6xxx模组,wifi是共用同一份驱动,增加同系列的一款wifi的支持, ...
- 全志平台ap6476 蓝牙功能驱动调试记录
1. 前言 蓝牙移植内核修改的较少, android层由于使用broadcom提供bplus, framework和package改动较多, android部份的移植只提及重要的修改. 2. 内核配置 ...
- 【蓝牙Mesh笔记 ①】ESP32-C3 模组上实现天猫精灵蓝牙 BLE Mesh AliGenie 接入,无需WiFi 连接也可以实现天猫精灵语音控制。
本系列博客学习由非官方人员 半颗心脏 潜心所力所写,仅仅做个人技术交流分享,不做任何商业用途.如有不对之处,请留言,本人及时更改. 系列一:ESP32系列模组基础学习系列笔记 1. 爬坑学习新旅程,虚 ...
- 要闻君说:阿里云联合8家芯片模组商推出“全平台通信模组”;北汽与小桔车服联合“京桔”;IBM要帮助印度公司打造5G战略!...
关注并标星星CSDN云计算 每周三次,打卡即read 更快.更全了解泛云圈精彩news go go go 嗨,大家好!偶是要闻君.盼望着.盼望着,放假的日子又临近了一步,抢先祝福各位看官们新年快乐哈 ...
- 阿里云联合8家芯片商推“全平台通信模组”,加速物联网生态建设...
因为此次合作,其中部分合作伙伴已经收获了一个月新客户同比线下增长500%的惊人成果. 1月28日晚间消息,阿里云宣布联合业内8家芯片模组商推出"全平台通信模组",帮助用户通过该模组 ...
- 【Quectel移远展锐平台5G模组RX500U/RG200U使用指南(二)-USB/TTL的使用】
USB调试 展锐5G模组的USB接口有3个功能: USB转串口用于AT控制 USB转串口跟4G模块是一样的,都会虚拟出多个USB串口设备,Windows下是Quectel AT的串口设备,只需要安装原 ...
- 【Quectel移远展锐平台5G模组RX500U/RG200U使用指南(一)】
概述 移远的展锐平台5G模组是基于展锐udx710平台开发的5G模组,在华为被禁,MH5000-31无法继续使用后,这个成了国产5G模组的独苗了. 目前移远出了多款展锐的5G模组,RG500U-CN, ...
- CK6855M1蓝牙离线语音识别灯控模组使用说明书
CK6855M1蓝牙离线语音识别灯控模组使用说明书 一.功能说明 CK6855M1模块是一款专为灯具照明产品设计的离线蓝牙语音识别模组.模组支持红外遥控接收,支持RGB+W+Y灯控制, ...
最新文章
- 使用Git分布式版本控制系统
- 19.3.21 计算机网络基础知识
- 25个必须记住的SSH命令
- go语言基础到提高(7)-数组
- JAVA——文档注释(javavdoc)通用注释-超链接@see与@link的使用
- C++11空指针(nullptr)
- 我做的第二个正则转换工具
- linux恢复桌面,ubuntu恢复unity桌面
- 完全分布式安装Hadoop,Hive,Hbase,Hwi,Zookeeper
- awk使用多个分割符
- 操作系统实验报告 实验3存储管理实验(答案全)
- Rendezvous机制完成数据交互。Rendezvous是一个基于—_者一__者模型设计的抽象类。
- Win10如何设置快速锁屏?电脑怎么设置离开锁屏?
- 计算机断电无法启动不了系统,电脑突然断电,小编教你电脑突然断电后开不了机怎么办...
- 使用Au进行人声噪声混合
- 10 个 VSCode 超级摸鱼神器,确定不试一下?
- SSI技术的前端动态实现(AJAX+SSI,适用于任何系统,包括搭载嵌入式RTOS的STM32系列开发板)
- 2050的编程竞赛青年见面会感想
- 个人所得税退税问题(个人经验)
- 电子台账:模板制作之八——时间与产品名称所在行有交错的流水账格式
热门文章
- java模拟器游戏要钱吗_安卓java模拟器(安卓手机如何玩JAVA游戏以及JAVA软件的方法)...
- hog算子matlab实现程序,HOG Matlab实现
- python爬虫如何模仿登录_python爬虫:两种方法模拟登录博客园
- 新系统怎么连接无线网络连接服务器,2016新款TP路由器设置_新版TP-Link路由器设置教程-192路由网...
- 热烈庆祝《信息系统项目管理师教程》上线了!
- Spring零基础入门到精通 --- IOC基础容器
- JavaEE之捣蛋的Filter
- farpoint 小数保留4位_Farpoint表格编辑的功能用法总结
- 外设驱动库开发笔记53:MAX31856热偶变送器驱动
- 抽象方法(abstract);