Help debugging misbehaving keyboard dongle

Hello guys,
A few months ago I bought a Chinese mechanical keyboard which can be used wired or wirelessly with a 2.4G dongle (or Bluetooth). The exact model is AK820 Pro from Ajazz.
The keyboard works perfectly when directly connected to my PC or whenever I need to use it on my laptop with BT, but on my desktop I can only use the 2.4G dongle.

For some reason, there are times when I leave my hands off the keyboard for a while (even just a few minutes, the time needed to read a document), and then my PC will refuse to receive any input from the device. The only way to fix it is to disconnect the dongle and connect it back.

I’m pretty sure that the issue is not the link between device and dongle, because if I restart the keyboard it still doesn’t work, and when I unplug it, the keyboard will display that it is not connected.

Maybe there’s some energy saving option that is crashing the dongle? I tried having a look at dmesg, but it only reports me physically unplugging and plugging it back in.
Do you have any suggestions on how to try to debug this?

dmesg
<6>[ 2323.563608] usb 1-3: USB disconnect, device number 3
<6>[ 2345.236386] usb 1-3: new full-speed USB device number 6 using xhci_hcd
<6>[ 2345.539906] usb 1-3: New USB device found, idVendor=0c45, idProduct=fdfd, bcdDevice= 1.38
<6>[ 2345.539913] usb 1-3: New USB device strings: Mfr=0, Product=2, SerialNumber=0
<6>[ 2345.539917] usb 1-3: Product: 2.4G Dongle
<6>[ 2345.587141] input: 2.4G Dongle as /devices/pci0000:00/0000:00:01.2/0000:02:00.0/usb1/1-3/1-3:1.0/0003:0C45:FDFD.000C/input/input32
<6>[ 2345.687947] hid-generic 0003:0C45:FDFD.000C: input,hidraw1: USB HID v1.00 Keyboard [2.4G Dongle] on usb-0000:02:00.0-3/input0
<6>[ 2345.699030] input: 2.4G Dongle as /devices/pci0000:00/0000:00:01.2/0000:02:00.0/usb1/1-3/1-3:1.1/0003:0C45:FDFD.000D/input/input33
<6>[ 2345.704949] hid-generic 0003:0C45:FDFD.000D: input,hidraw2: USB HID v1.00 Mouse [2.4G Dongle] on usb-0000:02:00.0-3/input1
<6>[ 2345.734140] input: 2.4G Dongle Consumer Control as /devices/pci0000:00/0000:00:01.2/0000:02:00.0/usb1/1-3/1-3:1.2/0003:0C45:FDFD.000E/input/input34
<6>[ 2345.784355] input: 2.4G Dongle System Control as /devices/pci0000:00/0000:00:01.2/0000:02:00.0/usb1/1-3/1-3:1.2/0003:0C45:FDFD.000E/input/input35
<6>[ 2345.784431] input: 2.4G Dongle Keyboard as /devices/pci0000:00/0000:00:01.2/0000:02:00.0/usb1/1-3/1-3:1.2/0003:0C45:FDFD.000E/input/input36
<6>[ 2345.784500] input: 2.4G Dongle System Multi Axis as /devices/pci0000:00/0000:00:01.2/0000:02:00.0/usb1/1-3/1-3:1.2/0003:0C45:FDFD.000E/input/input37
<6>[ 2345.784603] input: 2.4G Dongle as /devices/pci0000:00/0000:00:01.2/0000:02:00.0/usb1/1-3/1-3:1.2/0003:0C45:FDFD.000E/input/input38
<6>[ 2345.787965] hid-generic 0003:0C45:FDFD.000E: input,hiddev97,hidraw3: USB HID v1.00 Keyboard [2.4G Dongle] on usb-0000:02:00.0-3/input2
<6>[ 2345.804943] hid-generic 0003:0C45:FDFD.000F: hiddev98,hidraw4: USB HID v1.00 Device [2.4G Dongle] on usb-0000:02:00.0-3/input3
<6>[ 2345.821936] hid-generic 0003:0C45:FDFD.0010: hiddev99,hidraw5: USB HID v1.00 Device [2.4G Dongle] on usb-0000:02:00.0-3/input4

install powertop, run it and check to see if the dongle is indeed being powered down after a short while and fails to combe back cleanly.

If this is the case, you can toggle the setting in powertop and it’ll give the command disable power saving for that device. You can then stick that into your .profile or shell script of your choice.

Okay, probably autosuspend isn’t the issue.

I installed powertop, but all USB devices already show up with tunables set to Bad.

Device stats
            Usage         Device name
             18,5%        CPU misc
             18,5%        CPU core
            100,0%        Audio codec hwC1D0: Realtek (pipewire )
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Matisse/Vermeer Data Fabric: Device 18h; Function 3
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] 500 Series Chipset USB 3.1 XHCI Controller
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Matisse/Vermeer Data Fabric: Device 18h; Function 2
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge
            100,0%        USB device: USB Receiver (Logitech)
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] 500 Series Chipset Switch Downstream Port
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] FCH SMBus Controller
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge
            100,0%        PCI Device: NVIDIA Corporation AD104 [GeForce RTX 4070]
            100,0%        USB device: MYSTIC LIGHT  (MSI)
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Matisse/Vermeer Data Fabric: Device 18h; Function 4
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] FCH LPC Bridge
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Matisse/Vermeer Data Fabric: Device 18h; Function 5
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge
            100,0%        PCI Device: Samsung Electronics Co Ltd NVMe SSD Controller SM981/PM981/PM983
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] 500 Series Chipset Switch Upstream Port
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Starship/Matisse Internal PCIe GPP Bridge 0 to bus[E:B]
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Starship/Matisse GPP Bridge
            100,0%        USB device: xHCI Host Controller
            100,0%        PCI Device: NVIDIA Corporation AD104 High Definition Audio Controller
            100,0%        USB device: xHCI Host Controller
            100,0%        USB device: Samson Meteor Mic (Samson Technologies)
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] 500 Series Chipset Switch Downstream Port
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Starship/Matisse GPP Bridge
            100,0%        PCI Device: Sandisk Corp WD Black SN850X NVMe SSD
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] 500 Series Chipset SATA Controller
            100,0%        PCI Device: Realtek Semiconductor Co., Ltd. RTL8111/8168/8211/8411 PCI Express Gigabit Ethernet Controller
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Starship/Matisse Cryptographic Coprocessor PSPCPP
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Function
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Starship/Matisse Root Complex
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Starship/Matisse HD Audio Controller
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Starship/Matisse GPP Bridge
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Matisse/Vermeer Data Fabric: Device 18h; Function 6
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Matisse/Vermeer Data Fabric: Device 18h; Function 1
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Starship/Matisse IOMMU
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge
            100,0%        USB device: 2.4G Dongle
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Matisse/Vermeer Data Fabric: Device 18h; Function 0
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Starship/Matisse Reserved SPP
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Starship/Matisse Internal PCIe GPP Bridge 0 to bus[E:B]
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Matisse/Vermeer Data Fabric: Device 18h; Function 7
            100,0%        PCI Device: Advanced Micro Devices, Inc. [AMD] Matisse USB 3.0 Host Controller
             10,7 pkts/s  Network interface: enp42s0 (r8169)
              0,0%        Audio codec hwC0D0: Nvidia
              0,0%        USB device: USB2.0 Hub
              0,0%        USB device: xHCI Host Controller
              0,0%        USB device: xHCI Host Controller
              0,0%        runtime-PNP0C14:00
              0,0%        runtime-alarmtimer.0.auto
              0,0%        runtime-kgdboc
              0,0%        runtime-PCCT
              0,0%        runtime-acpi-cpufreq
              0,0%        runtime-intel_rapl_msr.0
              0,0%        runtime-PNP0C0C:00
              0,0%        runtime-rtc-efi.0
              0,0%        runtime-PNP0C14:01
              0,0%        runtime-sp5100-tco
              0,0%        runtime-PNP0800:00
              0,0%        runtime-MSFT0101:00
              0,0%        runtime-PNP0103:00
              0,0%        runtime-AMDI0030:00
              0,0%        runtime-efivars.0
              0,0%        I2C Adapter (i2c-1): SMBus PIIX4 adapter port 2 at 0b00
              0,0%        I2C Device (0-0050): ee1004
              0,0%        I2C Adapter (i2c-3): NVIDIA i2c adapter 2 at 2b:00.0
              0,0%        I2C Device (0-0052): ee1004
              0,0%        runtime-pcspkr
              0,0%        runtime-serial8250
              0,0%        runtime-PNP0C14:02
              0,0%        runtime-AMDIF030:00
              0,0%        I2C Adapter (i2c-5): NVIDIA i2c adapter 4 at 2b:00.0
              0,0%        I2C Device (0-0037): dummy
              0,0%        I2C Adapter (i2c-6): NVIDIA i2c adapter 5 at 2b:00.0
              0,0%        I2C Device (0-0053): ee1004
              0,0%        I2C Adapter (i2c-4): NVIDIA i2c adapter 3 at 2b:00.0
              0,0%        I2C Device (0-0051): ee1004
              0,0%        I2C Adapter (i2c-2): SMBus PIIX4 adapter port 1 at 0b20
              0,0%        I2C Adapter (i2c-0): SMBus PIIX4 adapter port 0 at 0b00
              0,0%        I2C Adapter (i2c-7): NVIDIA i2c adapter 6 at 2b:00.0
              0,0%        I2C Device (0-0036): dummy


Tunables
   Bad           NMI watchdog should be turned off                                                                      
   Bad           VM writeback timeout
   Bad           Enable SATA link power management for host2
   Bad           Autosuspend for USB device Samson Meteor Mic [Samson Technologies]
   Bad           Autosuspend for USB device USB Receiver [Logitech]
   Bad           Autosuspend for USB device 2.4G Dongle [1-3]
   Bad           Autosuspend for USB device MYSTIC LIGHT  [MSI]
   Bad           Runtime PM for port ata3 of PCI device: Advanced Micro Devices, Inc. [AMD] 500 Series Chipset SATA Controller
   Bad           Runtime PM for PCI Device Sandisk Corp WD Black SN850X NVMe SSD
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Starship/Matisse IOMMU
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Starship/Matisse Reserved SPP
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Starship/Matisse Root Complex
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Matisse/Vermeer Data Fabric: Device 18h; Function 4
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Function
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Matisse/Vermeer Data Fabric: Device 18h; Function 2
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] 500 Series Chipset SATA Controller
   Bad           Runtime PM for port ata1 of PCI device: Advanced Micro Devices, Inc. [AMD] 500 Series Chipset SATA Controller
   Bad           Runtime PM for port ata2 of PCI device: Advanced Micro Devices, Inc. [AMD] 500 Series Chipset SATA Controller
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Starship/Matisse Cryptographic Coprocessor PSPCPP
   Bad           Runtime PM for port ata4 of PCI device: Advanced Micro Devices, Inc. [AMD] 500 Series Chipset SATA Controller
   Bad           Runtime PM for port ata5 of PCI device: Advanced Micro Devices, Inc. [AMD] 500 Series Chipset SATA Controller
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Matisse/Vermeer Data Fabric: Device 18h; Function 5
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge
   Bad           Runtime PM for port ata6 of PCI device: Advanced Micro Devices, Inc. [AMD] 500 Series Chipset SATA Controller
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Matisse/Vermeer Data Fabric: Device 18h; Function 0
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] FCH SMBus Controller
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Matisse USB 3.0 Host Controller
   Bad           Runtime PM for PCI Device Realtek Semiconductor Co., Ltd. RTL8111/8168/8211/8411 PCI Express Gigabit Ethernet Controller
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Matisse/Vermeer Data Fabric: Device 18h; Function 7
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] FCH LPC Bridge
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge
   Bad           Runtime PM for disk sda
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Matisse/Vermeer Data Fabric: Device 18h; Function 6
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Matisse/Vermeer Data Fabric: Device 18h; Function 3
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] 500 Series Chipset USB 3.1 XHCI Controller
   Bad           Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Matisse/Vermeer Data Fabric: Device 18h; Function 1
   Good          Enable Audio codec power management
   Good          Enable SATA link power management for host0
   Good          Enable SATA link power management for host4
   Good          Enable SATA link power management for host1
   Good          Enable SATA link power management for host3
   Good          Enable SATA link power management for host5
   Good          Autosuspend for USB device xHCI Host Controller [usb3]
   Good          Autosuspend for USB device USB2.0 Hub [1-2]
   Good          Autosuspend for USB device xHCI Host Controller [usb2]
   Good          Autosuspend for USB device xHCI Host Controller [usb4]
   Good          Autosuspend for USB device xHCI Host Controller [usb1]
   Good          Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] 500 Series Chipset Switch Downstream Port
   Good          Runtime PM for PCI Device Samsung Electronics Co Ltd NVMe SSD Controller SM981/PM981/PM983
   Good          Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Starship/Matisse Internal PCIe GPP Bridge 0 to bus[E:B]
   Good          Runtime PM for PCI Device NVIDIA Corporation AD104 [GeForce RTX 4070]
   Good          Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Starship/Matisse GPP Bridge               
   Good          Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Starship/Matisse GPP Bridge
   Good          Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] 500 Series Chipset Switch Upstream Port
   Good          Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Starship/Matisse GPP Bridge
   Good          Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Starship/Matisse Internal PCIe GPP Bridge 0 to bus[E:B]
   Good          Runtime PM for PCI Device NVIDIA Corporation AD104 High Definition Audio Controller
   Good          Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] Starship/Matisse HD Audio Controller
   Good          Runtime PM for PCI Device Advanced Micro Devices, Inc. [AMD] 500 Series Chipset Switch Downstream Port

Well, at least you’ve ruled power suspend out.

<6>[ 2323.563608] usb 1-3: USB disconnect, device number 3
<6>[ 2345.236386] usb 1-3: new full-speed USB device number 6 using xhci_hcd
<6>[ 2345.539906] usb 1-3: New USB device found, idVendor=0c45, idProduct=fdfd, bcdDevice= 1.38
<6>[ 2345.539913] usb 1-3: New USB device strings: Mfr=0, Product=2, SerialNumber=0
<6>[ 2345.539917] usb 1-3: Product: 2.4G Dongle

According to the dmesg output, the keyboard dongle is device 3 on bus 1.

On desktop PCs, front USB ports are often a different bus from the rear ports (or even on an internal USB hub), so try moving the dongle to a different port to see if it makes a difference.

I’ll try doing this for a while to see if the situation improves.

I moved the dongle on the front panel because it’s easier to unplug/re-plug when it stops working. I’d really prefer not to waste half of my easy access ports.

In the past, linux has been lax about supporting devices that don’t conform to standards, but recently some older devices I use disconnect because power draw exceeded the specs. I wonder if your dongle isn’t “legal” in some jurisdictions.

See: https://beyondlogic.org/usbnutshell/usb5.shtml says:

The bcdDevice has the same format than [SIC] the bcdUSB and is used to provide a device version number. This value is assigned by the developer.

USB Bluetooth dongles are cheap and should allow you to avoid using the old device.