This article describes how to fix Bluetooth keyboard and/or mouse connection issues with CoreElec. In my case, I am using Kodi AMLogic 21.2 (21.2.0) running in CoreElec 21.2-Omega and my MadCatz Strike Bluetooth keyboard started to disconnect randomly or after going to sleep as well as on reboots it would no longer automatically reconnect.

Issue

When using my MadCatz Strike Bluetooth keyboard to control Kodi on CoreElec, I recently started to get intermittent disconnects and an inability to reliably reconnect my keyboard. In attempting to "Trust and Connect" the affected device would also hang CoreElec requiring a hard restart (a physical unplug - replug) in order to fix the "hung" device.

Root Cause

The suspected root cause appears to be with how CoreElec allows for the management of mutiple Bluetooth devices. CoreElec allows users to manage multiple "paired" devices and over time it appears that all these devices can create a management issue and possible corruption or permissions issues. It is believed that by adding multiple devices over time, the system gets itself into a "degraded mode" whereby it no longer can reliably manage all the "paired" devices.

Solution

I found that all the Bluetooth related information for all the connected devices is stored in a cache directory at /storage/.cache/bluetooth. If the permissions get messed up for these directories and files, CoreElec can hang up attempting to re-connect a previously connected Bluetooth device. One theory is that if you boot to NAND (Android version) you may end up setting the permissions incorrectly for the related directories and/or files in question in the /storage/.cache/bluetooth directory? Regardless of how the permissions get messed up, there are a few options to rectify the issue:

Option1 - Reload CoreElec

This option involves re-installing CoreElec as restoring from a backup does not resolve the issue. The obvious challenge with this option is that you will lose all your settings and you have to set up your environment all over again including reloading any local media libraries, etc. 

Option2 - Reset Permissions on "Cached" Bluetooth Directory and Files

This solution is to force the owner and group to "root" using the "chown' cmd for all the Bluetooth devices and their related directories and files in storage/.cache/bluetooth. This will allow you to keep all existing connections (i.e. past pairings) but ensures that the directories and files have the correct ownership. This is a more advanced change as you are required to telnet into the O/S and change the filesystem parameters. The steps are as follows.

Use Telnet to log into your device and:

  1. chown -R root:root /storage/.cache/bluetooth

Option 3 - Remove all "cached" Bluetooth Connections (Preferred Option)

Remove all cached devices and reconnect just the ones that you need. With this in mind, and to make things easier for the general user, simply rename the existing /storage/.cache/bluetooth directory and create a new one using the built-in Kodi File explorer. This removes any existing Bluetooth devices and you can effectively start fresh. The steps are as follows.

Using the built in Kodi File manager (under System) and using a USB attached keyboard:

  1. Navigate to storage/.cache. Using a long-press to access the menu, rename the "bluetooth" directory to "bluetooth-bak"
  2. Long-press to get a menu again and create a new directory "bluetooth"
  3. Exit the File Manager and Navigate to the bottom of the screen to reboot the system
  4. Once the system is up, you can run CoreElec configurator ("CoreElec" under System), put your Bluetooth device in pairing mode and "Pair" it to CoreElec.

Update - Using Option 3 [Fixed]

Following the Option 3 steps appears to have resolved my issues with my MadCatz Strike keyboard as it will wake from sleep mode as well as after a reboot it will automatically reconnect. Therefore Option 3 is the recommended option as it represents the easiest yet effective approach to resolving the Bluetooth connection issue.