Bluez 5.46 hciuart configuration changes

Update; 2017-08-13 Sunday
I discovered the problem is really in the tools/hciattach_bcm43xx.c file
I have now uploaded a patch to the git repo.

1. The speed cannot be set before the fiimware is uploaded

2. Wait 1 second before the reset command is sent.

Patch information;

git diff tools/hciattach_bcm43xx.c
diff –git a/tools/hciattach_bcm43xx.c b/tools/hciattach_bcm43xx.c
index 81f38cb..13a877c 100644
— a/tools/hciattach_bcm43xx.c
+++ b/tools/hciattach_bcm43xx.c
@@ -43,7 +43,7 @@
#include “hciattach.h”
-#define FIRMWARE_DIR “/etc/firmware”
+#define FIRMWARE_DIR “/lib/firmware”
#define FW_EXT “.hcd”
@@ -368,8 +368,6 @@ int bcm43xx_init(int fd, int def_speed, int speed, struct termios *ti,
if (bcm43xx_locate_patch(FIRMWARE_DIR, chip_name, fw_path)) {
fprintf(stderr, “Patch not found, continue anyway\n”);
} else {
– if (bcm43xx_set_speed(fd, ti, speed))
– return -1;
if (bcm43xx_load_firmware(fd, fw_path))
return -1;
@@ -380,6 +378,7 @@ int bcm43xx_init(int fd, int def_speed, int speed, struct termios *ti,
return -1;
+ sleep(1);
if (bcm43xx_reset(fd))
return -1;

Nikolay patch; This has the binary file in it hciattach you can just replace yours with..

Nikolay solution Is here;

Nikolay (2xl) wrote on 2017-04-04:
I did the same patch – modify firmware patch and speed initialization patch… and I got bluetooth working on RPi!

############################## older information

When you upgrade to the latest bluez 5.46-1 everything will work as of 2017-08-12.

goal;  that firmware simply loads on boot and bluetooth works.

Indications that firmware loading failed;
   the mac address is all AA’s

(no output)
hci0: Type: Primary Bus: UART
BD Address:  AA:AA:AA:AA:AA:AA ACL MTU: 1021:8 SCO MTU: 64:1
RX bytes:2095 acl:0 sco:0 events:118 errors:0
TX bytes:1974 acl:0 sco:0 commands:118 errors:0

How does it work to update bluez-5.46 then later not?

The Chip still has its firmware uploaded, until you reboot. Then the firmware needs to be reloaded.  And there is the change;

/etc/firmware is expected location from hciattach
BCM43430A1.hcd << one file needed

/var/firmware is where all the RPI’s firmware is located.
/var/firmware/BCM43430A1.hcd << cp this

mkdir /etc/firmware
cp /var/firmware/BCM43430A1.hcd /etc/firmware


Other related files;


My final analysis in retrospect;
The bluez 5.23 package that is in Jessie has an edit not part of the patches in tools/hciuart_bcm43xx.c, and this lead to a missed non working update to 5.46.  All is working in the 5.46-1 release.

Bluez 5.46 And BLE quick test

Once you have upgraded to Bluez 5.46 from the previous post;

You can perform a quick BLE test with this file

To start your BLE adventure;
sudo hciconfig hci0 leadv 0 #this sets LE advertising on and as ‘connectable’
./gatt-service #starts the service

The source for gatt-service;
inside the bluez/tools folder is all the source you need to get started with your own Linux BLE Applet.

How can I view the BLE service?
there are lots of BLE exploring apps, I happen to use the “LightBlue” App on my iPhone.

Build Bluez 5.46 yourself for your Debian Jessie RPI3

Updated on 2017-08-13 Sunday – all working with 5.46-1 on RPI3.
All patches that were included as part of ‘stretch’ deb source Bluez 5.43 are now in 5.46-1

You can git the source package contents here;
git clone


Pre-built packages ready to install;

Why would you want to do this?
-To get the latest BLE (Low Energy Features) of Bluez, its required.
-A lot of bug fixes were made since 5.23 that is available on RPI3 Jessie that are needed for BLE to work reliably.
-Using a debian package allows for a clean upgrade path. Files are guaranteed to upgrade as opposed to “make install” over a running bluetooth system which doesn’t work.
-Debian Stretch doesn’t include the latest bluez 5.46, it comes close but I found that (during May 2017) that BLE didn’t function correctly.

Note: This was built on a RPI3 with Jessie.

Steps are intentionally missing, you will need to make up the differences to get the new source into the old directory, update the changelog in the ./debian folders with dch -i and a few other things to get a new build.  My source package all this done for convenience.

How I made it;
#Activate src in /etc/apt/sources.list
vi /etc/apt/sources.list
# Uncomment line below then ‘apt-get update’ to enable ‘apt-get source’
deb-src jessie main contrib non-free rpi

sudo apt-get install ccache  #configure this is required! ie Add to Path!
sudo apt-get install build-essential devscripts lintian diffutils patch patchutils
cd /usr/src
apt-get source bluez
apt-get build-depend bluez

#grab a version from

cd bluez-5.23
#untar the source ball in the new directory


How to build it;
time dpkg-buildpackage -rfakeroot -uc -b

#On the RPI3 it takes about 15 minutes without ccache

real 5m48.312s << using ccache
user 4m0.350s
sys 0m24.680s

How to clean it;
dpkg-buildpackage -rfakeroot -Tclean

Find what bluez packages you have installed now;

pi@billspi3:/usr/src $ dpkg -l | egrep -e ‘^\||blue’

| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
ii bluej 3.1.7b all A simple but powerful Java IDE.
ii bluez 5.43-2 armhf Bluetooth tools and daemons
ii bluez-firmware 1.2-3+rpi1 all Firmware for Bluetooth devices
ii libbluetooth3:armhf 5.43-2 armhf Library to use the BlueZ Linux Bluetooth stack
ii pi-bluetooth 0.1.3 armhf Raspberry Pi 3 bluetooth
ii pulseaudio-module-bluetooth 5.0-13 armhf Bluetooth module for PulseAudio sound server


How to install only what you need;
sudo dpkg -i <package name>

#From the above list, you can see I only need bluez and libbluetooth3.
sudo dpkg -i bluez_5.46_armhf.deb libbluetooth3_5.46_armhf.deb