Power & Source of Big Ideas

Bluetooth does not work in Debian or Ubuntu Core/QtE Images

Moderators: chensy, FATechsupport

Hello,

I just ran into an issue with Bluetooth on NanoPC-T3 both in the June and September images: While Bluetooth works fine in the Android image, in both Debian and/or Ubuntu Core-QtE, Bluetooth does not work at all:

Contrary to what is written here: http://wiki.friendlyarm.com/wiki/index.php/NanoPC-T3#Bluetooth,

Click on the bluetooth icon on the GUI a menu will pop up:
Make discoverable... enables the NanoPC-T3 to be searched for by nearby bluetooth devices;
Devices... opens a search window and searches for nearby bluetooth devices(Note: the "Make discoverable" property needs to be enabled on those nearby devices as well);
Send Files to Device...enables the NanoPC-T3 to send files to another bluetooth device which is paired to the NanoPC-T3
there is no bluetooth icon in the X11 GUI (package blueman is not even installed), and in /etc/modprobe.d we even have a file that blacklists Bluetooth kernel modules: /etc/modprobe.d/disable_bt.conf.

So can you please advise how to get Bluetooth to work fine on a NanoPC-T3 not only using Android, but plain Linux as well?

Thanks a million in advance & best regards,
awl
Hello again,

awl29 wrote:
Contrary to what is written here: http://wiki.friendlyarm.com/wiki/index.php/NanoPC-T3#Bluetooth, in both Debian and/or Ubuntu Core-QtE, Bluetooth does not work at all out of the box
as there was no help from FriendlyARM regarding this, I have started digging deeper and deeper into this, and can finally announce success: I can now provide detailed instructions on how to make Bluetooth work fine with the Debian and/or Ubuntu Core/QtE images.

Even though the kernel contains all modules as needed to make Bluetooth work fine under Debian/Ubuntu, there are two major issues to make it work:
  1. hciattach from the Debian/Ubuntu "bluez" packages does not work with this recent Broadcom Bluetooth chip (AP6212/BCM43438): The reason is that more recent Broadcom devices do no longer send a so-called "2-byte confirmation" that hciattach waits for (this can only be worked around by using Broadcom's own "brcm_patchram_plus" tool which has a "--no2bytes" option)
  2. There still is a bug (most probably in AP6212 design) that causes BCM43438 to be unresponsive/blocked on some occasions: To properly initialize the chip's uart interface, one must at least bump the CTS line (HIGH->LOW->HIGH) before sending any data (see https://code.google.com/archive/p/broadcom-bluetooth/issues/2), and possibly also (my results varied, as did other people's experiences with AP6212 in different forums) toggle Bluetooth rfkill state through the /sys/class/rfkill/rfkill0/state interface.
  3. FriendlyARM had included an existing "brcm_patchram_plus" service in their Debian/Ubuntu images, but this service is defunct in many ways:
    1. it references a non-existing device "/dev/ttyAMA0" instead of the correct "/dev/ttySAC1", such that it simply cannot work this way,
    2. it does not properly handle putting the brcm_patchram_plus binary (hciattach equivalent) into the background, such that it cannot be monitored from systemd, and
    3. its service description has dependencies to two more defunct services (hwservice and hwservice_monitor).
So here are my detailed instructions to fix these issues and make Bluetooth work:
  • In case it exists in your installation (not sure how this file got there in mine - it is not included in a clean install, but turned up there later somehow on my NanoPC-T3...!?), delete the file /etc/modprobe.d/disable_bt.conf (which blacklists bluetooth kernel modules)
  • Download the attached tarball "nanopi_bluetooth_fix.tar.bz2" to your NanoPC-T3
  • As user root, change to the root diectory (cd /) and unpack the tarball (using tar xvjf)
  • Remove the two dangling services: "rm /lib/systemd/system/hwservice.service" and "rm /lib/systemd/system/hwservice_monitor.service"
  • Execute "systemd daemon-reload" and "systemctl enable brcm_patchram_plus"
  • Reboot your NanoPC-T3
You may now use Bluetooth on hci0, and e.g. execute an "hcitool scan".

Hope this might help somebody else as well - took me about two full working days to figure it out... :roll:

Best regards
awl

Attachments

Hello awl29,

Thanks a lot for your work. I passed several hours to make bluetooth working on the NanoPI M3 before seeing your post. And finally with your instructions, I can see bluetooth low energy devices with debian image installed on the board.
Thanks again !

Jonathan
8-) 8-) Thanks man!! Your patch perfectly worked. You saved my project!!

;)

Cheers
hey, thanks man :D
Hi folks,
for completeness & those of us coming late to the party, this fix has been incorporated in the recent debbie system image.
so ... s5p6818-debian-sd4g-20161117.img (after update) already has this fix.
[ ... and, joining in with everyone else, thanks to the author of this patch :]
all the best
Lawrence

Who is online

In total there are 9 users online :: 0 registered, 0 hidden and 9 guests (based on users active over the past 5 minutes)
Most users ever online was 825 on Wed Aug 28, 2019 3:18 pm

Users browsing this forum: No registered users and 9 guests