[Flatfish] Support Bluedroid on flatfish device

RESOLVED FIXED

Status

defect
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: dliang, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [TCP][flatfish])

Attachments

(3 attachments, 7 obsolete attachments)

For contribution program, we would like to support bluedroid on flatfish devices.
Posted file build.log (obsolete) —
Update the error log of build break with enable bluedroid.

/home/dannyliang/work/codes/b2g_flatfish_github/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/bin/../lib/gcc/arm-linux-androideabi/4.6.x-google/../../../../arm-linux-androideabi/bin/ld: /home/dannyliang/work/codes/b2g_flatfish_github/objdir-gecko/toolkit/library/../../dom/bluetooth/BluetoothHfpManager.o: in function vtable for mozilla::dom::bluetooth::BluetoothHfpManager:BluetoothHfpManager.cpp(.data.rel.ro._ZTVN7mozilla3dom9bluetooth19BluetoothHfpManagerE+0x38): error: undefined reference to 'mozilla::dom::bluetooth::BluetoothHfpManager::Reset()'
collect2: ld returned 1 exit status
make[6]: *** [libxul.so] Error 1
make[5]: *** [toolkit/library/libs] Error 2
make[4]: *** [libs] Error 2
make[3]: *** [default] Error 2
make[2]: *** [realbuild] Error 2
make[1]: *** [build] Error 2
make: *** [out/target/product/flatfish/obj/DATA/gecko_intermediates/gecko] Error 2
Posted patch bluedroid.patch (obsolete) — Splinter Review
patch to fix build break
Attachment #8394567 - Attachment is obsolete: true
libbt is required for flatfish, which controls power-on/off bt chipset. libbt would create libhci-vendor.so. This part required some vendor specific configuration. ni? Sam for this library.
Flags: needinfo?(ckjboy2003)
(In reply to Danny Liang [:dliang] from comment #3)
> Created attachment 8394605 [details]
> build.log
> 
> Update the error log of build break with enable bluedroid.
> 
> /home/dannyliang/work/codes/b2g_flatfish_github/prebuilts/gcc/linux-x86/arm/
> arm-linux-androideabi-4.6/bin/../lib/gcc/arm-linux-androideabi/4.6.x-google/.
> ./../../../arm-linux-androideabi/bin/ld:
> /home/dannyliang/work/codes/b2g_flatfish_github/objdir-gecko/toolkit/library/
> ../../dom/bluetooth/BluetoothHfpManager.o: in function vtable for
> mozilla::dom::bluetooth::BluetoothHfpManager:BluetoothHfpManager.cpp(.data.
> rel.ro._ZTVN7mozilla3dom9bluetooth19BluetoothHfpManagerE+0x38): error:
> undefined reference to
> 'mozilla::dom::bluetooth::BluetoothHfpManager::Reset()'
> collect2: ld returned 1 exit status
> make[6]: *** [libxul.so] Error 1
> make[5]: *** [toolkit/library/libs] Error 2
> make[4]: *** [libs] Error 2
> make[3]: *** [default] Error 2
> make[2]: *** [realbuild] Error 2
> make[1]: *** [build] Error 2
> make: *** [out/target/product/flatfish/obj/DATA/gecko_intermediates/gecko]
> Error 2

This had been fixed in bug 986352
(In reply to Shawn Huang [:shuang] [:shawnjohnjr] from comment #8)
> (In reply to Danny Liang [:dliang] from comment #3)
> > Created attachment 8394605 [details]
> > build.log
> > 
> > Update the error log of build break with enable bluedroid.
> > 
> > /home/dannyliang/work/codes/b2g_flatfish_github/prebuilts/gcc/linux-x86/arm/
> > arm-linux-androideabi-4.6/bin/../lib/gcc/arm-linux-androideabi/4.6.x-google/.
> > ./../../../arm-linux-androideabi/bin/ld:
> > /home/dannyliang/work/codes/b2g_flatfish_github/objdir-gecko/toolkit/library/
> > ../../dom/bluetooth/BluetoothHfpManager.o: in function vtable for
> > mozilla::dom::bluetooth::BluetoothHfpManager:BluetoothHfpManager.cpp(.data.
> > rel.ro._ZTVN7mozilla3dom9bluetooth19BluetoothHfpManagerE+0x38): error:
> > undefined reference to
> > 'mozilla::dom::bluetooth::BluetoothHfpManager::Reset()'
> > collect2: ld returned 1 exit status
> > make[6]: *** [libxul.so] Error 1
> > make[5]: *** [toolkit/library/libs] Error 2
> > make[4]: *** [libs] Error 2
> > make[3]: *** [default] Error 2
> > make[2]: *** [realbuild] Error 2
> > make[1]: *** [build] Error 2
> > make: *** [out/target/product/flatfish/obj/DATA/gecko_intermediates/gecko]
> > Error 2
> 
> This had been fixed in bug 986352

Hi,

Iean removed libbt since we did not need it before. 
By adding it back to flatfish, he does not see any build error so far.
Flags: needinfo?(ckjboy2003)
(In reply to Sam Lin from comment #9)
> (In reply to Shawn Huang [:shuang] [:shawnjohnjr] from comment #8)
> > (In reply to Danny Liang [:dliang] from comment #3)
> > > Created attachment 8394605 [details]
> > > build.log
> > > 
> > > Update the error log of build break with enable bluedroid.
> > > 
> > > /home/dannyliang/work/codes/b2g_flatfish_github/prebuilts/gcc/linux-x86/arm/
> > > arm-linux-androideabi-4.6/bin/../lib/gcc/arm-linux-androideabi/4.6.x-google/.
> > > ./../../../arm-linux-androideabi/bin/ld:
> > > /home/dannyliang/work/codes/b2g_flatfish_github/objdir-gecko/toolkit/library/
> > > ../../dom/bluetooth/BluetoothHfpManager.o: in function vtable for
> > > mozilla::dom::bluetooth::BluetoothHfpManager:BluetoothHfpManager.cpp(.data.
> > > rel.ro._ZTVN7mozilla3dom9bluetooth19BluetoothHfpManagerE+0x38): error:
> > > undefined reference to
> > > 'mozilla::dom::bluetooth::BluetoothHfpManager::Reset()'
> > > collect2: ld returned 1 exit status
> > > make[6]: *** [libxul.so] Error 1
> > > make[5]: *** [toolkit/library/libs] Error 2
> > > make[4]: *** [libs] Error 2
> > > make[3]: *** [default] Error 2
> > > make[2]: *** [realbuild] Error 2
> > > make[1]: *** [build] Error 2
> > > make: *** [out/target/product/flatfish/obj/DATA/gecko_intermediates/gecko]
> > > Error 2
> > 
> > This had been fixed in bug 986352
> 
> Hi,
> 
> Iean removed libbt since we did not need it before. 
> By adding it back to flatfish, he does not see any build error so far.

Hi Sam, this should be fixed in bug 986352, so you won't see the error message.
Please help to comment on https://bugzilla.mozilla.org/show_bug.cgi?id=986314#c6 Thanks,
Flags: needinfo?(ckjboy2003)
The pure AOSP libbt does not contain config for flatfish. So i think you need to provide it.
The path is /system/vendor/lib/libbt-vendor.so
Blocks: 987489
Blocks: flatfish
Component: General → Bluetooth
Program received signal SIGBUS, Bus error.
[Switching to Thread 1762.1783]
0x41dbb662 in AdapterPropertiesCallback (aStatus=BT_STATUS_SUCCESS, aNumProperties=1, aProperties=0x45679c4a) at ../../../gecko/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp:277
277	    bt_property_t p = aProperties[i];
(gdb) bt
#0  0x41dbb662 in AdapterPropertiesCallback (aStatus=BT_STATUS_SUCCESS, aNumProperties=1, aProperties=0x45679c4a) at ../../../gecko/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp:277
#1  0x4602462c in execute_storage_request (event=<optimized out>, p_param=<optimized out>) at external/bluetooth/bluedroid/main/../btif/src/btif_core.c:981
#2  0x4602492c in btif_context_switched (p_msg=0x45679c34) at external/bluetooth/bluedroid/main/../btif/src/btif_core.c:177
#3  btif_task (params=<optimized out>) at external/bluetooth/bluedroid/main/../btif/src/btif_core.c:308
#4  0x460425d8 in gki_task_entry (params=<optimized out>) at external/bluetooth/bluedroid/gki/./ulinux/gki_ulinux.c:154
#5  0x401503dc in __thread_entry (func=0x46042579 <gki_task_entry>, arg=0x460f5d60, tls=0x462f5f00) at bionic/libc/bionic/pthread.c:204
#6  0x4014fac8 in pthread_create (thread_out=0x462f5f00, attr=0xbebce458, start_routine=0x46042579 <gki_task_entry>, arg=<optimized out>) at bionic/libc/bionic/pthread.c:348
#7  0x00000000 in ?? ()
(gdb) p p
$1 = {type = 0, len = -1073741824, val = 0x1000}
(gdb) p aNumProperties
$2 = 1
(gdb) p aProperties[1]
$3 = {type = BT_PROPERTY_BDNAME, len = 1515870810, val = 0x5a5a5a5a}
Looks like the bluetooth adapter name len and value is invalid here. This is why it creates crash.
(In reply to Shawn Huang [:shuang] [:shawnjohnjr] from comment #14)
> (gdb) p p
> $1 = {type = 0, len = -1073741824, val = 0x1000}
> (gdb) p aNumProperties
> $2 = 1
> (gdb) p aProperties[1]
> $3 = {type = BT_PROPERTY_BDNAME, len = 1515870810, val = 0x5a5a5a5a}

Getting index 1 is wrong in gdb, since aNumProperties==1. Anyway, query index 0, everything looks like valid.

(gdb) p aProperties[0]
$4 = {type = BT_PROPERTY_ADAPTER_SCAN_MODE, len = 4, val = 0x45679666}
(gdb) p *(bt_scan_mode_t*)(aProperties[0].val)
$8 = BT_SCAN_MODE_CONNECTABLE

Thus, I still don't understand why we got SIGBUS error here.
I can turn on Bluetooth now, after renaming firmware patch file from /system/vendor/modules/bcm40183b2.hcd to /system/vendor/modules/BCM4330B1.hcd.

Also, for gecko, gecko/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp:277
I changed the statement, which seems to work. I still don't understand why this can make differences. But it works. I still need to figure out the root cause bringing SIGBUS error.

   for (int i = 0; i < aNumProperties; i++) {
-    bt_property_t p = aProperties[i];
+    bt_property_t p;
+    p.type = aProperties[i].type;
+    p.len = aProperties[i].len;
+    p.val = aProperties[i].val;
I open Bug 989976 for tracking SIGBUS error in gecko. Leave this bug open for general porting purpose.
Whiteboard: [TCP]
build failed when I try to enable bluedroid on flatfish (Jellybean) codebase...

1. add libbt to /device/common
2. add external/bluetooth/bluedroid
3. remove external/bluetooth/bluez
4. remove external/bluetooth/glib

gaia:
commit 88e0a972280bb35847c010b8c3f1481fa80f3847
Merge: 8a7fb29 7ba68d9
Author: Pavel Ivanov <pivanov@mozilla.com>
Date:   Mon Jul 14 10:00:05 2014 +0300

    Merge pull request #21655 from pivanov/bug-1035708
    
    Bug 1035708 - [Bluetooth] - remove unused images


gecko: 
commit f6aad75c6ac3d3da06406f3570833f29771e217d
Merge: 51ac93f 6070e19
Author: Wes Kocher <wkocher@mozilla.com>
Date:   Sun Jul 13 11:56:58 2014 -0700

    Merge b2g-inbound to m-c a=merge

build.log
../../../gecko/dom/bluetooth/bluedroid/BluetoothInterface.cpp: In member function 'bt_status_t mozilla::dom::bluetooth::SocketMessageWatcher::RecvMsg1()':
../../../gecko/dom/bluetooth/bluedroid/BluetoothInterface.cpp:333:126: error: 'errno' was not declared in this scope
../../../gecko/dom/bluetooth/bluedroid/BluetoothInterface.cpp:333:135: error: 'EINTR' was not declared in this scope
../../../gecko/dom/bluetooth/bluedroid/BluetoothInterface.cpp: In member function 'bt_status_t mozilla::dom::bluetooth::SocketMessageWatcher::RecvMsg2()':
../../../gecko/dom/bluetooth/bluedroid/BluetoothInterface.cpp:358:126: error: 'errno' was not declared in this scope
../../../gecko/dom/bluetooth/bluedroid/BluetoothInterface.cpp:358:135: error: 'EINTR' was not declared in this scope
../../../gecko/dom/bluetooth/bluedroid/BluetoothInterface.cpp:377:98: error: 'errno' was not declared in this scope
../../../gecko/dom/bluetooth/bluedroid/BluetoothInterface.cpp:377:107: error: 'EINTR' was not declared in this scope
Hi,

Thanks for reporting this. We have seen this problem before. System headers differ in the files they include, so we might not always see these errors on all platforms. The patch adds some missing include statements.

Shawn, should we land this patch together with the other flatfish patches here, or shall we land it separately now? I'd tend towards the latter option.
Attachment #8455209 - Flags: review?(shuang)
Attachment #8455209 - Flags: feedback?(iean.lin)
Comment on attachment 8455209 [details] [diff] [review]
Bug 986314: Include <errno.h> in BluetoothInterface.cpp

It works, thanks a lot.
Attachment #8455209 - Flags: feedback?(iean.lin) → feedback+
Comment on attachment 8455209 [details] [diff] [review]
Bug 986314: Include <errno.h> in BluetoothInterface.cpp

Landing this patch in bug 1038097
A [flatfish][tcp] image with bluedroid supported is available for download:
https://www.dropbox.com/sh/b2py1btcwstqldl/AABM1TPRodkpaHzPGy0SYXfNa/bluedroid


Hi Eva,
Could you help test this image, thank you.
Flags: needinfo?(eva.chen.fx)
Hi, Shawn & Thomas, if the new patch can be landed, please let us know. We will include the corresponding binary file in the daily build image to enable Bluedroid on Flatfish.
Bluedroid test results:
1. Verify the Pair & Unpair function.(from Flatfish to Computer) ---> Pass
2. Verify the Pair & Unpair function.(from Flatfish to Bluetooth Speaker) ---> Pass
3. Verify the volume control over Bluetooth. ---> Pass
4. Send a file(.jpg or .mp3) from the Flatfish device to computer. ---> Fail, 'The transfer has started' shown in sender's(Flatfish) notification, no file transfer request on receiving end(Computer), no file sent.(same as bug #962390)
5. Receive a file(.jpg or .mp3) from computer to a Flatfish device. --->Fail, Unable to receive files over Bluetooth. Sometimes the OS crash and restart the tablet itself.
-----------------------------------------------
Gaia:  88e0a972280bb35847c010b8c3f1481fa80f3847
Gecko: f6aad75c6ac3d3da06406f3570833f29771e217d
BuildID: 20140714190611
Version: 33.0a1
OS version: 2.1.0.0
Flags: needinfo?(eva.chen.fx)
(In reply to William Liang from comment #26)
> Hi, Shawn & Thomas, if the new patch can be landed, please let us know. We
> will include the corresponding binary file in the daily build image to
> enable Bluedroid on Flatfish.
Patch landed on Central.
https://hg.mozilla.org/mozilla-central/rev/70eeb07a2517
Thanks to Eva and Shawn!
Since Bug #962390 has been reported, hopefully it can be solved some other day.
Iean, let's put the needed binary in the daily build image afterward.
Flags: needinfo?(iean.lin)
Hi Danny, could you help update the manifest of flatfish
Flags: needinfo?(iean.lin) → needinfo?(dliang)
(In reply to Iean Lin from comment #30)
> Created attachment 8456742 [details] [diff] [review]
> Update extract-files.sh to support bluedroid on flatfish device
> 
> Hi Danny, could you help update the manifest of flatfish

Hi Iean, for extract-files.sh, what will be happened if we use new extract-files.sh but old system.img? As I know, the pull operation fail will cause build fail. Could you help to add some error message when build break to let user to download the new system.img?
add some error message when build break
Flags: needinfo?(dliang)
Whiteboard: [TCP] → [TCP][flatfish]
PR for update extract-files.sh
Attachment #8394568 - Attachment is obsolete: true
Attachment #8394605 - Attachment is obsolete: true
Attachment #8456742 - Attachment is obsolete: true
Attachment #8458537 - Attachment is obsolete: true
Attachment #8464587 - Flags: review?(kli)
PR for update manifest to support bluedroid
Attachment #8464588 - Flags: review?(kli)
Comment on attachment 8464588 [details]
pull request for bug 986314 - part 2.html

Look good.
Attachment #8464588 - Flags: review?(kli) → review+
Comment on attachment 8464587 [details]
pull request for bug 986314 - part 1.html

Danny, I left comment on github, plese have a look.
Comment on attachment 8464587 [details]
pull request for bug 986314 - part 1.html

Danny, Please see my comment on github. Thanks!
Attachment #8464587 - Flags: review?(kli) → review+
Attachment #8394625 - Attachment is obsolete: true
Hi Kai-Zhen, 
I have modified PR part 1 and part 2 as you commented. Could you help to merge them? Change status to checkin-needed might cause someone confused due to one of patches has been landed. Please help on this and let me know if any concern. Thanks.
Flags: needinfo?(kli)
../../../gecko/dom/bluetooth/bluedroid/BluetoothInterface.cpp: In lambda function:
../../../gecko/dom/bluetooth/bluedroid/BluetoothInterface.cpp:30:25: error: expected '{' before '=' token
../../../gecko/dom/bluetooth/bluedroid/BluetoothInterface.cpp: In function 'nsresult mozilla::dom::bluetooth::Convert(bt_status_t, mozilla::dom::bluetooth::BluetoothStatus&)':
../../../gecko/dom/bluetooth/bluedroid/BluetoothInterface.cpp:30:27: error: no match for 'operator=' in '{(bt_status_t)0u} = (mozilla::dom::bluetooth::BluetoothStatus)0u'
../../../gecko/dom/bluetooth/bluedroid/BluetoothInterface.cpp:30:27: note: candidate is:
../../../gecko/dom/bluetooth/bluedroid/BluetoothInterface.cpp:30:23: note: mozilla::dom::bluetooth::Convert(bt_status_t, mozilla::dom::bluetooth::BluetoothStatus&)::<lambda()>& mozilla::dom::bluetooth::Convert(bt_status_t, mozilla::dom::bluetooth::BluetoothStatus&)::<lambda()>::operator=(const mozilla::dom::bluetooth::Convert(bt_status_t, mozilla::dom::bluetooth::BluetoothStatus&)::<lambda()>&) <deleted>
We are aware of this problem. Looks like a compiler problem.
You need to log in before you can comment on or make changes to this bug.