Adding a Bluetooth Device to Sandpiper Linux
This guide explains how to connect a Bluetooth device (such as a keyboard, mouse, or speaker) to the Sandpiper Linux environment running on the Smart Zynq SP board.
Hardware Requirements
- Sandpiper system running Petalinux with Bluetooth module enabled
- Compatible Bluetooth adapter (tested with Broadcom BCM20702A0 BT4 adapter)
- Bluetooth device to connect (keyboard, mouse, speaker, etc.)
Checking Bluetooth Availability
First, verify that Bluetooth is available and the adapter is detected:
lsusb
# Look for a Bluetooth adapter in the output
hciconfig -a
# Should show your Bluetooth adapter (typically hci0)
Note: If no Bluetooth adapter is detected, ensure your USB Bluetooth adapter is properly connected, or verify that the Bluetooth kernel modules are loaded with lsmod | grep bt.
Enabling Bluetooth
Enable the Bluetooth adapter:
sudo hciconfig hci0 up
Scanning for Devices
Scan for nearby Bluetooth devices:
hcitool scan
This will return a list of devices with their MAC addresses and names:
Scanning ...
00:11:22:33:44:55 MyBluetoothDevice
Paring and Connecting
Use bluetoothctl for a more interactive pairing process:
bluetoothctl
# Start the Bluetooth control interface
[bluetooth]# power on
# Power on the Bluetooth adapter
[bluetooth]# agent on
# Enable the default agent
[bluetooth]# default-agent
# Set the default agent
[bluetooth]# scan on
# Start scanning for devices
# Wait for your device to appear in the scan results, then:
[bluetooth]# pair [MAC_ADDRESS]
# Example: pair 00:11:22:33:44:55
# You may be prompted to confirm a passkey or enter a PIN (commonly '0000' or '1234')
[bluetooth]# trust [MAC_ADDRESS]
# Trust the device for automatic reconnection
[bluetooth]# connect [MAC_ADDRESS]
# Connect to the device
# Exit when done:
[bluetooth]# quit
Troubleshooting: If pairing fails, ensure your Bluetooth device is in pairing mode and discoverable. Some devices may require a specific PIN. Check dmesg output for any Bluetooth-related errors.
Connecting Audio Devices
For Bluetooth audio devices (headphones, speakers), you may need to install and configure BlueZ and PulseAudio:
# Install BlueZ and PulseAudio modules if not already installed
apt-get install bluez pulseaudio-module-bluetooth
# After connecting the device, you may need to set it as the audio sink:
pactl set-default-sink [sink_name]
Connecting Input Devices
Bluetooth keyboards and mice should work automatically once paired and connected, as they use the HID (Human Interface Device) profile. The device will appear as a standard input device in Linux.
Automatic Reconnection
Once a device is trusted, it should automatically reconnect when powered on and within range. If automatic reconnection fails, ensure the device is not blocked:
bluetoothctl
[bluetooth]# devices
# List all paired devices
[bluetooth]# connect [MAC_ADDRESS]
# Manually connect to a device
Testing Your Connection
Verify the connection is working by testing your device:
- Keyboard: Type on the keyboard to verify input
- Mouse: Move the cursor and click to verify movement and button presses
- Audio: Play a sound to verify audio output
Resources
- ArchWiki Bluetooth Guide - Comprehensive Bluetooth documentation
- BlueZ Documentation - Linux Bluetooth protocol stack
- Sandpiper OS Build Configuration - Includes Bluetooth kernel module configurations