(XA2) Bluetoothd Segfaulting when pairing with smartwatch

Hi all,

Not sure if this is the right place to ask, but I’ve recently been having bluetoothd crash while attempting to pair my XA2 with my smartwatch.

The following is the output of bluetoothd run with -n -d:

bluetoothd[15402]: src/device.c:gatt_debug() Read By Type - start: 0x0001 end: 0x000f
bluetoothd[15402]: src/device.c:gatt_debug() Read By Type - start: 0x000f end: 0x000f
bluetoothd[15402]: src/device.c:gatt_debug() Read By Type - start: 0x0001 end: 0xffff
bluetoothd[15402]: src/gatt-database.c:db_hash_read_cb() Database Hash read
Segmentation fault (core dumped)

The following is from attempting to pair using bluetoothctl:

[bluetooth]# pair 43:43:A0:12:1F:AC 
[Attempting to pair with 43:43:A0:12:1F:AC
[CHG] Device 43:43:A0:12:1F:AC Connected: yes    
Request confirmation
[agent] Confirm passkey 434021 (yes/no): Agent unregistered
[agent] Confirm passkey 434021 (yes/no): [DEL] Controller D4:38:9C:BA:D5:8D Xperia XA2 [default]
Waiting to connect to bluetoothd...

Does anyone have any ideas about how I could resolve this?

Interestingly my phone connects to my laptop with no issues, and my laptop to my watch is fine as well.

There’s only an issue when connecting the watch to the phone.

you sure it’s supported in Sailfish?

It had been pairing fine since Sailfish 4 came out, it only started segfaulting this weekend.

you may want to inspect (backup/remove) /var/lib/bluetooth/cache or everything under /var/lib/bluetooth and restart bluetoothd or reboot.

Are you by any chance the same Geoff that is working on the Starfish AsteroidOS client for SFOS? I tried to compile your latest Github commit with the Sailfish SDK, but I got an error that I didn’t select a platform. Could you tell me how I would do this? (Sorry to hijack your topic here)

Yep that’s me! No worries, it would be good to get someone else testing and using it :slight_smile:.

So What I’ve been doing is:
In QT Creator -> Projects -> Build & Run -> Select the build config that you want I.E SailfishOS-4.0.1.48-armv7hl -> Build Steps -> qmake -> Additional arguments
and add CONFIG+=starfish

There’s probably a way to add that in the QT project files, but everything I’ve tried hasn’t worked so far.

Cheers, I’ve already tried that but will give it another go as I may have missed something.

If that’s not clear I can look at adding a screenshot later, I just don’t have any software for that on my laptop right now :sweat_smile:

Also, Starfish is pretty bare bones at the moment.
Notification forwarding is working, but I was 90% through getting time sync setup when this Bluetooth issue happened.

I think I managed that but I still can’t build because device is not specified. I guess that is caused in my environment and I will see how to sort that out. Thank you!

OK, looks like this due to a bug in Bluez5 5.54

https://www.spinics.net/lists/linux-bluetooth/msg85404.html

And its fixed in 5.55.
https://git.kernel.org/pub/scm/bluetooth/bluez.git/commit/?id=5a180f2ec9edfacafd95e5fed20d36fe8e077f07

Is there anyway to manually update bluez?

checkout the bluez5 code and build the packages. I have not done it recently, but it was working fine some time ago.

OK so after a small struggle I’ve managed to get bluez5 building.
For anyone stumbling on this in the future, I first pulled bluez5 from here https://git.sailfishos.org/mer-core/bluez5
And then installed the Platform SDK.

After that I installed libtool to both SailfishOS-latest-armv7hl and SailfishOS-latest.
After that I was able to go into sb2 and run ./bootstrap.

Then finally mb2 build ran to completion and compiled without errors.

and did this solve your original issue?
Also what is SailfishOS-latest-armv7hl 4.0.x or 4.1.x? because I think there is a kind of BT problem with the 4.0.x

thanks

Haven’t solved the issue yet, currently attempting to rebase the sailfishos fork of bluez5 onto upstream 5.55.

Looks like I mucked up my install somehow, as ssu re is telling me that its running 3.4.0.24.

[SB2 sdk-build SailfishOS-latest-armv7hl] geofft@Mico-Top bluez5 $ ssu re
WARNING: ssu.ini does not seem to be writable. Setting values might not work.
Device release is currently: 3.4.0.24

Thanks for asking that, I probably wouldn’t have caught it otherwise.

Yeah looks like the “latest” toolings and targets haven’t been updated since October last year.

Sailfish_OS-4.0.1.48-Sailfish_SDK_Target-aarch6..> 19-Feb-2021 07:09           158667027
Sailfish_OS-4.0.1.48-Sailfish_SDK_Target-aarch6..> 19-Feb-2021 07:10                  90
Sailfish_OS-4.0.1.48-Sailfish_SDK_Target-armv7h..> 19-Feb-2021 07:09           150686235
Sailfish_OS-4.0.1.48-Sailfish_SDK_Target-armv7h..> 19-Feb-2021 07:10                  90
Sailfish_OS-4.0.1.48-Sailfish_SDK_Target-i486.t..> 19-Feb-2021 07:10           166574744
Sailfish_OS-4.0.1.48-Sailfish_SDK_Target-i486.t..> 19-Feb-2021 07:10                  87
Sailfish_OS-4.0.1.48-Sailfish_SDK_Tooling-i486...> 19-Feb-2021 07:10           275696138
Sailfish_OS-4.0.1.48-Sailfish_SDK_Tooling-i486...> 19-Feb-2021 07:10                  88
Sailfish_OS-latest-Sailfish_SDK_Target-aarch64...> 30-Oct-2020 11:27           157721406
Sailfish_OS-latest-Sailfish_SDK_Target-aarch64...> 30-Oct-2020 13:21                  88
Sailfish_OS-latest-Sailfish_SDK_Target-armv7hl...> 30-Oct-2020 11:27           149596840
Sailfish_OS-latest-Sailfish_SDK_Target-armv7hl...> 30-Oct-2020 13:21                  88
Sailfish_OS-latest-Sailfish_SDK_Target-i486.tar.7z 30-Oct-2020 11:27           166307736
Sailfish_OS-latest-Sailfish_SDK_Target-i486.tar..> 30-Oct-2020 13:22                  85
Sailfish_OS-latest-Sailfish_SDK_Tooling-i486.ta..> 30-Oct-2020 11:27           272602465
Sailfish_OS-latest-Sailfish_SDK_Tooling-i486.ta..> 30-Oct-2020 13:22                  86

Well, I suspect (for other reasons ff) that there is a massive issue with bluetooth in 4.0.1.48. This is why I was asking regarding versions.

Regarding this issue with “ssu re” I also have seen it before, but do not recall how it was solved. I remember there was a hint on TJC.

I have put some notes here based on the TJC and documentation

ssu release 2.0.1.11 
	- replace 2.0.1.11 by the version you want to install. You can see the newest version in the Sailfish update app in settings
version --dup 
	- this will start the process of updating and will take several minutes to complete. You should never close the terminal when you're running this command. You will see some output and percents, it has three parts - refreshing repositories, downloading updates, installing updates, after these three parts are done, you will see message that advices you to reboot your phone, which you should do.

   1. Check release with ssu s, update to actual OS release if required with ssu release x.x.x.xx (devel-su required). Note: 'latest' is not correct.
   1a. If release updated, execute version --dup
   2. Perform pkcon refresh (pkcon update isn't enough)

	devel-su
	pkcon refresh
	version --dup
	sync
	reboot

For now I have frozen my testing X device and will continue when 4.1 is out. My daily driver is on 3.3.0.16