Raspberry pi broadcom bluetooth

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

clopresti/rpi-bluetooth

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Using Bluetooth With The Raspberry Pi

The following instructions show how to setup and use a USB Bluetooth adapter with the Raspberry Pi. Please note that these instructions only apply to the latest Raspbian Jessie distribution. If you are using a different distribution or an older Raspbian build such as Wheezy some of the instructions will need to be changed as the Bluetooth stack and utilities have changed with the Jessie release and BlueZ 5.23.

A lot of the instructions I found online were relating to the older wheezy builds and it took some extra time to find the correct way to do things with Jessie. There were also a few configuration changes that needed to be made in order to work around some known issues/bugs relating to the RFCOMM (serial over Bluetooth) communication on the Pi. I have documented all this and hopefully I can save you some time if you are trying to do a similar things.

I am using a USB Bluetooth 4.0 adapter with a Broadcom BCM20702 chipset but there are many other supported Bluetooth adapters including those with CSR (Cambridge Silicon Radio) chipsets. I tested on a Raspberry Pi 2 but all this should work with any version of the Raspberry Pi as long as you are running the latest Raspbian Jessie distribution.

First make sure your Pi is up to date:

> sudo apt-get update > sudo apt-get upgrade > sudo rpi-update > sudo reboot 

Insert your USB Bluetooth adapter into one of the USB ports on the Pi and enter:

You should see output similar to the following:

Читайте также:  Bluetooth hfp hsp profiles

If you used an adapter with a different chipset like CSR you might see ‘Cambridge Silicon Radio’ insead of ‘Broadcom Corp’. If you do not see something similar to this it might mean that there is something wrong with your adapter or it is not recognized/supported.

Next install the bluez and bluetooth manager packages:

> sudo apt-get install bluetooth blueman bluez python-gobject python-gobject-2 

Now you can check you your adapter state:

You should see output similar to the following:

BD Address: XX:XX:XX:XX:XX:XX UP RUNNING PSCAN ISCAN 

The [XX:XX:XX:XX:XX:XX] part is the MAC address of your Bluetooth adapter If you do not see «UP RUNNING» enter the following to turn on Bluetooth:

Part 2. Paring and Connecting Devices

Start the command line Bluetooth manager

You should see a line similar to:

Controller XX:XX:XX:XX:XX:XX raspberrypi [default] 

‘raspberrypi’ is the default name you will see when pairing/connecting to the Pi from other devices

Источник

Connect Bluetooth Headset To Raspberry Pi 3 (A2DP and HSP)

In this post I’ll explain how to connect your Raspberry Pi 3 to a Bluetooth headset. It includes A2DP and HSP profiles.

Connect Bluetooth Headset To Raspberry Pi 3 (A2DP and HSP)

Things used in this project

Hardware components

Software apps and online services

Story

If you are here, it means that you are trying to use your headset’s microphone AND speakers with Raspberry Pi 3.

What appeared to be a configuration issue turned into to a real headache. After so many weekends spent to find a solution, I ended up with a lot of information and no workaround — a sort of series of puzzle pieces that I’m still collecting over all the Google results. I’m not exaggerating if I tell you that I already read every single page that Google can propose for this topic.

With all that effort, I start to have a clear idea of the problem. So here you will save your time and focus on the major root cause.

Long story short: The real problem comes from the built-in WiFi-Bluetooth chipset: BCM43438 (and/or its driver/firmware)

How do I know? Because I used an external Bluetooth transceiver (USB dongle), and now my headset works perfectly (AD2P & HSP). So, unless I find THE ideal solution, you have no choice but to use a Bluetooth USB dongle.

I know that some people may just want to know how to do it, and don’t care about details, so I’ll explain first how to make it. Then I’ll post the exhaustive story behind this Bluetooth/Raspberry Pi issue, in order to help others who want to explore more.

One problem that is mentioned everywhere is the drop out of Bluetooth support by ALSA. Now only way is PulseAudio. Source: https://git.kernel.org/pub/scm/bluetooth/bluez.git/commit/?id=4ff9b99292eca193dc0c149722328cb0b1ab0818

Minimal versions needed for HSP (A2DP included) are: Bluez 5 / PulseAudio 6 Source: https://www.freedesktop.org/wiki/Software/PulseAudio/Notes/6.0/

I recommend starting with a fresh Raspbian Jessie image: https://www.raspberrypi.org/downloads/raspbian/

sudo apt-get update sudo apt-get upgrade sudo apt-get autoremove sudo reboot 

Check the version of packages:

dpkg -l bluez dpkg -l pulseaudio 

Purge pre-installed PulseAudio:

sudo apt-get purge pulseaudio 

To install manually PulseAudio 6 or higher, there are two methods and both of them are OK.

Читайте также:  Lenovo ideapad g710 bluetooth

Method 1: Install PulseAudio from Debian Backports

sudo nano /etc/apt/sources.list 
deb http://ftp.debian.org/debian jessie-backports main 

Add PGP keys to your Raspberry Pi:

gpg --keyserver pgpkeys.mit.edu --recv-key 8B48AD6246925553 gpg --keyserver pgpkeys.mit.edu --recv-key 7638D0442B90D010 gpg -a --export 8B48AD6246925553 | sudo apt-key add -- gpg -a --export 7638D0442B90D010 | sudo apt-key add -- 

Install PulseAudio and its Bluetooth module:

sudo apt-get -t jessie-backports install pulseaudio pulseaudio-module-bluetooth 

Check the version (6 or higher is OK):

dpkg -l pulseaudio pulseaudio-module-bluetooth ii pulseaudio 7.1-2~bpo8+1 ii pulseaudio-module-blue 7.1-2~bpo8+1 

You can jump directly to Step 2.

Method 2: Use PulseAudio sources

Download the sources from Freedesktop.org:

wget https://freedesktop.org/software/pulseaudio/releases/pulseaudio-6.0.tar.xz 

Unzip and go to the directory:

tar xvf pulseaudio-6.0.tar.xz 

I will sum up here all the errors I encountered (in case people search them by copy/paste):

./bootstrap.sh: line 46: intltoolize: command not found 

So install all of the following libraries:

sudo apt-get install intltool libtool libcap-dev libjson0-dev libsndfile1-dev 

The script should now end correctly, and in the command line you can see a table of the configuration done with enabled/disabled parts. On my side: udev, bluez5, ofono, native-headset, alsa, X11, systemd, … were not enabled, so I installed additional libraries:

sudo apt-get install libudev-dev libsbc-dev libbluetooth-dev libx11-xcb-dev libasound2-dev libsystemd-dev libsamplerate0-dev 

Re-do the ./ bootstrap , now missing parts are enabled.

Then, make and install PulseAudio (this will take some time, grab a coffee).

The last command to avoid errors of shared libs not found.

Step 2: Bluetooth Hardware

To turn off built-in Bluetooth controller (BCM43438), blacklist it:

sudo nano /etc/modprobe.d/raspi-blacklist.conf 
blacklist btbcm blacklist hci_uart 

CTRL+X, then Y, then Enter. Reboot:

Now connect your Bluetooth USB dongle, mine is ASUS BT400. At this step, the result may differ, maybe your USB dongle is already supported by Raspbian.

For ASUS BT-400, I have to install manually the firmware. To know if your hardware is correctly called, check it here:

In my case, I see the error:

[ 155.924366] bluetooth hci0: Direct firmware load for brcm/BCM20702A1-0b05-17cb.hcd failed with error -2 

Here I need to explain some things. The chipset in the USB dongle is from Broadcom (BCM). Broadcom’s firmwares are proprietary, which means that they aren’t shared as open source and sometimes are not in Linux repositories. So to use it, you have to find the corresponding .hcd file and store it in /lib/firmware folder.

An easy way is to download ASUS drivers online:

wget http://dlcdnet.asus.com/pub/ASUS/wireless/USB-BT400/UT_USB_BT400_6516000.zip -P /home/pi/Downloads/ 

Open .inf file of the drivers and look for ASUS

cd BTW6.5.1.6000_Win7_USB_ASUS/Win32/ cat bcbtums-win7x86-brcm.inf 

Search for the driver supporting your hardware. For ASUS BT400, I find the corresponding file: BCM20702A1_001.002.014.1315.1347.hex

Because it is .hex, I need to convert it to .hcd. I’ll use the hex2hcd tool:

Here I meet error due to Raspberry Pi configuration

gcc -O2 -march=native hex2hcd.c -o hex2hcd *** Error in `gcc’: double free or corruption (top): 0x015fdc58 *** : recipe for target ‘hex2hcd’ failed make: *** [hex2hcd] Aborted 
CFLAGS = -O2 -march=native By CFLAGS = -mcpu=cortex-a53 -mfpu=neon-vfpv4 

Redo make command. Now you have the executable hex2hcd:

cp /home/pi/Downloads/BTW6.5.1.6000_Win7_USB_ASUS/Win32/BCM20702A1_001.002.014.1315.1347.hex /home/pi/Desktop/hex2hcd/ ./hex2hcd BCM20702A1_001.002.014.1315.1347.hex BCM20702A1-0b05-17cb.hcd 

Pay attention here to the name of the .hcd file — it is the same one missing in the above error with:

Читайте также:  Bluetooth share на планшет

Copy it to the firmware folder, reboot, and check Bluetooth initiation:

sudo cp BCM20702A1-0b05-17cb.hcd /lib/firmware/brcm/ sudo reboot dmesg | grep -i bluetooth 

The firmware should be correctly called now!

Now we will connect the Bluetooth headset (same steps as for A2DP only post)

Start Bluetoothctl tool and initiate everything:

Turn on the headset, for mine I press and hold the button till I see a white blinking LED. Start the scan:

After some seconds, you will see the headset name and MAC address (xx:xx:xx:xx:xx:xx)

Pair, trust and connect it:

Now the headset is correctly connected to the Raspberry Pi. If not, it should be PulseAudio daemon that it is not already running. Open new console and start it:

Go back to the other console and connect again the headset:

Now the headset is connected!

Check cards in PulseAudio:

You can see the Bluetooth card and the profiles A2DP and HSP available. For me the default profile was headset_head_unit, if it is not for you, force it:

pacmd set-card-profile 1 headset_head_unit 

Tell PulseAudio to use the headset as default “sink” and “source”:

pacmd set-default-sink bluez_sink.xx_xx_xx_xx_xx_xx 

Record yourself with the microphone:

CTRL+C to end it. Play it back:

Are you listening to your voice?! Final check that A2DP is also working, activate it:

pacmd set-card-profile 1 a2dp_sink paplay -v 

Your voice again, that’s all. This tutorial will for work for any Bluetooth USB dongle that you can find the ASUS driver sources. If you have any question or remark, feel free to ask me by comment.

Why Raspberry Pi-Bluetooth does not work

This part is ongoing because everyday I’m learning new things about Bluetooth profiles, hardware architecture, IP issues, etc.

The aim here is not to blame the Raspberry Pi, but to understand why it is NOT working and how to correct it. Because at the of the day we want to do it by the board only without external add-ons. Until this, I recommend using Bluetooth USB dongles if you want to have HSP profile.

Some quick notes and questions:

  • Raspberry Pi uses Broadcom BCM43438 “combo” shipset for Wi-Fi and Bluetooth
  • Broadcom firmwares are proprietary, not all the time coming with Linux distributions
  • Apparently, BCM43438 firmware is the same as BCM43430 (but how to be sure…)
  • People report that the use of Wi-Fi & Bluetooth leads to poor audio quality and slow connection
  • Raspberry Pi Zero W will have the same problem (same BCM 43438)
  • What is the architecture of Raspberry Pi wireless? (I know it is not open source.)
  • What are the buses and protocols used (HCI, UART, SCO, SDIO, …)?
  • Did anyone checked that Bluetooth audio will work before agreeing to use this hardware at the Raspberry Pi Foundation?
  • Why is the BCM43438 not mentioned on the Raspberry Pi hardware list (on the website)?

Источник

Оцените статью
Adblock
detector