Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@larsblumberg
Last active May 28, 2021 16:36
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larsblumberg/2335c0ba97f805a2b996f1a7c3ac9571 to your computer and use it in GitHub Desktop.
Save larsblumberg/2335c0ba97f805a2b996f1a7c3ac9571 to your computer and use it in GitHub Desktop.
Flash Raspian Lite and set up latest BlueZ for Raspberry Pi 3
Flashing the memory card and creating /ssh file
===============================================
diskutil unmountDisk /dev/disk4
sudo dd bs=1m if=2017-01-11-raspbian-jessie-lite.img of=/dev/rdisk4
touch /Volumes/boot/ssh
diskutil unmountDisk /dev/disk4
SSH to Raspberry Pi
===================
ssh pi@raspberrypi.local
Stop Legacy BlueZ and Install Dependencies
==========================================
sudo systemctl stop bluetooth
sudo apt-get update
sudo apt-get install libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev libdbus-glib-1-dev unzip
Download, Compile and Install Latest BlueZ
==========================================
cd
mkdir bluez
cd bluez
wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.44.tar.xz
tar xf bluez-5.44.tar.xz
cd bluez-5.44
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-library
make
sudo make install
sudo ln -svf /usr/libexec/bluetooth/bluetoothd /usr/sbin/
sudo install -v -dm755 /etc/bluetooth
sudo install -v -m644 src/main.conf /etc/bluetooth/main.conf
sudo systemctl daemon-reload
sudo systemctl start bluetooth
bluetoothd --version # should now print 5.44
Enable bluetoothd on System Start
=================================
sudo systemctl daemon-reload
sudo systemctl enable /lib/systemd/system/bluetooth.service
sudo systemctl start bluetooth
systemctl status bluetooth
Run Ptyhon test scripts that make use of bluetoothd D-Bus
=========================================================
# Install dbus-python
sudo apt-get install -y python-dev libdbus-1-dev libdbus-glib-1-dev python-gi python-pip
sudo python2.7 -m pip install dbus-python
# Run tests (it's inside bluez-5.44 folder)
cd test
sudo python test-discovery
Known issues
============
bluetoothctl sometimes shows "Waiting to connect to bluetoothd..." forever. Rebooting and restarting the bluetooth service seems to sometimes help.
Switch controller to BLE mode only
==================================
vim /etc/bluetooth/main.conf
and add this line:
ControllerMode = le
@Caravanvolumio
Copy link

Hi.
I have built a tiny music player & internet radio for my caravan.
Hardware is
Raspberry Pi Zero W
Hifi Berry Dac Zero
Guittarreria.com case
128Gb USB pen holding my complete music Lib (converted to MP3)

Software is volumio-2.141

It all works well, connected from the DAC to the Aux In on the Caravan Radio.
I also have a Studio Series Bluetooth speaker and I'd like to stream to it. To have music outside the van.

Using phweyland's excellent instructions @ volumio-bluez-alsa-a2dp-bluetooth-support-t6130.html I have got Bluetooth working.
His build allows the Pi Zero to act like a Bluetooth speaker. I can connect it to an Ipad and stream music via the Pi to the DAC wired output. I can getthe Pi to pair & trust the BT speaker, but I can't get a connection.
phweyland suggested "The path you want to follow is more like:
Volumio -> alsa -> bluez 5 -> Bluetooth controller (on pi) -> Bluetooth Headset.
On https://github.com/Arkq/bluez-alsa you will find instruction for that"

I have been trying for weeks, without success to get this working.
I have now followed your build to install Bluez 5.43
I have to start with the Volumio - jessie image, so not the same as your jessie lite/
So I started by installing the following

sudo apt-get install build-essential (to have make & config tools?)
sudo apt-get install xarchiver (to use Zip/UnZip)
sudo apt-get install raspberrypi-sys-mods (added 08_05_2017 – to resolve sudo /usr issue)

The build has worked up to the end of

  • Attach Bluetooth controller on RPi 3 once, line 57
    Now I'm stumped with
  • Attach Bluetooth controller on RPi 3 automatically on system start
    62 #TBD:
    63 #sudo /usr/bin/hciattach /dev/ttyAMA0 bcm43xx 921600 noflow -
    64 #sudo hciconfig hci0 up
    With my limited knowledge, It looks the same as what has just been done?

I have cloned an Image up to & including Line 57.

Could you help me understand and make the correct steps to Attach Bluetooth controller on RPi 3 automatically on system start?
Thanks for looking
Roger

@larsblumberg
Copy link
Author

I updated the Gist with changed installation instructions – can you check if it's now working for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment