Raspberry Pi 3 - Setting Up Bluetooth: Difference between revisions

From Alpine Linux
m (Categorized: Installation)
(One intermediate revision by one other user not shown)
Line 1: Line 1:
The Raspberry Pi Bluetooth chip varies by model.


The Raspberry Pi 3 has bluetooth chip on the BCM2837 and it is connected to the hardware UART.
* Raspberry Pi 3 has BCM2837 connected to the hardware UART
* Raspberry Pi 3B+ has BCM4345C0 connected to the hardware UART
* Raspberry Pi Zero W has BCM43430A1 connected to the hardware UART


You can get bluetooth to work only if you are not using the UART for anything else.
You can get Bluetooth to work only if you are not using the UART (ttyAMA0) for anything else, for example serial console.
Recent versions of Alpine Linux for Raspberry Pi come with the required Broadcom firmware files.
If you need the UART for something else, you can use an USB Bluetooth adapter instead.


You'll need the bluez package
You'll need the bluez package
Line 8: Line 13:
{{cmd|apk add bluez}}
{{cmd|apk add bluez}}


Start the bluetooth deamon at boot. This should load the right modules when you next reboot.
The Bluetooth controller is not automatically discovered on the UART. Test attaching it and check that the controller is found


{{cmd|rc-update add bluetooth}}
{{cmd|btattach -B /dev/ttyAMA0 -P bcm -S 115200 -N &}}


We'll need the firmware from Broadcom. You'll have to look online for BCM43430A1.hcd to find $URL
{{cmd|/etc/init.d/bluetooth start}}


{{cmd|mount -o remount,rw /dev/mmcblk0p1
{{cmd|<nowiki>bluetoothctl list
Controller B8:27:EB:01:02:03 BlueZ 5.50 [default]
</nowiki>}}


wget $URL/BCM43430A1.hcd -O /media/mmcblk0p1/firmware/brcm/BCM43430A1.hcd}}
If the interface is discovered after the attach, you can make attaching persistent by uncommenting
the line next to "rpi bluetooth" in ''/etc/mdev.conf''


Next we need to stop the kernel using the device we want to attach to the bluetooth chip for as a console
Start the bluetooth deamon at boot. This should load the right modules when you next reboot.


{{cmd|<nowiki>remove "console=ttyAMA0,115200" from /media/mmcblk0p1/cmdline.txt</nowiki>
{{cmd|rc-update add bluetooth}}


lbu commit && reboot}}
{{cmd|lbu commit && reboot}}


After the reboot we attach the serial port to the bcm43xx
{{cmd|
hciattach /dev/ttyAMA0 bcm43xx 115200 noflow -
}}


The output from the hciattach above should be
The output from the btattach above should be


{{cmd|bcm43xx_init
{{cmd|Attaching Primary controller to /dev/ttyAMA0
Flash firmware /lib/firmware/brcm/BCM43430A1.hcd
Switched line discipline from 0 to 15
Set Controller UART speed to 115200 bit/s
Device index 0 attached
Device setup complete
}}
}}
Then it's a matter of doing what you normally do with your bluetooth stack. This should get you going:
{{cmd|hciconfig hci0 up
hcitool dev
hciconfig scan
bluetoothctl}}


Then it's a matter of doing what you normally do with your Bluetooth stack.


[[Category:Installation]]
[[Category:Installation]]
[[category: Raspberry]]

Revision as of 10:08, 25 October 2019

The Raspberry Pi Bluetooth chip varies by model.

  • Raspberry Pi 3 has BCM2837 connected to the hardware UART
  • Raspberry Pi 3B+ has BCM4345C0 connected to the hardware UART
  • Raspberry Pi Zero W has BCM43430A1 connected to the hardware UART

You can get Bluetooth to work only if you are not using the UART (ttyAMA0) for anything else, for example serial console. Recent versions of Alpine Linux for Raspberry Pi come with the required Broadcom firmware files. If you need the UART for something else, you can use an USB Bluetooth adapter instead.

You'll need the bluez package

apk add bluez

The Bluetooth controller is not automatically discovered on the UART. Test attaching it and check that the controller is found

btattach -B /dev/ttyAMA0 -P bcm -S 115200 -N &

/etc/init.d/bluetooth start

bluetoothctl list Controller B8:27:EB:01:02:03 BlueZ 5.50 [default]

If the interface is discovered after the attach, you can make attaching persistent by uncommenting the line next to "rpi bluetooth" in /etc/mdev.conf

Start the bluetooth deamon at boot. This should load the right modules when you next reboot.

rc-update add bluetooth

lbu commit && reboot


The output from the btattach above should be

Attaching Primary controller to /dev/ttyAMA0 Switched line discipline from 0 to 15 Device index 0 attached

Then it's a matter of doing what you normally do with your Bluetooth stack.