Repository navigation
Conversation
Claude Opus 5.5 AnalysisWhat goes wrongWhen the device asks the host to wake up (remote wakeup), the driver can decide the host has answered even when it hasn't. The device then switches to active and stays that way, although nothing is talking to it. This is easiest to see with a PC that is shut down but still powers its USB ports: pressing a key "wakes" the device, and it never returns to suspend. Why it happensAs far as I can tell from the source, the driver relies on two things. First, the comment in ChibiOS-Contrib/os/hal/ports/RP/LLD/USBDv1/hal_usb_lld.h Lines 416 to 422 in 7561ba7 And the SOF branch of the ISR completes the wakeup: ChibiOS-Contrib/os/hal/ports/RP/LLD/USBDv1/hal_usb_lld.c Lines 390 to 405 in 7561ba7 Second, the RP2040 keeps its "SOF received" status set until the frame number register ( ChibiOS-Contrib/os/hal/ports/RP/LLD/USBDv1/hal_usb_lld.c Lines 499 to 508 in 7561ba7 Without a The fixRead Possible side effectsI've tried to think through what else this could affect:
This was tested on one RP2040 keyboard running QMK, using the steps described above. I may well be missing context about why the code is written this way, so corrections are welcome. |
5e9e973 to
0f5ded6
Compare
Hi!
My Pi Pico based QMK keyboard can be woken up after being suspended (Win PC is turned off) and then never goes back to sleep. The RGB stays on the whole night and it's pretty but then I can't sleep either. 😭
I personally tested and confirmed that this patch fixes the issue for my particular use case.
However I don't understand any of this, so I ask for a review from someone more experienced, and I'll be happy to refine the PR further if needed. Below is an analysis by Claude Opus 5.5 which guided me on the fix. A QMK workaround exists but I'd obviously prefer to fix the root cause and not apply workarounds in QMK.
Thank you! Let me know what you think!
- Jan