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

Chibios USB: Take into account if host wants remote wakeup or not #21287

Conversation

purdeaandrei
Copy link
Contributor

Description

According to the USB 2.0 spec, remote wakeup should be disabled by
default, and should only be enabled if the host explicitly requests
it. The chibios driver code already takes care of storing this
information, and returning it on GET_STATUS requests. However our
application code has been ignoring it so far.

This is a USB compliance issue, but also a bug that causes trouble
in some cases: On RP2040 targets this has been causing problems if
a key is held down while the keyboard is plugged in. The keyboard
would fail to enumerate until all keys are released. With this
change that behavior is fixed.

Note that for LUFA targets this is already done correctly.

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

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).

According to the USB 2.0 spec, remote wakeup should be disabled by
default, and should only be enabled if the host explicitly requests
it. The chibios driver code already takes care of storing this
information, and returning it on GET_STATUS requests. However our
application code has been ignoring it so far.

This is a USB compliance issue, but also a bug that causes trouble
in some cases: On RP2040 targets this has been causing problems if
a key is held down while the keyboard is plugged in. The keyboard
would fail to enumerate until all keys are released. With this
change that behavior is fixed.

Note that for LUFA targets this is already done correctly.
Copy link
Contributor

@lesshonor lesshonor left a comment

Choose a reason for hiding this comment

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

I'd love to see this merged into master under bugfix criteria. Immediately useful. Guaranteed to resolve bewildering boot failures caused by soldering or other assembly errors, which are most often made by folks who lack the equipment and/or experience to realize they even have a hardware problem...let alone the knowledge required to apply the changes in this PR without causing repository headaches later.

Personally: I was attempting to test firmware written for integrated RP2040 using the only device I had handy, a WeAct Pi Pico. GP23 is a column pin in this firmware's COL2ROW matrix.

Turns out the KEY button on WeAct's Pi Pico causes GP23 to be pulled to ground until pressed. Couldn't get it to enumerate until a hunch got me to rebase on this PR; only then did I realize what was going on with the tact switch.

Will try to test on other ChibiOS-supported hardware when I am able.

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.

At least, it doesn't seem to break anything.

@drashna drashna requested a review from a team June 24, 2023 08:47
@purdeaandrei
Copy link
Contributor Author

@drashna Should I rebase and retarget it to master, or leave it as it is? A strict reading of the docs suggests all core changes go to develop, but I have had a different bugfix for a core regression merged to master recently, so seems like there are exceptions sometimes.

@lesshonor Please correct me if I'm wrong, I notice that your approval is a different color on github from drashna's and even though I have seen you very active around here, I think that implies you're not on the official list of approvers, right? I agree with all you said, and would be happy to rebase to master, if everybody agrees.

When it comes to non-rp2040 targets, I played around with STM32 in the past, I don't remember seeing the boot failure behavior, but if that's the case, it's probably because some differences in the USB stack. I believe it's still wrong and a USB compliance issue to not check that bit, an example scenario where we are probably non-usb compliant would be if we have one of our keyboards and another device on a hub, and if the OS is configured to not wake up from the keyboard, but wake up from the other device, (so we would never receive a set_feature to enable remote wakeup) maybe the hub could be combining the wakeup signals, so we could end up waking the host even though the host didn't want it. I am not sure if host/hub ports remember if there are any remote wakeup enabled devices under them. I didn't test if this actually happens.

@KarlK90 KarlK90 added the bug label Jun 25, 2023
@KarlK90
Copy link
Member

KarlK90 commented Jun 25, 2023

@purdeaandrei thanks for your investigation and subsequent bug fix, as the problem is real but an edge case which is not encountered to frequently (at least that is my impression but I can be wrong ofc) I would rather merge this into develop and see if there is any fallout from the changes.

@KarlK90 KarlK90 merged commit 3ebdb12 into qmk:develop Jun 26, 2023
jesperhellberg pushed a commit to jesperhellberg/qmk_firmware that referenced this pull request Sep 9, 2023
…k#21287)

According to the USB 2.0 spec, remote wakeup should be disabled by
default, and should only be enabled if the host explicitly requests
it. The chibios driver code already takes care of storing this
information, and returning it on GET_STATUS requests. However our
application code has been ignoring it so far.

This is a USB compliance issue, but also a bug that causes trouble
in some cases: On RP2040 targets this has been causing problems if
a key is held down while the keyboard is plugged in. The keyboard
would fail to enumerate until all keys are released. With this
change that behavior is fixed.

Note that for LUFA targets this is already done correctly.
thismarvin pushed a commit to thismarvin/qmk_firmware that referenced this pull request Sep 27, 2023
…k#21287)

According to the USB 2.0 spec, remote wakeup should be disabled by
default, and should only be enabled if the host explicitly requests
it. The chibios driver code already takes care of storing this
information, and returning it on GET_STATUS requests. However our
application code has been ignoring it so far.

This is a USB compliance issue, but also a bug that causes trouble
in some cases: On RP2040 targets this has been causing problems if
a key is held down while the keyboard is plugged in. The keyboard
would fail to enumerate until all keys are released. With this
change that behavior is fixed.

Note that for LUFA targets this is already done correctly.
akeep pushed a commit to akeep/qmk_firmware that referenced this pull request Oct 2, 2023
…k#21287)

According to the USB 2.0 spec, remote wakeup should be disabled by
default, and should only be enabled if the host explicitly requests
it. The chibios driver code already takes care of storing this
information, and returning it on GET_STATUS requests. However our
application code has been ignoring it so far.

This is a USB compliance issue, but also a bug that causes trouble
in some cases: On RP2040 targets this has been causing problems if
a key is held down while the keyboard is plugged in. The keyboard
would fail to enumerate until all keys are released. With this
change that behavior is fixed.

Note that for LUFA targets this is already done correctly.
csolje pushed a commit to csolje/qmk_firmware that referenced this pull request Oct 21, 2023
…k#21287)

According to the USB 2.0 spec, remote wakeup should be disabled by
default, and should only be enabled if the host explicitly requests
it. The chibios driver code already takes care of storing this
information, and returning it on GET_STATUS requests. However our
application code has been ignoring it so far.

This is a USB compliance issue, but also a bug that causes trouble
in some cases: On RP2040 targets this has been causing problems if
a key is held down while the keyboard is plugged in. The keyboard
would fail to enumerate until all keys are released. With this
change that behavior is fixed.

Note that for LUFA targets this is already done correctly.
jashort pushed a commit to jashort/qmk_firmware that referenced this pull request Nov 20, 2023
…k#21287)

According to the USB 2.0 spec, remote wakeup should be disabled by
default, and should only be enabled if the host explicitly requests
it. The chibios driver code already takes care of storing this
information, and returning it on GET_STATUS requests. However our
application code has been ignoring it so far.

This is a USB compliance issue, but also a bug that causes trouble
in some cases: On RP2040 targets this has been causing problems if
a key is held down while the keyboard is plugged in. The keyboard
would fail to enumerate until all keys are released. With this
change that behavior is fixed.

Note that for LUFA targets this is already done correctly.
autoferrit pushed a commit to SpaceRockMedia/bastardkb-qmk that referenced this pull request Dec 8, 2023
…k#21287)

According to the USB 2.0 spec, remote wakeup should be disabled by
default, and should only be enabled if the host explicitly requests
it. The chibios driver code already takes care of storing this
information, and returning it on GET_STATUS requests. However our
application code has been ignoring it so far.

This is a USB compliance issue, but also a bug that causes trouble
in some cases: On RP2040 targets this has been causing problems if
a key is held down while the keyboard is plugged in. The keyboard
would fail to enumerate until all keys are released. With this
change that behavior is fixed.

Note that for LUFA targets this is already done correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants