Repository navigation
Open
Labels
Bluetooth Issuepelwell_there_is_no_escapeWaiting for external inputWaiting for a comment from the originator of the issue, or a collaborator.
Description
Trying to use a bluetooth mic/speaker in a raspberry pi 3 (headless).
Hardware is Raspberry pi 3, firmware updated today, running raspbian also dist-upgraded today. Using bluez and pulseaudio (system service start mode).
- The device is trusted, paired and connects/disconnects without problems.
- When device is initially connected, "pactl list" shows the device is using the profile named "headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 20, available: yes)". With this profile, no sound (trying to play with aplay command).
- When profile is changed to "a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 10, available: yes)" (using command pactl set-card-profile), the sound is played correctly.
No error messages seen in any log file.
Moreover, if I "down" ("hciadmin hci0 down") the internal raspberry bluetooth controller and use instead an external bluetooth controller connected in an usb port, both modes works correctly. Thus, problem seems related with the bluetooth device in raspberry card.
These are result from some related commands.
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.9.56-v7+ #1044 SMP Fri Oct 13 15:23:13 BST 2017 armv7l GNU/Linux
pi@raspberrypi:~ $ hciconfig -a
hci0: Type: Primary Bus: UART
BD Address: B8:27:EB:7E:DA:2A ACL MTU: 1021:8 SCO MTU: 64:1
UP RUNNING
RX bytes:14641 acl:101 sco:0 events:1341 errors:0
TX bytes:2208546 acl:2358 sco:7 commands:97 errors:0
Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH SNIFF
Link mode: SLAVE ACCEPT
Name: 'raspberrypi'
Class: 0x0c0000
Service Classes: Rendering, Capturing
Device Class: Miscellaneous,
HCI Version: 4.1 (0x7) Revision: 0x145
LMP Version: 4.1 (0x7) Subversion: 0x2209
Manufacturer: Broadcom Corporation (15)
pi@raspberrypi:~ $ pactl list
...
Card #3
Name: bluez_card.E8_07_BF_11_10_A0
Driver: module-bluez5-device.c
Owner Module: 15
Properties:
device.description = "SPUBT710"
device.string = "E8:07:BF:11:10:A0"
device.api = "bluez"
device.class = "sound"
device.bus = "bluetooth"
device.form_factor = "speaker"
bluez.path = "/org/bluez/hci0/dev_E8_07_BF_11_10_A0"
bluez.class = "0x240414"
bluez.alias = "SPUBT710"
device.icon_name = "audio-speakers-bluetooth"
Profiles:
headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 20, available: yes)
a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 10, available: yes)
off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
Active Profile: headset_head_unit
Ports:
speaker-output: Speaker (priority: 0, latency offset: 0 usec)
Part of profile(s): headset_head_unit, a2dp_sink
speaker-input: Bluetooth Input (priority: 0, latency offset: 0 usec)
Part of profile(s): headset_head_unit
# systemctl status bluetooth
● bluetooth.service - Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2017-10-14 15:49:16 UTC; 36min ago
Docs: man:bluetoothd(8)
Main PID: 461 (bluetoothd)
Status: "Running"
CGroup: /system.slice/bluetooth.service
└─461 /usr/lib/bluetooth/bluetoothd
Oct 14 15:49:16 raspberrypi bluetoothd[461]: Bluetooth daemon 5.43
Oct 14 15:49:16 raspberrypi systemd[1]: Started Bluetooth service.
Oct 14 15:49:16 raspberrypi bluetoothd[461]: Starting SDP server
Oct 14 15:49:16 raspberrypi bluetoothd[461]: Bluetooth management interface 1.14 initialized
Oct 14 15:49:16 raspberrypi bluetoothd[461]: Failed to obtain handles for "Service Changed" characteristic
Oct 14 15:49:16 raspberrypi bluetoothd[461]: Sap driver initialization failed.
Oct 14 15:49:16 raspberrypi bluetoothd[461]: sap-server: Operation not permitted (1)
Oct 14 15:49:16 raspberrypi bluetoothd[461]: Endpoint registered: sender=:1.3 path=/MediaEndpoint/A2DPSource
Oct 14 15:49:16 raspberrypi bluetoothd[461]: Endpoint registered: sender=:1.3 path=/MediaEndpoint/A2DPSink
Oct 14 15:55:04 raspberrypi bluetoothd[461]: /org/bluez/hci0/dev_E8_07_BF_11_10_A0/fd0: fd(24) ready
systemctl status pulseaudio
● pulseaudio.service - Pulse Audio
Loaded: loaded (/etc/systemd/system/pulseaudio.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2017-10-14 15:49:12 UTC; 36min ago
Main PID: 343 (pulseaudio)
CGroup: /system.slice/pulseaudio.service
└─343 /usr/bin/pulseaudio --system --disallow-exit --disable-shm --exit-idle-time=-1
Oct 14 15:49:12 raspberrypi pulseaudio[343]: W: [pulseaudio] main.c: OK, so you are running PA in system mode. Please make sure that you actually do want to do that.
Oct 14 15:49:12 raspberrypi pulseaudio[343]: W: [pulseaudio] main.c: Please read http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/WhatIsWrongWithSystemWide/ for an explanation why system mode is usually a bad idea.
Oct 14 15:49:12 raspberrypi pulseaudio[343]: W: [pulseaudio] authkey.c: Failed to open cookie file '/var/run/pulse/.config/pulse/cookie': No such file or directory
Oct 14 15:49:12 raspberrypi pulseaudio[343]: W: [pulseaudio] authkey.c: Failed to load authentication key '/var/run/pulse/.config/pulse/cookie': No such file or directory
Oct 14 15:49:12 raspberrypi pulseaudio[343]: W: [pulseaudio] authkey.c: Failed to open cookie file '/var/run/pulse/.pulse-cookie': No such file or directory
Oct 14 15:49:12 raspberrypi pulseaudio[343]: W: [pulseaudio] authkey.c: Failed to load authentication key '/var/run/pulse/.pulse-cookie': No such file or directory
Oct 14 15:49:16 raspberrypi pulseaudio[343]: E: [pulseaudio] bluez5-util.c: Found duplicated D-Bus path for adapter /org/bluez/hci0
Oct 14 15:49:16 raspberrypi pulseaudio[343]: E: [pulseaudio] bluez5-util.c: Found duplicated D-Bus path for device /org/bluez/hci0/dev_E8_07_BF_11_10_A0
Metadata
Metadata
Assignees
Labels
Bluetooth Issuepelwell_there_is_no_escapeWaiting for external inputWaiting for a comment from the originator of the issue, or a collaborator.
Activity
pratham2003 commentedon Nov 8, 2017
I'm facing the same issue too
Pillar1989 commentedon Nov 22, 2017
I'm facing the same issue too
JamesH65 commentedon Dec 5, 2017
Would it be possible for commenters to try the latest kernel (4.14) and see if the problems persists? Note, this is a testing branch, so should not be done on a critical system unless it's well backed up!
sudo BRANCH=next rpi-update
pelwell commentedon Dec 5, 2017
It's not a kernel issue - it's a BlueZ limitation. As of version 5.0, BlueZ does not support HFP or HSP, only A2DP. I've not found an official explanation from BlueZ, but there are some notes from the PulseAudio devs here: https://www.freedesktop.org/wiki/Software/PulseAudio/Notes/5.0/
If anyone knows of a solution that doesn't involve installing BlueZ 4 as well I'll be interested to hear it.
viktorgino commentedon Dec 5, 2017
To get HFP/HSP working properly you'll need PulseAudio 11 https://www.freedesktop.org/wiki/Software/PulseAudio/Notes/11.0/
HFP works using ofono, but it is only started fully working with version PA version 11.
@SoloVeniaASaludar can you try to install lates versions of PA, bluez and ofono and report back?
bluetiger9 commentedon Jan 21, 2018
Seems that, we have a solution to use the HSP profile with Raspberry Pi 3’s built in BCM43438 chip. The culprit was the so called SCO audio routing. HSP / HFP uses SCO audio packets to transmit audio and in order to make PulseAudio work the packets must be routed to the HCI interface. This can be done by sending the the following HCI command:
After issuing this command, both
paplayandparecordshould work with the HSP profile.More details here:
https://www.spinics.net/lists/linux-bluetooth/msg73883.html
https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Bluetooth/#index8h3
http://youness.net/raspberry-pi/bluetooth-headset-raspberry-pi-3-ad2p-hsp#comment-2484
pelwell commentedon Jan 23, 2018
Ooh, interesting. That hci command that could easily be added to the Pi-specific script /usr/bin/btuart if it solves the problem.
YOUN3SS commentedon Feb 8, 2018
Hi,
I confirm that this command solves the problem.
More details: How To Connect Bluetooth Headset Or Speaker To Raspberry Pi 3
kp339 commentedon Apr 10, 2018
Hi,
hcitool cmd can solve the connect problem in HSP/HFP mode, but the sound is terrible, have distortion.
Do anyone have the same problem as I do?
Thanks!
bluetiger9 commentedon Apr 10, 2018
@kp339, the sound is a little noisy for me too. I contacted the Cypress's support, their FW team is checking the CYW43438's firmware right now.
kp339 commentedon Apr 10, 2018
@bluetiger9 If there is any progress, please let me know. Thanks!
CliveWongTohSoon commentedon May 17, 2018
It happens to me too, the sound is too distorted until the speech recognition can't even work. Please let me know how to improve the sound quality.
bluetiger9 commentedon May 23, 2018
The problem was identified as a timing issue in PulseAudio.
In an nutshell, PulseAudio uses a hard-coded (e)SCO packet size of 48 bytes, instead of using the packet size negotiated at the eSCO connect (ex 60 bytes). The timing logic used for SCO connections, is to send (e)SCO packets (one at a time), at each SCO packet received. If the negotiated packet size is bigger (ex 60 bytes) than the hard-coded 48 bytes, the SCO packets are received at a lower rate, which causes PulseAudio to send the SCO packets way too slow.
More details on the following [pulseaudio-discuss] thread:
[pulseaudio-discuss] Bluetooth - HSP / HFP - source based timing & hard-coded MTU causes SCO packets to be badly delayed
As a workaround PulseAudio 11.1 can be used, with the
module-bluetooth-discoverstarted withautodetect_mtu=yesparameter. The parameter can be set in/etc/pulse/default.pa:(note: be aware that this setting breaks the compatibility with some adapters)
The PulseAudio 11.1 is not yet available for Raspbian, but it can be compiled from source:
Cheers,
Attila
kp339 commentedon May 24, 2018
Yeah, and if your PulseAudio's version lower than 11.1, you can try this way:
If you want to fit more devices, you can modify the code refer to the 11.1 source.
Rebuild the pulseaudio source code and replace the libbluez5-util.so in system:
$ sudo cp ./src/.libs/libbluez5-util.so /usr/lib/pulse-x.x/modules
Reboot the system
And from the test I found that before you connect your headset, you should enter HCI command first or you will find that your headset profile "headset_head_unit" available is no.
Thanks Attila.
55 remaining items
pelwell commentedon Nov 1, 2019
@aurelihein I have audio playing over HSP/HFP now. In order for it to work properly I had to follow this guide: https://hackaday.io/project/165208-an-old-rotary-phone-as-bluetooth-set/log/162491-setting-up-the-bluetooth
I started from a clean Raspbian install. Pairing and audio device selection can be done using the standard Raspbian Bluetooth tool (but note that starting pulseaudio will require the audio device is reselected, and I found I usually had to do it twice for it to work (there is a beep on connection, and I only got that on the second attempt).
There are one or two steps missing from the guide:
sudo systemctl enable --now ofonowill start it immediately and at every boot.pulseaudio --startshould do it.If you don't edit default.pa it will use a2dp. If you don't patch pulseaudio with the correct mtu size it will sound strangely slowed down. If you don't start pulseaudio then when you play a sound it will try, then switch back to another output (HDMI for me).
Note that this assumes you are running Raspbian, which has the magic hcitool command in /usr/bin/bthelper. Without that (and if the headset has been powered off since it was last run) you'll get no sound.
aurelihein commentedon Nov 4, 2019
Nope it does not work ! They are talking about Rpi zero !
I am talking about Rpi4 !! bthelper doesn't handle Rpi4 yet !
pelwell commentedon Nov 4, 2019
I was testing on a convenient 3B+ which runs the same firmware on the same hardware. The crucial difference is that the 3B+ doesn't have a MAC address from the new dc:a6:32 OUI. The bthelper command needs to be updated to also recognise the new OUI and apply the same patch. An offline task is then to figure out why the HCI cmd is necessary, given that according to Cypress this should be the default.
Try replacing the hciconfig ... grep ... line with:
bthelper: Recognise Pi 4 OUI
pelwell commentedon Nov 4, 2019
See RPi-Distro/pi-bluetooth#10.
bthelper: Recognise Pi 4 OUI (#10)
pelwell commentedon Nov 11, 2019
Forget my previous post and try this instead:
profile "a2dp"toprofile "sco". This will be deleted when you disconnect the headset, but for now this is a proof of concept.arecord test.wavand speak into the microphone, ending with Ctrl-C. Thenaplay test.wavto replay your recording.If this works for you then it shows there's nothing fundamentally wrong with the Bluetooth modem and its HSP handling.
pelwell commentedon Nov 11, 2019
To summarise my findings so far:
It isn't clear to me why anyone would want to use HSP for output when A2DP is available, which leads me to ask:
i. Do items 1-3 above cover all the issues?
ii. If 3 is useful, would it help if the plugin was altered to allow such a connection without the need to manually edit .asoundrc, e.g. by provided two different connection modes?
iii. If the above doesn't resolve your problems, describe your use case and where it fails.
StuartIanNaylor commentedon Feb 27, 2020
Anyone know how to get this working as doesn't seem to be.
Also if you want HSP then if *imtu should be 48/60/64?
https://hackaday.io/project/165208-an-old-rotary-phone-as-bluetooth-set/log/162491-setting-up-the-bluetooth
Confused.com but in the latest 2020-02-05 a bluetooth speaker/mic does not seem to work?
Im PA11.0 MTA is now set in the kernel for PA.
So the kernel should have a MTU config of 64?
There are a ton of devices that use HSP and since 1.6 HSP has been wideband audio it was just pulseaudio and settings that make HSP bad not HSP.
The devices are not OS configurable and firmware and HSP is likely to continue and the same questions are being asked on the Ubuntu bugzilla as why on Ubuntu does HSP sound so bad when you plug into other OS it sounds great.
Ubuntu is the same but other distros and win or android HSP is 16Khz great quality plug it into a Pi and not because of the MTU and not using ofono with pulseaudio
I am not even sure if PA12 works with HSF/HSP as even with a bluetoothdongle/headset I can not switch profile.
In PA12 they swapped the priority with A2DP & HSF/HSP because it would 'stick' in HSF/HSP profile but now the opisite happens but rather than lower quality on headphones you now get headsets that are now only headphone only.
Seems Arch and Ubuntu are the same and maybe its just me but PA12/Bluetooth seems to be broken for HSF/HSP
Also if you go the bluealsa route for some reason bluealsa is compiled with
So disabling internal bluealsa support which would seem contary in terms of bloat to the rational of opting for bluealsa
E500E commentedon Jun 17, 2020
Thank you @bluetiger9 and @kp339 ---- With your clues I was able to solve the metallic garbled noises by recompiling pulseaudio --- thanks so much!
However I seem to be stuck on the next step - getting echo cancellation to work.
I am trying to use my pi0w as a bluetooth HFP set. Meaning my phone connects via bluetooth to the pi0w. The pi0w has a speaker and a microphone (via a USB audio adapter) and the goal is that I conduct my telephone call with the speaker/microphone.
The problem is that I can place calls and hear the other call participant clearly as well as speak, but I just cannot get the echo cancellation module to work I have tried these combos to no avail:
What happens is that I place the call, the conversation starts, and the other call participant has a devil of a time in the call because he/she can hear himself/herself. No doubt it is because of echo from the other participant speaking, getting played out of my pi's speaker, then picked up by my pi's microphone, and then fed back through the call.
First I tried putting this in /etc/pulse/default.pa
load-module module-echo-cancel aec_method=webrtcBut that didn't work at all. Then, instead of putting that line inside the file, tried to manually load the echo cancel module on the shell:
pactl load-module module-echo-cancelwhich just seems to crash pulseaudio every time. You can see the results of pulseaudio -v -v -v below --- the last two lines show the attempted load and "Illegal Instruction" and then pulseaudio quits.
This happens on both Buster and Stretch, and happens whether or not I use the sudo apt-get install pulseaudio pulseaudio-module-bluetooth -y command to get a "standard" version of pulse audio, or if I compile my own version of pulseaudio (to solve for metallic / robotic / garbled noises.
Any advice would be appreciated. Thanks.
ciaranj commentedon Aug 31, 2022
Just went through this process (loosely following this guide) on an RPi 3B+, no bluetooth dongle, all onboard kit with wifi enabled.
Raspbian Bullseye which was shipping PulseAudio 14.2.
I needed to make the changes suggested above by @kp339 (MTU from 48->64) in order to significantly reduce the garbled sound, which works a treat. (Even with the auto_detect_mtu module parameter specified.)
As the codebase has moved on from 11.1 -> 14.2, I've included an updated diff in case it helps others.
shubhamfuloria commentedon Sep 29, 2025
I faced a similar problem with the Raspberry Pi Zero 2W, which has a Bluetooth chip (BCM43430) similar to the Raspberry Pi 3’s (BCM43438). Running the HCI command
seems to fix the no-audio issue, but after 2-3 minutes into a call, the Bluetooth connection disconnects from the Pi. Any help or suggestions would be greatly appreciated!
HennriCortez commentedon Nov 17, 2025
ayo, you fixed it?