Skip to content

bug(rp2040): holding a key down while plugging the keyboard crashes ZMK #3408

Description

@Nuclear-Squid

Hello ! I’m currently developing an rp2040-based mechanical keyboard that makes use of dip-switches to enable features in the keymap on the fly. They are defined as standard switches, as far as ZMK is concerned, and trigger &mo behaviors. The problem is that under the right conditions (see below), if one of those switches (or any other key for that matter) is held on when the keyboard plugged into the computer, the keyboard crashes / isn’t able to boot with no logs available.

To replicate this bug:

  • have a keyboard using an rp2040
  • run ZMK on the main branch with ZMK studio
  • hold any key (can even be a &none behavior) that isn’t controlled by an io-expander
  • plug the keyboard into a Windows or MacOS computer (Linux does not have this issue)
  • keyboard doesn’t respond

[EDIT]: The next two paragraphs are wildly off, you can safely ignore them.

I’m not really sure what could even trigger this issue, but since it only happens when ZMK Studio is enabled and is OS-specific (since it works fine on Linux), I’m guessing that the issue is related to the USB communication between the keyboard and the computer, that this communication interrupts something important during the startup of the rp2040 (or maybe accesses uninitialized ressources ?), and that Linux doesn’t do this at the same time as the other OS, so it doesn’t trigger the issue.

If this assumption is true, that would mean the bug probably resides somewhere in the studio_rpc_listener_cb function in app/src/studio/rpc.c, as this seems to be the only non-BLE event listener specific to zmk-studio.

Right now, I could only test this on a couple of custom boards. Here are the links to their .dts files, in case the issue is on my end:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions