[WORKAROUND INCLUDED] Keyboard does not work in BIOS/BitLocker

Device: GL-RM1PE, firmware 1.10.0beta2-30-g265a7f2656 (latest stable)
Target: Lenovo Legion 7i 2020

Problem: At the BitLocker PIN screen the Comet's keyboard is ignored (mouse works; a physical USB keyboard works; everything works after boot).

Cause: kvmd-otg hardcodes the USB device class to 0xEF/02/01. The laptop's firmware reads the keyboard's reports but ignores them. With class 0/0/0 it works. Removing the mice, a spec boot-keyboard descriptor, longer key presses and full-speed USB made no difference. The camera still works in Windows 11 with class 0.

Workaround

SSH in as root and paste:

mkdir -p /etc/kvmd/user/scripts
cat > /etc/kvmd/user/scripts/S90usb-class-fix.sh <<'EOF'
#!/bin/sh
case "$1" in
start)
    (
    G=/sys/kernel/config/usb_gadget/rockchip
    for n in $(seq 1 120); do [ -n "$(cat $G/UDC 2>/dev/null)" ] && break; sleep 1; done
    UDC=$(cat $G/UDC 2>/dev/null)
    [ -n "$UDC" ] || exit 0
    [ "$(cat $G/bDeviceClass)" = "0x00" ] && exit 0
    echo "" > $G/UDC
    echo 0 > $G/bDeviceClass
    echo 0 > $G/bDeviceSubClass
    echo 0 > $G/bDeviceProtocol
    echo "$UDC" > $G/UDC
    logger -t usb-class-fix "bDeviceClass set to 0 on $UDC"
    ) </dev/null >/dev/null 2>&1 &
    ;;
esac
EOF
chmod +x /etc/kvmd/user/scripts/S90usb-class-fix.sh
reboot

After reboot, cat /sys/kernel/config/usb_gadget/rockchip/bDeviceClass should print 0x00.

Note: the filename must start with S + two digits (S90...), otherwise S99custom never runs it. Nothing needs to go in override.yaml. To undo: delete the file and reboot.

Requests

  1. Make the device class configurable or default to 0/0/0 (upstream PiKVM never sets it).
  2. Kernel use-after-free when the target resets USB:
    refcount_t: underflow; use-after-free.
    Comm: kvmd/hid-mouse ... Call trace: refcount_warn_saturate <- kobject_put <- cdev_put <- __fput
    
  3. Minor: Dropbear sometimes rejects the correct root password on the first try.

Hi, thanks for the detailed report!

We've found that the IAD descriptor can cause keyboard and mouse enumeration issues on some systems. We've provided beta firmware without the IAD descriptor to some users for testing, but it hasn't resolved the issue for everyone. We're still looking into what else might be causing it.

We'll update the IAD descriptor in v1.11 firmware.

Thanks for sharing your findings with us.