Closed Bug 944299 Opened 6 years ago Closed 6 years ago

B2G Emulator: support bluedroid

Categories

(Firefox OS Graveyard :: Emulator, defect)

x86_64
Linux
defect
Not set

Tracking

(Not tracked)

RESOLVED FIXED
2.0 S4 (20june)

People

(Reporter: vicamo, Assigned: shawnjohnjr)

References

Details

Attachments

(5 files, 3 obsolete files)

No description provided.
Attached file adb-logcat.log (obsolete) —
Current status: enabling BT in Settings app hangs Gaia, bt-vendor closes opened fd.
https://wiki.mozilla.org/B2G/Bluetooth-bluedroid from Shawn Huang [:shuang] [:shawnjohnjr].
Attached file adb-logcat.log (obsolete) —
Disable HCISU_H4_INCLUDED in bdroid_buildcfg.h, still failed with:

  E/bt-btif (   45): ...preload_wait_timeout (retried:0/max-retry:0)...
Attachment #8360355 - Attachment is obsolete: true
Attached file adb-logcat.log
Added bt_config.xml.  Still fails with preload_wait_timeout.
Attachment #8361600 - Attachment is obsolete: true
The error message looks like libbt-vendor.so (libbt-hci) does not complete stack preload process.(In reply to Vicamo Yang [:vicamo][:vyang] from comment #5)
> Created attachment 8361600 [details]
> Disable HCISU_H4_INCLUDED in bdroid_buildcfg.h, still failed with:
> 
>   E/bt-btif (   45): ...preload_wait_timeout (retried:0/max-retry:0)...
The error message looks like libbt-vendor.so (libbt-hci) does not complete stack preload process. I guess something wrong in libbt/src/hardware.c, libbt is all based on brcm chipset implementation.
04-08 08:25:59.405    45    45 I bt_vendor: init
04-08 08:25:59.405    45    45 I bt_vnd_conf: Attempt to load conf from /etc/bluetooth/bt_vendor.conf
04-08 08:25:59.405    45    45 E bt_h4   : hci_h4_init
04-08 08:25:59.405    45    45 E bt_userial: userial_init
04-08 08:25:59.415    45    45 E bt_hci_bdroid: set_power 0
04-08 08:25:59.415    45    45 D bt_upio : is_emulator_context : 1
04-08 08:25:59.415    45    45 E bt_hci_bdroid: set_power 1
04-08 08:25:59.415    45    45 D bt_upio : is_emulator_context : 1
04-08 08:25:59.415    45    45 D bt_upio : set_bluetooth_power [emul] 1
04-08 08:25:59.415    45    45 E bt_hci_bdroid: preload
04-08 08:25:59.484    45   545 I bt_hci_bdroid: bt_hc_worker_thread started
04-08 08:25:59.484    45   545 E bt_userial: userial_open(port:0)
04-08 08:25:59.484    45   545 I bt_userial_vendor: userial vendor open: opening /dev/ttyS2
04-08 08:25:59.494    45   545 I bt_userial_vendor: device fd = 127 open
04-08 08:25:59.494    45   545 E bt_userial: fd = 127
04-08 08:25:59.494    45   548 E bt_userial: Entering userial_read_thread()
04-08 08:25:59.564    45   546 I GKI_LINUX: gki_task_entry: gki_task_entry task_id=0 [BTU] starting
04-08 08:25:59.584    45   546 W bt-hci  : No command in queue matching opcode 0
04-08 08:25:59.594    45   546 W bt-hci  : No command in queue matching opcode 0
04-08 08:26:02.408    45   544 E bt-btif : ...preload_wait_timeout (retried:0/max-retry:0)...

It looks like stuck in the middle of executing vendor specific commands.
This looks like after sending HCI_RESET command to /dev/ttyS2 and we got opcode 0 HCI command status event. In stack/btu/btu_hcif.c, we saw strong event return from /dev/ttyS2.

04-09 03:34:58.535 D/bt_vendor(   45): BT_VND_OP_POWER_CTRL ON
04-09 03:34:58.545 D/bt_upio (   45): is_rfkill_disabled ? [0]
04-09 03:34:58.545 E/bt_hci_bdroid(   45): preload
04-09 03:34:58.675 I/bt_hci_bdroid(   45): bt_hc_worker_thread started
04-09 03:34:58.675 E/bt_userial(   45): userial_open(port:0)
04-09 03:34:58.675 D/bt_vendor(   45): op for 3
04-09 03:34:58.675 D/bt_vendor(   45): BT_VND_OP_USERIAL_OPEN
04-09 03:34:58.675 I/bt_userial_vendor(   45): userial vendor open: opening /dev/ttyS2
04-09 03:34:58.685 I/bt_userial_vendor(   45): device fd = 136 open
04-09 03:34:58.685 E/bt_userial(   45): fd = 136
04-09 03:34:58.685 D/bt_vendor(   45): op for 1
04-09 03:34:58.685 D/bt_vendor(   45): BT_VND_OP_FW_CFG
04-09 03:34:58.685 D/bt_hwcfg(   45): ---- hw_config_start HCI_RESET ----
04-09 03:34:58.685 E/bt_userial(   45): Entering userial_read_thread()
04-09 03:34:58.705 I/GKI_LINUX(   45): gki_task_entry: gki_task_entry task_id=0 [BTU] starting
04-09 03:34:58.755 E/BTLD    (   45): btu_hcif_command_status_evt, controller id: 0, opcode: 0, opcode cmd: 1143967164 ,status: 0 
04-09 03:34:58.755 W/bt-hci  (   45): No command in queue matching opcode 0
04-09 03:34:58.765 E/BTLD    (   45): btu_hcif_command_status_evt, controller id: 0, opcode: 0, opcode cmd: 1143967164 ,status: 0 
04-09 03:34:58.765 W/bt-hci  (   45): No command in queue matching opcode 0
I dumped hci packet and found HCI event (Command Status) is incorrect from QEMU.

hcidump -r btsnoop_hci.log 
HCI sniffer - Bluetooth packet analyzer ver 2.5
btsnoop version: 1 datalink type: 1002
< HCI Command: Reset (0x03|0x0003) plen 0
> HCI Event: Command Status (0x0f) plen 4
    Unknown (0x00|0x0000) status 0x00 ncmd 1


Normal Reset hci event should be:
> HCI Event: Command Complete (0x0e) plen 4
    Reset (0x03|0x0003) ncmd 1
    status 0x00

In Bluetooth core spec, HCI commands and Events, HCI_Reset:
"When the reset has been performed, a Command Complete event shall be
generated."

In external/qemu/hw/bt-hci.c,
    case cmd_opcode_pack(OGF_HOST_CTL, OCF_RESET):
        bt_hci_reset(hci);
-        bt_hci_event_status(hci, HCI_SUCCESS);
+        bt_hci_event_complete_status(hci, HCI_SUCCESS);
Even changing bt_hci_event_complete_status, I found the last hci command was not included into command complete event.

< HCI Command: Reset (0x03|0x0003) plen 0
> HCI Event: Command Complete (0x0e) plen 4
    Unknown (0x00|0x0000) ncmd 1
It still did not fix preload error problem.
I tried to use libbt-vendor of qct version (bcm version gotta many chipset related to operation), and managed to call |bt_vendor_cbacks->fwcfg_cb(BT_VND_OP_RESULT_SUCCESS)| directly so preload firmware can be ignored and pass but now it stucked at different level -- processing HCI reset.
Assignee: vyang → shuang
No longer blocks: emulator-NFC
(In reply to Shawn Huang [:shuang] [:shawnjohnjr] from comment #11)
> I dumped hci packet and found HCI event (Command Status) is incorrect from
> QEMU.
> 
> hcidump -r btsnoop_hci.log 
> HCI sniffer - Bluetooth packet analyzer ver 2.5
> btsnoop version: 1 datalink type: 1002
> < HCI Command: Reset (0x03|0x0003) plen 0
> > HCI Event: Command Status (0x0f) plen 4
>     Unknown (0x00|0x0000) status 0x00 ncmd 1
> 
> 
> Normal Reset hci event should be:
> > HCI Event: Command Complete (0x0e) plen 4
>     Reset (0x03|0x0003) ncmd 1
>     status 0x00
> 
> In Bluetooth core spec, HCI commands and Events, HCI_Reset:
> "When the reset has been performed, a Command Complete event shall be
> generated."
> 
> In external/qemu/hw/bt-hci.c,
>     case cmd_opcode_pack(OGF_HOST_CTL, OCF_RESET):
>         bt_hci_reset(hci);
> -        bt_hci_event_status(hci, HCI_SUCCESS);
> +        bt_hci_event_complete_status(hci, HCI_SUCCESS);
Because opcode is missing in HCI event complete, this CommandComplete event will be thrown away.
external/bluetooth/bluedroid/stack/./btu/btu_hcif.c, btu_hcif_command_complete_evt
Attachment #8434052 - Flags: review?(vyang) → review+
Comment on attachment 8434080 [details] [review]
Bug 944299 - B2G Emulator: support bluedroid

Could you also help correct all the commit summaries "Bug 944299 - M/N" to "Bug 944299 - M/6"?  Thank you.
Attachment #8434080 - Flags: review?(vyang) → review+
(In reply to Vicamo Yang [:vicamo][:vyang] from comment #18)
> Comment on attachment 8434080 [details] [review]
> Bug 944299 - B2G Emulator: support bluedroid
> 
> Could you also help correct all the commit summaries "Bug 944299 - M/N" to
> "Bug 944299 - M/6"?  Thank you.

Sure. I've updated the commit summaries.
Comment on attachment 8434080 [details] [review]
Bug 944299 - B2G Emulator: support bluedroid

That's a wrong branch.  Please send pull request to https://github.com/mozilla-b2g/device_generic_goldfish/tree/b2g-4.3_r2.1
Attachment #8434080 - Flags: review+ → review-
Attachment #8435628 - Flags: review?(vyang) → review+
Attachment #8435696 - Flags: review?(shuang) → review+
b2g-4.3_r2.1: https://github.com/mozilla-b2g/platform_build/commit/cc67f31dc638c0b7edba3cf7e3d87cadf0ed52bf
Status: NEW → RESOLVED
Closed: 6 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → 2.0 S4 (20june)
See Also: → qemu-bt-test
See Also: → 1139774
You need to log in before you can comment on or make changes to this bug.