[Quote] Debugging Android Bluetooth (Broadcom Bluetooth and Low-power mode)

Source: Internet
Author: User

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'll call this file Bt_enable () function, first call this function inside Set_bluetooth_power () then call Property_set ("CTL. Start "," Hciattach "), to start the This service Hciattach, and thereby this process run brcm_patchram_plus of. This service would load the firmware work. This section of the work was done, we'll call Property_set ("Ctl.start", "BLUETOOTHD"), this service was start our Bluz proce Ss. If the above is successful, the Bluetooth chip would 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 does not need to control. General on the rf-kill inside are, can operate on the command line.

The UART has been configured as UART (tx/rx/rts/cts), can also is configured only when using the Bluetooth UART.

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

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

III) detection to the CTS (the other RTS), does not give the other data

IV) BT after power (not done initialized), Bt_rts lower

V) host serial port is no 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 don't use LPM (low power mode), regardless of whether they verify the "BT function of Time" 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 was 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 and then the Bluetooth chip OK.

The B) Brcm_patchram_plus role

As we mentioned above, when start Hciattach service would start this brcm_patchram_plus this process. This process is BRCM_PATCHRAM_PLUS.C the this file compiled with.

Its role was 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.hc D/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 isn't sleep to BT

HOST each time before going to send data pulled Bt_wake

BT sleep'll is 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 is pulled low bt_wake), open the interruption to monitor the state of the Host_wake Bluesl eep_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 BL Uesleep 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 have been in print H4_recv:unknown HCI packet type

A:We to apply for Host_wake interrupt type was high. When you first open the "Bluetooth Host_wake = 1, this" interrupt is generated. Then turns to the interrupt type. When we transfer files to a good many times interrupt, which'll respond to multiple interrupt handler, this function wil L 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 would result in a period of time the serial port is not working. Therefore cause bt buf overflow. 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, does 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 Blu Etooth process is not responding.

A:such problems, ships has a problem, the flow of processing sleep code. Click to search for Bluetooth devices would 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 reactio N.

A:after analysis, such a situation:when of the other phone to our test machine transfer files to Interrup T response, first came to the response, however, and the system re-enter the suspend state.

Our Approach:just accept the file and you can try host Wakelock and do not let host sleep. This can is a good solution to the problem. But does not forget this 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 is 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 11mA, analysis the following reasons.

A:bluetooth Mobile phone connection on the headset or carkit, even if the state does not call and listen to music, Phys ical link or would remain, the Bluetooth RF still at work (this was stipulated in the agreement, otherwise it would call can Not answer with headset or carkit) headset or carkit query link time interval is different (the main link establishment ne Gotiation by the parties in the decision), so standby current performance of different products not the same, as shown in Figure 1 are the phone Kewei connection after OTA (Air Packet analyzer), OTA showed, the POLL and NULL interaction of S Ystem is very frequent (Kewei as the main initiate POLL), which are leading mobile phone standby current rise the main fact Ors. figure 2 is a and skyworth to establish the OTA link interaction frequency than Kewei to ten times lower, so the Performance on the standby current would be smaller.

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.