Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] ChibiOS: shorten USB disconnect state on boot to 50ms #15805

Merged
merged 1 commit into from
Jan 10, 2022

Conversation

KarlK90
Copy link
Member

@KarlK90 KarlK90 commented Jan 9, 2022

Description

(Disclaimer: This is the rationale a came up after reading the USB spec, please feel free the chime in if this is wrong)

A SE0 state for longer then 2.5us signals a device disconnect from the USB bus - according to the USB specs. So the 1500ms are much longer than actually needed and had been copied from the ChibiOS demo code. That code does not state any reason for the long wait.

The new 50ms wait was chosen arbitrarily to be barely noticeable, but to be plenty of time for hosts/hubs that do not adhere to the specs. For split keyboards which rely on a fast enumeration for primary / secondary negotiation this shortens the boot up noticeably.

Also a soft reset for the USB connection should only be necessary for:

  • MCUs with fixed pull-ups on the data lines that always signal readiness
    to establish a USB connection to the host
  • In situations where a system is reset without a real cable disconnect

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Issues Fixed or Closed by This PR

  • Noticeable timeout for ChibiOS based keyboards on boot

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

A SE0 state for longer then 2.5us signals a device disconnect from
the USB bus - according to the USB specs. So the 1500ms are much
longer than actually needed and had been copied from the ChibiOS
demo code. That code does not state any reason for the long wait.

The new 50ms wait was chosen arbitrarily to be barely noticeable,
but to be plenty of time for hosts/hubs that do not adhere to the
specs. For split keyboards which rely on a fast enumeration for
primary / secondary negotiation this shortens the boot up noticeably.

Also a soft reset for the USB connection should only be necessary for:

* MCUs with fixed pull-ups on the data lines that always signal readiness
  to establish a USB connection to the host
* In situations where a system is reset without a real cable disconnect
@github-actions github-actions bot added the core label Jan 9, 2022
Copy link
Member

@drashna drashna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on blackpill split. Works well. And much better startup time.

@drashna drashna requested a review from a team January 9, 2022 20:19
@drashna drashna merged commit 5470e4a into qmk:develop Jan 10, 2022
@KarlK90 KarlK90 deleted the feature/fast-usb-connect branch January 11, 2022 10:21
0xcharly added a commit to 0xcharly/qmk_firmware that referenced this pull request Feb 6, 2022
- qmk#15805: [Core] ChibiOS: shorten USB disconnect state on boot to 50ms
- qmk#15821: Optimize initialization of PMW3360 Sensor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants