Bluetoothd doesn't come up on SGS2 #124

Closed
qdot opened this Issue Jan 10, 2012 · 6 comments

Projects

None yet

3 participants

Collaborator
qdot commented Jan 10, 2012

We can now load firmware to the bluetooth chip on the SGS2, but bringing up the bluetoothd daemon errors out. This means that we don't have full access to the hci0 file, so we can't do things like get adapter information, scan for other bluetooth devices, etc... Many forums report the timeout issues are usually lack of support for the chip in either the kernel or bluez, but having diffed our kernel config and some code against cyanogenmod, I didn't see many changes.

"bttest enable" on B2G (with bluetoothd debugging on):

I/bluedroid( 2743): Starting bluetoothd deamon
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: Bluetooth deamon 4.69
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/main.c:parse_config() parsing main.conf
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/main.c:parse_config() discovto=120
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/main.c:parse_config() pairto=0
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/main.c:parse_config() pageto=8192
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/main.c:parse_config() name=%m
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/main.c:parse_config() class=0x40020C
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/main.c:parse_config() discov_interval=0
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/main.c:parse_config() deviceid=android:generic:1.5
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/main.c:parse_config() default_link_policy=7
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: Starting SDP server
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: Got Unix socket fd '14' from environment
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: Adding device id record for 000a:0000
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/plugin.c:plugin_init() Loading builtin plugins
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/plugin.c:add_plugin() Loading hciops plugin
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/plugin.c:plugin_init() Loading plugins /system/lib/bluez-plugin
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/plugin.c:add_plugin() Loading audio plugin
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/plugin.c:add_plugin() Loading input plugin
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: HCI dev 0 registered
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/plugins/hciops.c:init_device() child 2754 forked
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/adapter.c:btd_adapter_ref() 0x10d50: ref=1
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: HCI dev 0 up
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: Starting security manager 0
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/adapter.c:btd_adapter_set_class() Changing Major/Minor class to 0x00020c
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/adapter.c:adapter_start() Stopping Inquiry at adapter startup
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/adapter.c:btd_adapter_ref() 0x10d50: ref=2
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/adapter.c:btd_adapter_ref() 0x10d50: ref=3
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/sdpd-service.c:add_record_to_server() Adding record with handle 0x10001
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000019-0000-1000-8000-00805f9
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000100-0000-1000-8000-00805f9
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/sdpd-service.c:add_record_to_server() Record pattern UUID 00001002-0000-1000-8000-00805f9
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/sdpd-service.c:add_record_to_server() Record pattern UUID 0000110a-0000-1000-8000-00805f9
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/sdpd-service.c:add_record_to_server() Record pattern UUID 0000110d-0000-1000-8000-00805f9
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/sdpd-service.c:add_record_to_server() Adding record with handle 0x10002
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000017-0000-1000-8000-00805f9
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000100-0000-1000-8000-00805f9
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/sdpd-service.c:add_record_to_server() Record pattern UUID 00001002-0000-1000-8000-00805f9
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/sdpd-service.c:add_record_to_server() Record pattern UUID 0000110c-0000-1000-8000-00805f9
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/sdpd-service.c:add_record_to_server() Record pattern UUID 0000110e-0000-1000-8000-00805f9
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: ioctl(HCIUNBLOCKADDR): Invalid argument (22)
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: Adapter /org/bluez/2753/hci0 has been enabled
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: Failed to open RFKILL control device
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/main.c:main() Entering main loop
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/plugins/hciops.c:child_exit() child 2754 exited
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: external/bluetooth/bluez/src/adapter.c:adapter_update_tx_power() inquiry respone tx power level is 0
I//system/bin/bluetoothd( 2752): bluetoothd[2753]: Inquiry Failed with status 0x12

Running hciconfig -a on cyanogenmod:

hciconfig -a
hci0:   Type: BR/EDR  Bus: UART
    BD Address: F0:08:F1:B5:F3:91  ACL MTU: 1021:8  SCO MTU: 64:1
    UP RUNNING PSCAN 
    RX bytes:1056 acl:0 sco:0 events:36 errors:0
    TX bytes:1632 acl:0 sco:0 commands:36 errors:0
    Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
    Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
    Link policy: RSWITCH HOLD SNIFF 
    Link mode: SLAVE ACCEPT 
    Name: 'GT-I9100'
    Class: 0x08020c
    Service Classes: Capturing
    Device Class: Phone, Smart phone
    HCI Version: 4.0 (0x6)  Revision: 0x1109
    LMP Version: 4.0 (0x6)  Subversion: 0x4103
    Manufacturer: Broadcom Corporation (15)

Running hciconfig -a on B2G:

# hciconfig -a
hciconfig -a
hci0:   Type: BR/EDR  Bus: UART
    BD Address: 43:30:A0:00:00:00  ACL MTU: 1021:8  SCO MTU: 64:1
    UP RUNNING PSCAN 
    RX bytes:1056 acl:0 sco:0 events:36 errors:0
    TX bytes:1641 acl:0 sco:0 commands:37 errors:0
    Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
    Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
    Link policy: RSWITCH HOLD SNIFF 
    Link mode: SLAVE ACCEPT 
Can't read local name on hci0: Connection timed out (110)

"hciconfig hci0 down" works on both

"hciconfig hci0 up" works on cyanogenmod, hangs on B2G

B2G dmesg

dmesg | grep Blue
<6>[    0.207254] Bluetooth: Core ver 2.15
<6>[    0.207432] Bluetooth: HCI device and connection manager initialized
<6>[    0.207450] Bluetooth: HCI socket layer initialized
<6>[    1.124824] Bluetooth: HCI UART driver ver 2.2
<6>[    1.124839] Bluetooth: HCI H4 protocol initialized
<6>[    1.287565] Bluetooth: L2CAP ver 2.14
<6>[    1.287577] Bluetooth: L2CAP socket layer initialized
<6>[    1.287602] Bluetooth: SCO (Voice Link) ver 0.6
<6>[    1.287613] Bluetooth: SCO socket layer initialized
<6>[    1.287723] Bluetooth: RFCOMM TTY layer initialized
<6>[    1.287744] Bluetooth: RFCOMM socket layer initialized
<6>[    1.287757] Bluetooth: RFCOMM ver 1.11
<6>[    1.287768] Bluetooth: HIDP (Human Interface Emulation) ver 1.2

Cyanogenmod dmesg

dmesg | grep Blue
<6>[    0.371354] Bluetooth: Core ver 2.15
<6>[    0.371819] Bluetooth: HCI device and connection manager initialized
<6>[    0.372021] Bluetooth: HCI socket layer initialized
<6>[    1.219795] Bluetooth: HCI UART driver ver 2.2
<6>[    1.219996] Bluetooth: HCI H4 protocol initialized
<6>[    1.386999] Bluetooth: L2CAP ver 2.14
<6>[    1.387108] Bluetooth: L2CAP socket layer initialized
<6>[    1.387319] Bluetooth: SCO (Voice Link) ver 0.6
<6>[    1.387430] Bluetooth: SCO socket layer initialized
<6>[    1.387639] Bluetooth: RFCOMM TTY layer initialized
<6>[    1.387851] Bluetooth: RFCOMM socket layer initialized
<6>[    1.387961] Bluetooth: RFCOMM ver 1.11
<6>[    1.388158] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
<6>[    1.388267] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
Collaborator
qdot commented Jan 10, 2012

Other things I've researched so far in the above logs:

I//system/bin/bluetoothd( 2752): bluetoothd[2753]: ioctl(HCIUNBLOCKADDR): Invalid argument (22)

This apparently happens in multiple versions of bluez. Not sure if it's a blocking issue or not? Could be though, since it might mean we can't access the node?

I//system/bin/bluetoothd( 2752): bluetoothd[2753]: Failed to open RFKILL control device

chmod 666 /dev/rfkill fixes this but doesn't seem to do much else for us.

Collaborator

Is it possible we should be grabbing a blob bluetoothd/libbluetooth that we're not?

Collaborator
qdot commented Jan 10, 2012

The only things we need to grab is the firmware. I've tried both cm and stock sgs2 firmware, neither seems to make a difference.

I've got an unpacked sgs2 cm 7.1 distro here, I'll try replacing those on b2g and seeing if it does anything.

Contributor
eric30 commented Feb 9, 2012

I've traced the code and found a way to solve this problem. In B2G, we start service 'hciattach' by a long command defined in init.rc:

service hciattach /system/bin/logwrapper /system/bin/brcm_patchram_plus 
          -d --enable_lpm --enable_hci --baudrate 3000000 --patchram .......

One parameter '--enable_lpm' would send a 'hci_sleep_cmd' to Bluetooth chip, which means that Bluetooth chip may 'sleep' at some time after that command has been sent. So, I tried to remove it from the command, and bluetooth works well afterwards.

The only side-effect of taking 'enable_lpm' off would be more power consumption, I guess. But I think we should fix this first to let Bluetooth work.

Contributor
eric30 commented Feb 15, 2012

Should've been fixed, see #176.

Collaborator
qdot commented Feb 15, 2012

Oh, yup, fixed. Forgot to put the resolve in the commit. :)

@qdot qdot closed this Feb 15, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment