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

Device Crashes when Host Device goes to sleep/powers down #23

Open
LibertyBeta opened this issue Aug 9, 2021 · 14 comments
Open

Device Crashes when Host Device goes to sleep/powers down #23

LibertyBeta opened this issue Aug 9, 2021 · 14 comments

Comments

@LibertyBeta
Copy link

LibertyBeta commented Aug 9, 2021

So, odd bug: the device will crash when the host goes into sleep/powers down.

The Display reads "USBerror: USB busy". Doesn't matter if USB memory is set to readonly or not, if usb_cdc is enabled, etc. It seems that any interactions with memory in the main loop while the Host device is in these power states causes the USB issue.

Code can be found here: https://github.com/LibertyBeta/macro_pady

@FoamyGuy
Copy link
Contributor

FoamyGuy commented Aug 9, 2021

Does it crash immediately when the host device goes to sleep or powers off? or only when you press a button that is attempting to send shortcut keys to the host system? Or some other time?

@LibertyBeta
Copy link
Author

LibertyBeta commented Aug 9, 2021 via email

@FoamyGuy
Copy link
Contributor

Can you post the full stack trace that you're seeing? I'm curious to see which lines are initially raising the error.

@LibertyBeta
Copy link
Author

LibertyBeta commented Aug 10, 2021 via email

@LibertyBeta
Copy link
Author

So, after MUCH tracing, looks like the issue is with a macropad.keyboard.release_all() call fouling things up.

@dhalbert
Copy link
Contributor

release_all() sends a report with all the values set to value (nothing is pressed).

@LibertyBeta
Copy link
Author

Yep, but that's what's crashing when the host is disconnected(IE, shutdown).

@hathach
Copy link
Member

hathach commented Aug 13, 2021

maybe this could help, hathach/tinyusb#1020 would you mind switching the lib/tinyusb to branch to tes with https://github.com/hathach/tinyusb/tree/rp2040-disconnect-suspend

@rpavlik
Copy link

rpavlik commented Aug 13, 2021

this is fascinating because I'd like to detect host sleep/powerdown in my code... I tried finding the right place for it in the circuitpython source this morning but had no luck. Right now I'm just doing a timeout based on last interaction.

@LibertyBeta
Copy link
Author

hathach/tinyusb#1020

This has been folding into TinyUSB, just waiting on news of how its going to be upstream into the main build. Still need details on this will interact with the Macropad.

@LibertyBeta
Copy link
Author

Can confirm on most recent firmware that supervisor.runtime.usb_connected reports correctly now, but release, etc, still error. Should be a simple matter of having the lib check the supervisor to make sure there is an active connection before sending the keystrokes.

@mscreations
Copy link

I can confirm that changing the library to include a check for usb_connected at the beginning of all the release functions does seem to solve this issue. I put a check for it at the beginning of my main loop to gracefully shut down and stop doing anything that may call one of those functions which works well.

@p0rt9
Copy link

p0rt9 commented Aug 2, 2022

Is there any update on this bug? I am currently using the Macropad as a boot device to assist some boot time processes and in between bit locker and windows, If any key is pressed the board crashes.

@rpavlik
Copy link

rpavlik commented Aug 3, 2022

I haven't seen this in a while. I would imagine that a new CircuitPython version sometime in the last year probably incorporated the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants