Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.2k
rp2: Fix USB PLL glitch during wake from light sleep.#15301
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
rp2: Fix USB PLL glitch during wake from light sleep.#15301
Uh oh!
There was an error while loading.Please reload this page.
Conversation
codecovbot commentedJun 19, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@## master #15301 +/- ##======================================= Coverage 98.42% 98.42% ======================================= Files 161 161 Lines 21248 21248 ======================================= Hits 20914 20914 Misses 334 334 ☔ View full report in Codecov by Sentry. |
Code size report:
|
Maybe we should report this to pico-sdk, and potentially they can add this argument to But for now, patching it here is OK. Can you please split out the addition of our copy of |
Adapts pico-sdk clocks_init() into clocks_init_optional_usb() which takesan argument to initialise USB clocks or not.To avoid a code size increase the SDK clocks_init() function is linkerwrapped to become clocks_init_optional_usb(true).This work was funded through GitHub Sponsors.Signed-off-by: Angus Gratton <angus@redyak.com.au>
Follow-up toa84c7a0, this commit works most of the time but has anintermittent bug where USB doesn't resume as expected after waking fromlight sleep.Turns out waking calls clocks_init() which will re-initialise the USB PLL.Most of the time this is OK but occasionally it seems like the clockglitches the USB peripheral and it stops working until the next hard reset.Adds a machine.lightsleep() test that consistently hangs in the firsttwo dozen iterations on rp2 without this fix. Passed over 100 times in arow with this fix.The test is currently rp2-only as it seems similar lightsleep USB issuesexist on other ports (both pyboard and ESP32-S3 native USB don't send anydata to the host after waking, until they receive something from the hostfirst.)This work was funded through GitHub Sponsors.Signed-off-by: Angus Gratton <angus@redyak.com.au>
c1fa5e3
to068d9bf
Compare
No worries, done. PTAL! |
In this mode, XOSC is stopped so can't really keepthe USB PLL enabled.Signed-off-by: Angus Gratton <angus@redyak.com.au>
Added one more small commit to always disable USB if going to DORMANT mode with no external oscillator. Have also raised a feature request with pico-sdk, see link above. |
All looks good, thank you! |
f60c71d
intomicropython:masterUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Follow-up to#15111, that change works most of the time but has an intermittent bug where USB doesn't resume as expected after waking from light sleep. Thanks to@GitHubsSilverBullet who reported it here:https://github.com/orgs/micropython/discussions/14401#discussioncomment-9675017
Turns out waking calls
clocks_init()
which will re-initialise the USB PLL. Most of the time this is OK but occasionally it seems like the clock glitches the USB peripheral and it stops working until the next hard reset.Adds a
machine.lightsleep()
test that consistently hangs in the first two dozen iterations of a single test run on rp2 without this fix. Passed over 100 full test runs in a row with this fix.The test is currently rp2-only as it seems similar lightsleep USB issues exist on other ports (both pyboard and ESP32-S3 native USB don't send any data to the host after waking, until they receive something from the host first.)
EDIT: Added one more small commit to always disable USB if there is no timeout (i.e. entering DORMANT mode where the external oscillator is disabled.)
This work was funded through GitHub Sponsors.