zmk: Cannot connect to ZMK keyboard over Bluetooth on Pop_OS! 22.04 + Intel AX200 controller

Hi all,

For some reason (I believe after updating from Pop_OS! 20.10 to 22.04), I am no longer able to connect to either of my ZMK firmware keyboards over Bluetooth. I’ve collected all the logs I can think of below:

Bluetoothctl output:
Failed to pair: org.bluez.Error.AuthenticationFailed

dmesg output:
[ 9738.118236] Bluetooth: hci0: unexpected SMP command 0x0b from e1:ed:df:d8:a0:25
[ 9738.232020] Bluetooth: hci0: Opcode 0x 401 failed: -16

systemctl journal output:
src/device.c:load_gatt_db() No cache for E1:ED:DF:D8:A0:25

USB logging output:
[00:03:08.153,594] <dbg> zmk: zmk_endpoints_send_report: usage page 0x07
[00:03:19.176,818] <dbg> zmk: connected: Connected thread: 0x20004d90
[00:03:19.176,910] <dbg> zmk: connected: Connected 44:AF:28:56:A6:C0 (public)
[00:03:19.178,405] <dbg> zmk: update_advertising: advertising from 0 to 2
[00:03:19.213,256] <inf> bas: BAS Notifications enabled
[00:03:19.300,628] <err> zmk: Security failed: 44:AF:28:56:A6:C0 (public) level 1 err 4
[00:03:19.390,991] <inf> bas: BAS Notifications disabled
[00:03:19.393,676] <dbg> zmk: disconnected: Disconnected from 44:AF:28:56:A6:C0 (public) (reason 0x05)
[00:03:19.393,707] <dbg> zmk: update_advertising: advertising from 2 to 2

The Bluetooth controller is the built-in controller in the Intel AX200 chipset. I’ve tested all things I can think of, including manually installing the latest linux-firmware, reinstalling Pop_OS! from scratch, etc.

The connection does work properly on Windows and on another Linux laptop, plus my Android phone.

https://paste.sethforprivacy.com/?d908b857102a6e0d#6Csv3EbvFSz7HeSGTNCzdJupZkze4ZxAmoqVs3fVa5Wr

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 1
  • Comments: 85 (38 by maintainers)

Commits related to this issue

Most upvoted comments

There is now an aggregate setting called CONFIG_ZMK_BLE_EXPERIMENTAL_CONN which you can set to have a combination of the settings I shared earlier applied. Here is a copy of the call for testers that @petejohanson sent out on Discord:

I could use some help with testing some core changes to our BLE connection settings that are aimed to improve our reliability across all host OS/versions. You don’t even need to use a different branch (assuming you are on main). For details on what the config enables, see https://zmk.dev/docs/config/bluetooth#kconfig

To test:

  • Enable CONFIG_ZMK_BLE_EXPERIMENTAL_CONN=y in your config, rebuild and flash to your keeb. If using a split, please flash both sides.
  • You may need to re-pair to hosts, but maybe not. If you do need to, please make a note.
  • Test for a day or two.
  • Report your testing experience/results in the newly created thread started with this message.

Thanks in advance!

Still no luck. And it is extremely problematic when the keyboard disconnects while typing as the last key stays stuck repeating itself for n times until it reconnects again.

As a note, perhaps the issue title should be changed. I guess a lot of people are having the very same issue with indeed different distros and/or configurations.

Hello!

I would also like to report that CONFIG_BT_CTLR_PHY_2M=n fixed my issue. However, it has caused one side effect in that the right half now takes much longer to connect to the left. Its not super long, but it is a noticeable wait.

Config: Pop-OS Intel AX210 Bluetooth nice!nano controllers

I have tried

CONFIG_BT_CTLR_PHY_2M=n
CONFIG_BT_GATT_AUTO_SEC_REQ=y

and everything worked!

So, I decided to try only CONFIG_BT_CTLR_PHY_2M=n again just to be sure. And it also works! Connection is stable for now. Both to the laptop and between halfs.

Just for reference, I did:

  • unpair keyboard from laptop
  • reset both nice!nano_v2 with settings_reset.uf2
  • flash new FW to both halfs
  • pair with laptop

I will monitor this thread, so if you need to test some other configuration let me know.

Same issue, when upgraded to kernel 6.6.2. I tried clearing all profiles and reflashing, all I get is a connect and an immediate disconnect:

kernel: Bluetooth: hci0: unexpected SMP command 0x0b from eb:28:2c:3b:2e:ce
bluedevil-wizard[8227]: kf.bluezqt: PendingCall Error: "Authentication Canceled"

Edit: so the kernel is fine, the issue is related to the arch package linux-firmware-20231110.74158e7a-1. I have no idea who is to blame here.

@sadekbaroudi : Glad I could help! I must admit that since I have written that comment, the problem haven’t occur any more. And now I have even one additional Linux installation. Maybe the problem caused by the more frequent flashes of the firmware, or also bad handling from my side… Anyway, it seems CONFIG_ZMK_BLE_EXPERIMENTAL_FEATURES=y helped also for me.

Thank you so much, can confirm the above config changes also work for me

Perhaps the above is my misunderstanding on where to apply these config changes for a shield type zmk config?

Yes, you need to either use separate left, right conf files, or put that file under config/ directory directly: https://zmk.dev/docs/config#config-file-locations

@hal3e I don’t know what is happening, but in the morning my keyboard connects, but not type anything. I flashed again and it’s now working again. I will monitor…

A monitored about a week and it worked correctly.

@hal3e I don’t know what is happening, but in the morning my keyboard connects, but not type anything. I flashed again and it’s now working again. I will monitor…

I have the same issue after an os update. I have a sofle clone (split keyboard) and I report that:

* `CONFIG_BT_GATT_AUTO_SEC_REQ=y` and `CONFIG_BT_AUTO_PHY_UPDATE=n` do not solve the connection problem.

* `CONFIG_BT_CTLR_PHY_2M=n` solved the connection problem but after connecting key-presses are not received on my laptop.

Is there something else I could try ?

Have you completely removed and re-paired the keyboard?

Yes. and I thought it was ok because it connected however no key-presses were being received. Also, while I had the left side connected over USB the right side could not connect to the left side.

I will try the combination @wAISw mentioned and report back.

Hi! I’m on fresh fedora linux got this problem. I have DAO keyboard. I solve my problem with adding

CONFIG_BT_CTLR_PHY_2M=n
CONFIG_BT_GATT_AUTO_SEC_REQ=y

https://github.com/wAISw/dao-zmk-config/commit/d30aaca69b86eedb5fb48f49b1bfe500ff6ad269

You also could try setting CONFIG_BT_CTLR_PHY_2M=n and see if that helps at all.

Another user reporting issues had a dmesg output indicating it was unhappy with the SMP security request packet… I do wonder if maybe using https://github.com/zmkfirmware/zmk/pull/2046 and enabling CONFIG_BT_GATT_AUTO_SEC_REQ=y will help.

Finally, pairing with bluetuith instead of bluetoothctl resolved the issue in my case. https://github.com/darkhz/bluetuith

A friend of mine more familiar with ZMK suggested clearing all Bluetooth profiles on the keyboard (not just the one I was trying to use) and after doing so the issue is resolved.

If I can provide any additional logs to help track down this bug, please let me know – I will leave this issue open for a bit in case that would be helpful!