System is failed to search any bluetooth device to get connected systemctl status bluetooth. Begin reading the Arch Wiki article on bluetooth. Machine: Type: Laptop System: LENOVO product: 20207 v: Lenovo B490 serial. Connecting a Bluetooth device for serial communication on Arch Linux. bluetoothserial.md. Connecting a Bluetooth device for serial communication on Arch Linux. bluetoothserial.md. Surprisingly rfcomm bind. Command doesn't spit errors in that case - just exits and doesn't create the serial port. Once you have paired a device it will.
The new Raspberry Pi 3 released on 29 Feb 2016 has issues with its UART port as the pinout GPIO 14/15 on the pin header is now based on a low throughput mini-UART.
![Linux bluetooth serial Linux bluetooth serial](/uploads/1/2/6/3/126348043/242958243.png)
To understand the issue better than reading the wall of text below, you can see the talk I gave on this issue.
The actual hardware UART on the BCM2837 SoC has now been assigned to handle Bluetooth with the BCM43438 Wifi/Bluetooth chip. More details can be found here and here.
This mini-UART does not produce a stable baud rate as it fluctuates based on the Core clock speed whenever it rises or falls. The result is that the serial debug output is practically unusable. On Raspbian you may see garbage or nothing at all. The solution is simple, add
core_freq=250
to /boot/config.txt
to cap the core frequency to a constant value. This option is soon to be discouraged in favour of enable_uart=1
which Arch Linux already supports.A 'pi-bluetooth' package that exists in Raspbian is also not available in Arch Linux (yet) so Bluetooth support is not ready although an AUR package exists to enable BT.
In this gist, I will detail out all the steps required to enable the debug console on the miniUART and install Bluetooth support. At the same time, I have alternative instructions should you want to swap the Bluetooth to use the mini-UART and the debug console to use hardware UART instead.
Required hardware:
- Raspberry Pi 3 Model B
- 3.3V USB-TTL cable like this from Adafruit or HDMI screen with keyboard or SSH.
- Network connection to download packages
Preparing the SD Card
- Copy the partition image to your microSD Card based on the installation guide here.
- Open the boot partition of the microSD card which should be the small 100MB partition.
- Open config.txt
- Add the following lines to the end of the file
The
enable_uart=1
multiplier will cap the CPU speed of your ARM CPU to a constant 600Mhz instead of fluctuating speed up to 1.2Ghz so the baud rate of the mini-UART will be stable. This is roughly equivalent to earlier attempts to solve the problem with core_freq=250
.For extra information, you can also add
dtoverlay=pi3-miniuart-bt
to switch the pin mappings of the BCM2837 so the Serial Debug port will use the hardware UART and the Bluetooth part of the wireless chip will use the mini-UART.- Unmount the SD card and insert into your Rpi3 and plug your USB-TTL cable.
Install Yaourt
We will need to install the pi-bluetooth package. This package has been ported from Raspbian and posted on AUR by someone. But before that, we should install Yaourt, a tool to install AUR packages.
Using a terminal program on your computer like
screen
with the serial-TTL console cable, login with default user:alarm, password:alarm. Do not use root yet as makepkg
does not like root.Configuring Bluetooth
Continue from the above using the alarm account.
If you set the Bluetooth communication to go through the mini-UART channel, the performance will be significantly degraded in theory. In fact, you may want to reduce the baud rate from
921600
to something lower like 460800
or even as low as 115200
. However, it should be enough for Bluetooth Low Energy applications. Higher speed data/audio transfer on Bluetooth classic may face issues. You will also need to set core_freq=250
or force_turbo=1
in /boot/config.txt
so the baud rate of the mini-UART will be stable to use Bluetooth.If you use just
enable_uart=1
in /boot/config.txt
, your RPi 3 will just be slow but everything should work as per normal.References
Bluetooth is a standard for the short-range wireless interconnection of cellular phones, computers, and other electronic devices. In Linux, the canonical implementation of the Bluetooth protocol stack is BlueZ.
- 1Installation
- 1.1Front-ends
- 3Configuration
- 6Troubleshooting
- 6.4Bluetooth USB Dongle
Installation
- Install the bluez package, providing the Bluetooth protocol stack.
- Install the bluez-utils package, providing the
bluetoothctl
utility. Alternatively install bluez-utils-compatAUR to additionally have the deprecated BlueZ tools. - The generic Bluetooth driver is the
btusb
Kernel module. Check whether that module is loaded. If it's not, then load the module. - Start/enable
bluetooth.service
.
- By default the bluetooth daemon will only give out bnep0 devices to users that are a member of the
lp
group. Make sure to add your user to that group if you intend to connect to a bluetooth tether. You can change the group that is required in the file/usr/share/dbus-1/system.d/bluetooth.conf
. - Some Bluetooth adapters are bundled with a Wi-Fi card (e.g. Intel Centrino). These require that the Wi-Fi card is firstly enabled (typically a keyboard shortcut on a laptop) in order to make the Bluetooth adapter visible to the kernel.
- Some Bluetooth cards (e.g. Broadcom) conflict with the network adapter. Thus, you need to make sure that your Bluetooth device get connected before the network service boot.
- Some tools such as hcitool and hciconfig have been deprecated upstream, and are no longer included in bluez-utils. Since these tools will no longer be updated, it is recommended that scripts be updated to avoid using them. If you still desire to use them, install bluez-utils-compatAUR. See FS#53110 and the Bluez mailing list for more information.
Front-ends
Console
- bluetoothctl — Pairing a device from the shell is one of the simplest and most reliable options.
- http://www.bluez.org/ || bluez-utils
Tip: To automate bluetoothctl commands, use
echo -e '<command1>n<command2>n' | bluetoothctl
or bluetoothctl -- command
Graphical
The following packages allow for a graphical interface to customize Bluetooth.
- GNOME Bluetooth — GNOME's Bluetooth tool.
- gnome-bluetooth provides the back-end
- gnome-shell provides the status monitor applet
- gnome-control-center provides the configuration front-end GUI that can be accessed by typing Bluetooth on the Activities overview, or with the
gnome-control-center bluetooth
command. - You can also launch the
bluetooth-sendto
command directly to send files to a remote device. - nautilus-bluetoothAUR adds a 'Send via Bluetooth' entry to Nautilus' right-click menu
- To receive files, open the Bluetooth settings panel; you can only receive whilst the Bluetooth panel is open.
- To add a Bluetooth entry to the Send To menu in Thunar's file properties menu, see instructions here. (The command that needs to be configured is
bluetooth-sendto %F
).
- https://wiki.gnome.org/Projects/GnomeBluetooth ||
- Bluedevil — KDE's Bluetooth tool. If there is no Bluetooth icon visible in Dolphin and in the system tray, enable it in the system tray options or add a widget. You can configure Bluedevil and detect Bluetooth devices by clicking the icon. An interface is also available from the KDE System Settings.
- https://cgit.kde.org/bluedevil.git || bluedevil
- Blueberry — Linux Mint's spin-off of GNOME Bluetooth, which works in all desktop environments. Blueberry does not support receiving files through Obex Object Push.
- https://github.com/linuxmint/blueberry || blueberry
- Blueman — A full featured Bluetooth manager.
- https://github.com/blueman-project/blueman || blueman
- ObexFTP — A tool for transferring files to/from any OBEX enabled device.
- http://dev.zuckschwerdt.org/openobex/wiki/ObexFtp || obexftpAUR
Pairing
This article or section needs expansion.
Reason: Step 5 is unclear. What are Bluetooth agents? (Discuss in Talk:Bluetooth#)
Note: Before using the bluetooth device, make sure that it is not blocked by rfkill.
This section describes directly configuring bluez5 via the bluetoothctl CLI, which might not be necessary if you are using an alternative front-end tool (such as GNOME Bluetooth).
The exact procedure depends on the devices involved and their input functionality. What follows is a general outline of pairing a device using
bluetoothctl
.Start the
bluetoothctl
interactive command. Input help
to get a list of available commands.- (optional) Select a default controller with
select MAC_address
. - Enter
power on
to turn the power to the controller on. It is off by default and will turn off again each reboot, see #Auto power-on after boot. - Enter
devices
to get the MAC Address of the device with which to pair. - Enter device discovery mode with
scan on
command if device is not yet on the list. - Turn the agent on with
agent on
or choose a specific agent: if you press tab twice afteragent
you should see a list of available agents, e.g. DisplayOnly KeyboardDisplay NoInputNoOutput DisplayYesNo KeyboardOnly off on. - Enter
pair MAC_address
to do the pairing (tab completion works). - If using a device without a PIN, one may need to manually trust the device before it can reconnect successfully. Enter
trust MAC_address
to do so. - Enter
connect MAC_address
to establish a connection.
An example session may look this way:
Configuration
Auto power-on after boot
By default, your Bluetooth adapter will not power on after a reboot. The former method by using
hciconfig hci0 up
is deprecated, see the release note. Now you just need to add the line AutoEnable=true
in /etc/bluetooth/main.conf
at the bottom in the [Policy]
section:Discoverable on startup
If the device should always be visible and directly connectable:
Audio
In order to be able to use audio equipment like bluetooth headphones or speakers, you need to install the additional pulseaudio-bluetooth package. With a default PulseAudio installation you should immediately be able to stream audio from a bluetooth device to your speakers.
If you have a system-wide PulseAudio setup make sure the user running the daemon (usually
pulse
) is in the lp
group and you load the bluetooth modules in your PulseAudio config:See the Bluetooth headset page for more information about bluetooth audio and bluetooth headsets.
Bluetooth serial
To get bluetooth serial communication working on Bluetooth-to-Serial modules (HC-05, HC-06) do the following steps:
Pair your bluetooth device using
bluetoothctl
as described above.Install bluez-rfcommAUR and bluez-hcitoolAUR, as they provide certain functionality which is missing from newer tools.
Bind paired device MAC address to tty terminal:
Now you can open
/dev/rfcomm0
for serial communication.Troubleshooting
This article or section is out of date.
Reason: Replace hciconfig with newer commands. (Discuss in Talk:Bluetooth#)
Debugging
In order to debug, first stop
bluetooth.service
.And then start it with the
-d
parameter:Another option is via the
btmon
tool.Deprecated BlueZ tools
Eight BlueZ tools were deprecated and removed from bluez-utils, although not all of them were superseded by newer tools. The bluez-utils-compatAUR package provides an alternative version of bluez-utils with the deprecated tools.
Deprecated tool | Most likely replacement |
---|---|
gatttool | btgatt-client, D-Bus Gatt API |
hciattach | btattach |
hciconfig | btmgmt (and bluetoothctl?) |
hcidump | btmon (and btsnoop) |
hcitool | missing, D-Bus Device API available |
rfcomm | missing, implement with D-Bus Profile1 API? |
ciptool | |
sdptool | missing, functionality seems to be scattered over different D-Bus objects: Profile, Advertising, and the UUIDs arrays in device and adapter. |
gnome-bluetooth
If you see this when trying to enable receiving files in bluetooth-properties:
Then make sure that the XDG user directories exist.
Bluetooth USB Dongle
If you are using a USB dongle, you should check that your Bluetooth dongle is recognized. You can do that by running
journalctl -f
when you have plugged in the USB dongle (or inspecting /var/log/messages.log
). It should look something like the following (look out for hci):If you only get the first two lines, you may see that it found the device but you need to bring it up.Example:
Or
To verify that the device was detected you can use
btmgmt
which is part of the bluez-utils
. You can get a list of available devices and their identifiers and their MAC address by issuing:It is possible to check the Bluetooth version as mapped to the HCI version according to the table in the official specification. For example, in the previous output, HCI version 6 is Bluetooth version 4.0.
More detailed information about the device can be retrieved by using the deprecated
hciconfig
. (bluez-utils-compatAUR)Audio devices start to skip at short distance from dongle
If other devices share the same USB host, they can interrupt communication with audio devices. Make sure it is the only device attached to its bus. For example:
CSR Dongle 0a12:0001
The device
ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
has a regression bug, and currently only works in the kernel version ≤ 3.9.11. There is a patch available for newer versions. For more information, see Kernel Bug 60824.Logitech Bluetooth USB Dongle
There are Logitech dongles (ex. Logitech MX5000) that can work in two modes: Embedded and HCI. In embedded mode dongle emulates a USB device so it seems to your PC that you are using a normal USB mouse/keyoard.
If you hold the little red Button on the USB BT mini-receiver it will enable the other mode. Hold the red button on the BT dongle and plug it into the computer, and after 3-5 seconds of holding the button, the Bluetooth icon will appear in the system tray. Discussion
Alternatively, you can install the bluez-hid2hci package. When you connect your Logitech dongle it will automatically switch.
hcitool scan: Device not found
- On some laptops (e.g. Dell Studio 15, Lenovo Thinkpad X1) you have to switch the Bluetooth mode from HID to HCI. Install the bluez-hid2hci package, then udev should do this automatically. Alternatively, you can run this command to switch to HCI manually:
- If the device will not show up and you have a Windows operating system on your machine, try booting it and enable the bluetooth adapter from windows.
- Sometimes also this simple command helps:
- It might happen with some intel cards (such as the 8260) to not be picked up correctly by the bluetooth service, resulting in the previous command erroring with `no default controller available`. In some cases, using the deprecated bluez-utils-compatAUR in lieu of bluez-utils have reportedly fixed the issue.
rfkill unblock: Do not unblock
If your device still soft blocked and you run connman, try this:
My computer is not visible
Cannot discover computer from your phone? Enable discoverable mode:
to check if it worked:
Note: Check DiscoverableTimeout and PairableTimeout in
/etc/bluetooth/main.conf
If even so it does not show up, try changing the device class in
/etc/bluetooth/main.conf
as following:A user reported that this was the only solution to make his computer visible for his phone.
Logitech keyboard does not pair
If you do not get the passkey when you try to pair your Logitech keyboard, type the following command:
If after pairing, the keyboard still does not connect, check the output of
hcidump -at
. If the latter indicates repeatedly connections-disconnections like the following message:then, the only solution for now is to install the old Bluetooth stack.
HSP/HFP profiles
bluez5 removed support for the HSP/HFP profiles (telephony headset for TeamSpeak, Skype, etc.). You need to install PulseAudio (>= version 6) or another application that implements HSP/HFP itself.
Foxconn / Hon Hai / Lite-On Broadcom device
Some of these devices require the firmware to be flashed into the device at boot. The firmware is not provided but can converted from a Microsoft Windows .hex file into a .hcd using hex2hcd (which is installed with bluez-utils).
In order to get the right .hex file, try searching the device vendor:product code obtained with lsusb, for example:
or
Alternatively, boot into Windows (a virtual machine installation will suffice) and get the firmware name from the Device Manager utility. If you want to know the model of your device but cannot see it in lsusb, you might see it in lsusb -v as
iProduct
.The .hex file can be extracted from the downloaded Windows driver without having to run Windows for it. Download the right driver, for example Bluetooth Widcomm (listed among the drivers for Lifebook P771), which contains the drivers for many Broadcomm devices. In case of Bluetooth Widcomm, the driver is a self-extracting RAR archive, so it can be extracted using unrar x. To find out which of the many .hex files is the right one for you, look in the file
Win32/bcbtums-win7x86-brcm.inf
and search for [RAMUSBE031.CopyList]
, where E031
should be replaced with the product code (the second hex number in lsusb) of your device in upper-case. Underneath you should see the file name of the right .hex file.Once you have the .hcd file, copy it into
/lib/firmware/brcm/BCM.hcd
- this filename is suggested by dmesg
and it may change in your case so check your dmesg output in order to verify. Then reload the btusb module:The device should now be available. See BBS#162688 for information on making these changes persistent.
Intel combined wifi and bluetooth cards
See Wireless network configuration#Bluetooth coexistence.
Device connects, then disconnects after a few moments
If you see messages like the following in
journalctl
output, and your device fails to connect or disconnects shortly after connecting:This may be because you have already paired the device with another operating system using the same bluetooth adapter (e.g., dual-booting). Some devices cannot handle multiple pairings associated with the same MAC address (i.e., bluetooth adapter). You can fix this by re-pairing the device. Start by removing the device:
Then restart
bluetooth.service
, turn on your bluetooth adapter, make your device discoverable, re-scan for devices, and re-pair your device. Depending on your bluetooth manager, you may need to perform a full reboot in order to re-discover the device.Device does not connect with an error in journal
If you see a message like the following in
journalctl
output while trying to connect to a device:try installing pulseaudio-bluetooth and restarting PulseAudio. This error can manifest even while using only file transfer.
Device does not show up in scan
Some devices using bluetooth low energy do not appear when scanning with bluetoothctl, for example the Logitech MX Master. The simplest way I have found to connect them is by installing bluez-utils-compatAUR, then start
bluetooth.service
and do:In another terminal:
Wait until your device shows up, then
Ctrl+c
hcitool. bluetoothctl should now see your device and pair normally.Interference between Headphones and Mouse
If you experience audio stuttering while using a bluetooth mouse and keyboard simultaneously, you can try the following as referenced in #23 https://bugs.launchpad.net/ubuntu/+source/bluez/+bug/424215
Bluetooth mouse laggy movements
Try edit the file
/var/lib/bluetooth/XX:XX:XX:XX:XX:XX/YY:YY:YY:YY:YY:YY/info
(XX:XX:XX:XX:XX:XX
- your Bluetooth adapter MAC-address, YY:YY:YY:YY:YY:YY
- your mouse MAC-address) and add those lines:You can see your local adapter MAC address by running command
hcitool dev
, your can see MAC addresses of currently connected remote devices by running command hcitool con
Adapter disappears after suspend/resume
First, find vendor and product ID of the adapter. For example:
In this case, the vendor ID is 8087 and the product ID is 0025.
Then, use usb_modeswitch to reset the adapter:
Retrieved from 'https://wiki.archlinux.org/index.php?title=Bluetooth&oldid=593573'