[quote] debugging android Bluetooth (Broadcom Bluetooth and low-power mode)

URL:  http://www.phonesdevelopers.com/1695137/

First the combination of grasping this part of the project from a whole:

The Bluetooth module core file is bluetooth.c on electricity, I will call this file bt_enable () function, first call this function inside set_bluetooth_power () then call property_set ("CTL. start "," hciattach "), to start this service hciattach, and thereby this process run brcm_patchram_plus of. This service will load the firmware work. This part of the work is done, we will call property_set ("ctl.start", "bluetoothd"), this service is start our bluz process. If the above is successful, the Bluetooth chip will start working.

Bluetooth need to work properly, in short, need to do a three-part work:

i) the power to the chip.

ii) hciattach the service starts, thus loading the firmware, set the baud rate and so a series of operations. (Hard)

iii to start bluetooth Agreement Bluetooth to work properly.                   (Soft)

Second, to analyze for specific workflow:

a) Introduction to BT pin

The BT_REG_ON and BT_RESET pulled open the Bluetooth, turn off Bluetooth when low. Usually do not need to control.General on the RF-KILL inside is, can operate on the command line.

UART has been configured as UART (TX / RX / RTS / CTS), can also be configured only when using Bluetooth UART.

I) correspond to each other: TX and RX, RTS and CTS, RTS and CTS are used for hardware flow control

II) pulled the RTS (the other CTS), the other side can not send data

Iii) detection to the CTS (the other RTS), do not give the other data

Iv) BT after power (not done initialized), BT_RTS lower

V) host serial port is not open low

The sleep control foot: HOST_WAKE and BT_WAKE

i) for the AP, a GPO, an interrupt is.

. ii) BT before use, configure, control bluesleep.c.

iii) If you do not use LPM (low power mode), regardless of whether they verify the the bt function of time back in the new board, often do not require a low-power mode.

a) hardware verification

First of all, should do the following things:

i) configure the UART pin

ii) configured BT_REG_ON / BT_RESET pin and changing for the better RFKILL code

the iii) BT_WAKE HOAT_WAKE can unworthy

Followed by the verification process

Under power: by RFKILL low BT_REG_ON and BT_RESET BT default state

Power-on: the same by RFKILL pulled BT_REG_ON and BT_REST the chip is in power-on state

Through the initialization brcm_patchram_plus BT chip

Hciconfig uart0 up

The hcitool scan search equipment, if we can search to the device, then the Bluetooth chip ok.

the b) Brcm_patchram_plus role

As we mentioned above, when start hciattach service will start this brcm_patchram_plus this process. This process is brcm_patchram_plus.c this file compiled with.

Its role is to initialize the Bluetooth chip, the basic parameters configuration: lpm, PCM parameters

The parameters explained (brcm_patchram_plus) listed

-D: display debugging information

The-enable_hci: start HCI protocol

Enable_lpm: start lpm mode

-Baudrate: baud rate specified work

The-patchram: specify HCD file

- BD_ADDR: load the Bluetooth address

- / Dev / ttyxxx: Specifies the serial port

brcm_patchram_plus-d-bd_addrxx: xx: xx: xx: xx: xx - enable_hci - enable_lpm - baudrate3000000 - patchram / etc/bcm4330.hcd / dev/ttyHS0

Hardware verification can be simplified:

brcm_patchram_plus-d - enable_hci / dev/ttyHS0

c) LowPower Mode

the lpm specific parameters set in the brcm_patchram_plu.c code

unsignedchar hci_write_sleep_mode [] = {0x01, 0x27, 0xfc,

0x0c, / ??/ ??command length

0x01, / / ??Sleep_Mode UART

0x01, / / ??Host Idle Threshold, roughly 1 * 300ms

0x01, / / ??Host Controller Idle Threshold

0x01, / / ??BT_WAKE_Active_Mode, 0-active low, 1-active hgih

0x01, / / ??HOST_WAKE_Active_Mode, 0 - active low, 1-active hgih

0x01, / / ??Allow_Host_Sleep_During_SCO

0x01, / / ??Combine_Sleep_Mode_And_LPM

0x00, / / ??Enable_Tristate_Control_Of_UART_Tx_Line

0x00, / / ??Active_Connection_Handling_On_Suspend

0x00, / / ??Resume_Timeout

0x00, / / ??Enable_BREAK_To_Host

0x00 / / Pulsed_HOST_WAKE

};

The BT chip the lpm need HOST bluesleep work simultaneously

We tested the Bluetooth sleep manually to / proc / BCM / Asleep / proto write, you can start the sleep mode.

i) the normal code:

The BlueZ: start BT (bluez bt_enable in bluetooth.c the inside)

Changes init.qcom.rc file to open / close the BT chip lpm

servicehciattach / system / bin / brcm_patchram_plus - enable_hci - enable_lpm - baudrate 3000000 --patchram/etc/firmware/bcm4329.hcd / dev/ttyHS0

ii) AP by BT_WAKE to control BT

The pulled BT_WAKE: BT can not sleep, or to wake up

Pulled low BT_WAKE: BT can sleep, sleep is not sleep to BT

HOST each time before going to send data pulled BT_WAKE

BT sleep will be pulled BT_RTS to prevent HOST data.

iii) Bluesleep.c Overview

bluesleep_init: create a node, bluesleep_probe: application GPIO / INT / WAKE_LOCK, resources, start the timer monitoring host to send data (time-out can be pulled low BT_WAKE), open the interruption to monitor the state of the HOST_WAKE bluesleep_outgoing_data: pulled BT_WAKE wake BT, bluesleep_hostwake_isr: interrupt handler, wake task scheduling.

For new projects, we first ensure INT and of HOST_WAKE and BT_WAKE and GPIO can correct application Secondly ensure the bluesleep is compiled, the following three node is created

/ Proc / bcm / asleep / proto, / proc / bcm / asleep / hostwake, / proc / bcm / asleep / btwake

Third, the project Bluetooth some bug Analysis.

i) in the process of transferring multiple files, transfer several files, transfer progress bar stops moving. And the kernel has been in print h4_recv: Unknown HCI packet type

A:   We to apply for Host_wake interrupt type is high. When you first open the Bluetooth Host_wake = 1, this time an interrupt is generated. Then turns to change the interrupt type. When we transfer files to a good many times interrupt, which will respond to multiple interrupt handler, this function will repeatedly open and close the work of the serial. This is where the problem lies.Bt to HOST pass data when repeatedly open and close the serial port, which will result in a period of time the serial port is not working. Therefore cause bt buf overflow. This is the cause of the problem of data frame detection bit: rfcomm_recv_frame: bad checksum in packet.

Our approach is: in the process of transferring files, do not let the HOST to close the serial port. Until the end of our file transfer, and then the kernel timer to close the serial port.

ii) in the transmission process, click on the search for Bluetooth devices in the UI above, nothing happens, or pop-up Bluetooth process is not responding.

A: such problems, ships have a problem, the flow of processing sleep code. Click to search for Bluetooth devices will interface, HOST did not wake up the Bluetooth device.

iii) In the case of standby, the other phone to transfer files to the testing machine, testing machine without any reaction.

A: After analysis, only to find that such a situation: when the other phone to our test machine transfer files to interrupt response, first came to the response, however, the system re-enter the suspend state.

Our approach: just accept the file, you can try HOST wakelock, do not let HOST sleep. This can be a good solution to the problem. But do not forget that in the final plus unwakelock oh.

iv) Bluetooth in certain specific circumstances open. The probability is very low. After restart the phone, the Bluetooth turns on properly.

A: are generally due to the Bluetooth firmware loaded in the patchram_plus not successful, resulting in the. May be caused by the process of blocking. When loading the firmware, try again to load the firmware.

v) some models, KEWEI Car Bluetooth to the phone standby current to 11mA, analysis The following reasons.

A: Bluetooth mobile phone connection on the headset or carkit, even if the state did not call and listen to music, physical link or will remain, the Bluetooth RF still at work (this is stipulated in the agreement, otherwise it will call can not answer with headset or carkit) headset or carkit query link time interval is different (the main link establishment negotiation by the parties in the decision), so standby current performance of different products not the same, as shown in Figure 1 is the phone kewei connection after OTA (air packet analyzer), OTA showed that the POLL and NULL interaction of system is very frequent (KEWEI as the main initiate POLL), which is leading mobile phone standby current rise the main factors. Figure 2 is a and skyworth to establish the OTA link interaction frequency than kewei to 10 times lower, so the performance on the standby current will be smaller.

时间: 2024-10-10 01:39:32

[quote] debugging android Bluetooth (Broadcom Bluetooth and low-power mode)的相关文章

Android 4.2 Bluetooth 分析总结(二) 蓝牙enable 的整个过程

转载请标明出处:Android 4.2 Bluetooth 分析总结(二) 蓝牙enable 的整个过程 现在开始我们分析 Android4.2 Bluetooth 打开的整个过程,由于是新手,难免有很多错误,记录只是为了以后方便查找,如发错误敬请指出. 我们整个分析过程有可能有点繁琐,但请仔细阅读,读完之后必然发现还是会有一点点收获的,虽然写的不好.搜先我们上一份enable 打开蓝牙整个过程的打印:然后我们跟踪打印来窥探 Android4.2Bluetooth 工作的流程. D/Blueto

Remote Debugging Android Devices

Remote Debugging Android Devices //在电脑上远程调试安卓设备 By Kayce Basques Technical Writer at Google By Meggin Kearney Meggin is a Tech Writer Remote debug live content on an Android device from your Windows, Mac, or Linux computer.//远程实时调试安卓设备的内容. TL;DR Set

PatentTips - Fast awake from low power mode

BACKGROUND Electronic devices, such as electronic book readers ("eBook reader devices"), cellular telephones, portable media players, desktop computers, laptops, tablet computers, netbooks, personal digital assistants, and the like, rely on elec

Network management system scheduling for low power and lossy networks

In one embodiment, a network management system (NMS) determines an intent to initialize a request-response exchange with a plurality of clients in a low power and lossy network (LLN). In response, the NMS adaptively schedules corresponding responses

tensorfolw配置过程中遇到的一些问题及其解决过程的记录(配置SqueezeDet: Unified, Small, Low Power Fully Convolutional Neural Networks for Real-Time Object Detection for Autonomous Driving)

今天看到一篇关于检测的论文<SqueezeDet: Unified, Small, Low Power Fully Convolutional Neural Networks for Real-Time Object Detection for Autonomous Driving>,论文中的效果还不错,后来查了一下,有一个Tensorflow版本的实现,因此在自己的机器上配置了Tensorflow的环境,然后将其给出的demo跑通了,其中遇到了一些小问题,通过查找网络上的资料解决掉了,在这里

bzoj 3969 LOW Power

3969: [WF2013]Low Power Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline/problem.php?id=3969 Description 有n个机器,每个机器有2个芯片,每个芯片可以放k个电池. 每个芯片能量是k个电池的能量的最小值. 两个芯片的能量之差越小,这个机器就工作的越好. 现在有2nk个电池,已知它们的能量,我们要把它们放在n个机器上的芯片上, 使得所有机

bzoj 3969: [WF2013]Low Power 二分

3969: [WF2013]Low Power Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline/problem.php?id=3969 Description 有n个机器,每个机器有2个芯片,每个芯片可以放k个电池. 每个芯片能量是k个电池的能量的最小值. 两个芯片的能量之差越小,这个机器就工作的越好. 现在有2nk个电池,已知它们的能量,我们要把它们放在n个机器上的芯片上, 使得所有机

[CortexM0--stm32f0308]Low Power Mode

问题描述 stm32f0308正常是运行在Run mode下,这种mode是在reset之后的默认模式.Low Power Mode,即低功耗模式,用于在IC空闲时可以考虑选择进入,使系统耗能降低,在必要的时候通过唤醒在进入Run mode正常工作.Low Power Mode,在嵌入式系统中考虑的很多,也很关键,因为一般都是用移动电源供电,合理使用Low Power Mode,会很好的提高设备的续航能力. Low Power Mode方式 Sleep Mode:CPU时钟关闭,所有periph

Low Power之CPF/UPF

1 CPF The Common Power Format is a standard promoted by the Low Power Coalition at Si2. CPF is also a TCL-based language that operates on speci?cation objects and the design objects. A design object is a module, instance, net, pin or port as they app