Raspberry Pi 3 - Setting Up Bluetooth: Difference between revisions

From Alpine Linux
m (Categorized: Installation)
m (Use pkg template.)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Merge|Raspberry Pi|or create subpages}}


The Raspberry Pi 3 has bluetooth chip on the BCM2837 and it is connected to the hardware UART.  
The Raspberry Pi Bluetooth chip varies by model.


You can get bluetooth to work only if you are not using the UART for anything else.
* 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
You'll need the bluez package


{{cmd|apk add bluez}}
{{cmd|# apk add {{pkg|bluez|arch=a*}}}}
 
The Bluetooth controller is not automatically discovered on the UART. Test attaching it and check that the controller is found:
 
{{cmd|$ btattach -B /dev/ttyAMA0 -P bcm -S 115200 -N &}}


Start the bluetooth deamon at boot. This should load the right modules when you next reboot.
{{cmd|# rc-service bluetooth start}}


{{cmd|rc-update add bluetooth}}
<p style="background-color:#f9f9f9; border:1px dashed #2f6fab; line-height:1.1em; padding:1em; font-family:monospace; font-size:10pt; white-space:pre; overflow:auto;"><span style="color:green;">~</span>'''$''' bluetoothctl list


We'll need the firmware from Broadcom. You'll have to look online for BCM43430A1.hcd to find $URL
Controller B8:27:EB:01:02:03 BlueZ 5.50 [default]
</p>


{{cmd|mount -o remount,rw /dev/mmcblk0p1
If the interface is discovered after the attach, you can make attaching persistent by uncommenting
the line next to <code>rpi bluetooth</code> in {{Path|/etc/mdev.conf}}.


wget $URL/BCM43430A1.hcd -O /media/mmcblk0p1/firmware/brcm/BCM43430A1.hcd}}
Start the Bluetooth daemon at boot:


Next we need to stop the kernel using the device we want to attach to the bluetooth chip for as a console
{{cmd|# rc-update add bluetooth}}


{{cmd|<nowiki>remove "console=ttyAMA0,115200" from /media/mmcblk0p1/cmdline.txt</nowiki>
{{cmd|# lbu commit && reboot}}


lbu commit && reboot}}


After the reboot we attach the serial port to the bcm43xx
The output from the <code>btattach</code> above should be


{{cmd|
Attaching Primary controller to /dev/ttyAMA0
hciattach /dev/ttyAMA0 bcm43xx 115200 noflow -
Switched line discipline from 0 to 15
}}
Device index 0 attached


The output from the hciattach above should be
Then it's a matter of doing what you normally do with your Bluetooth stack.


{{cmd|bcm43xx_init
== See also ==
Flash firmware /lib/firmware/brcm/BCM43430A1.hcd
Set Controller UART speed to 115200 bit/s
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}}


* [[Bluetooth]]


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

Latest revision as of 14:31, 10 January 2024

This material is proposed for merging ...

It should be merged with Raspberry Pi. or create subpages (Discuss)

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 &

# rc-service 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 daemon at boot:

# 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.

See also