[Core] ChibiOS: Fix USB bus disconnect handling #18566
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
usb_disconnect()
previously only stopped the USB driver but didn't disconnect the device from USB bus. This is a problem with split keyboards that fail to enumerate on bootup but are actually connected to a USB bus. This can happen in the case that a shortSPLIT_USB_TIMEOUT
is used but it takes longer to enumerate with the host system correctly. In this condition the host system would still try to enumerate with the keyboard, as it still recognizes it as a connected device, but never succeed as we already disabled the USB driver. This in turn prevents some systems to boot-up correctly or at least slow down the boot process until the device is finally rejected by the host USB stack.A drive-by fix is the case for rebooting a keyboard without a physical reconnect and not stopping the USB driver before starting it again - which is a violation of ChibiOS state model for the USB driver.
Demo: RP2040 split keyboard that fails to enumerate on boot
With the fix the device is disconnected properly
Without the fix the device is not disconnected and the host tries to enumerate until finally giving up
Types of Changes
Issues Fixed or Closed by This PR
Checklist