Android bcm4330 Bluetooth BT driver debugging record

Source: Internet
Author: User

There are very few BT drivers on the Internet, so I recorded the steps during the development process. For mutual learning and discussion.

1. Migration of Bt DRIVER:

1. enableeffectch in boadconfig. mk

Board_have_bluetooth: = true

2. Implement rfkill driver for BT power management.

Kernel/driver/Bluetooth/bluetooth-power.c Qualcomm this file basically does not need to be moved.

In kernel \ arch \ Arm \ mach_msm7x27.c: static int rjth_power (INT on)

Implementation: power-on: Low bt_reset pin and bt_reg_on pin

Mdelay (10 );

Increase bt_resetpin and bt_reg_on pin

Mdelay (150)

Power-off: lower bt_reset pin and bt_reg_on pin

 

3. rebuildandroid image and reboot

Command Line test:

Echo 0>/sys/class/rfkill/rfkill0/State // BT power-off

Echo 1>/sys/class/rfkill/rfkill0/State // BT power-on

Brcm_patchram_plus-d -- patchram/etc/firmware/bcm4329b0000002.002.023.0061.0062.hcd/dev/ttyhs0

Hciattach-s115200/dev/ttyhs0 any

If no error message is displayed, use the following test:

Hciconfig hci0up

Hcitool Scan

 

4. Implement BT sleep wake-up Mechanism

Kernel \ drivers \ Bluetooth \ bluesleep. c In general, this file is slightly changed, but it may be logically problematic. Small changes are required.

In kernel \ arch \ Arm \ mach_xxx/board_xxx.c: bluesleep_resources, define gpio_host_wake (BT wake-up host foot), gpio_ext_wake (host wake-up BT foot), and host_wake (BT wake-up ).

Note: The board_xxx.c files of different platforms have different names. Please confirm

5. System Integration

1) Check the following content in init. qcom. RC:

Service hciattach/system/bin/sh/system/etc/init. qcom. bt. Sh

User Bluetooth

Group qcom_oncrpc Bluetooth net_bt_admin

Disabled

Oneshot

 

2) Modify init. qcom. bt. Sh.

Confirmation:

Export th_sleep_path =/proc/Bluetooth/sleep/proto

Echo 1> $ th_sleep_path

/System/bin/hciattach-N/dev/ttyhs0 any 3000000 flow & changed:

./Brcm_patchram_plus -- enable_lpm-enable_hci -- patchram/system/etc/WiFi/bcm4329bt. HCD -- baudrate3000000/dev/ttyhs0 &

Note: Qualcomm downloads the firmware command.

 

6. recompile the system. Now BT should be able to run.

Ii. BT sleep wake-up configuration

BT sleep in Driver/Bluetooth/bluesleep. in C, the first driver name is "bluesleep" and arch/ARM/Mach-MSM/board-msm7x30.c match to execute platform_driver_probe (& bluesleep_driver, bluesleep_probe) call static int _ init bluesleep_probe (struct platform_device * pdev). Two pins host_wake_bt & bt_wake_host will be configured here.

BSI = kzarloc (sizeof (struct bluesleep_info), gfp_kernel );
If (! BSI)
Return-enomem;

Res = platform_get_resource_byname (pdev, ioresource_io,
"Gpio_host_wake ");
If (! Res ){
Bt_err ("couldn't find host_wake gpio \ n ");
Ret =-enodev;
Goto free_bsi;
}
BSI-> host_wake = res-> start;
// [SIMT-zhangmin-111230] change the configuration of Bt sleep gpio from bt_power to here {
Gpio_tlmm_config (gpio_cfg (BSI-> host_wake, 0, gpio_cfg_input, gpio_cfg_no_pull, gpio_cfg_2ma), gpio_cfg_enable );
// [SIMT-zhangmin-111230]}
Ret = gpio_request (BSI-> host_wake, "bt_host_wake ");
If (RET)
Goto free_bsi;
Ret = gpio_direction_input (BSI-> host_wake );

BSI-> host_wake_irq = platform_get_irq_byname (pdev, "host_wake ");

As shown in the above Code, we mainly set host_wake_bt to the output foot, bt_wake_host to the input foot, and bt_wake_host to the center broken foot, waiting for the BT chip to wake up.

Then, create the BT directory/proc/Bluetooth/sleep/read the host_wake_bt status in btwake in the bluesleep_init function. The read status value is 0 or 1.

Or in the BT directory/proc/Bluetooth/sleep/write the host_wake_bt status in btwake. The write status value is 0 or 1.

Related Article

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.