Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged

Conversation

projectgus
Copy link
Contributor

@projectgusprojectgus commentedJun 19, 2024
edited
Loading

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 callsclocks_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 amachine.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.

@codecovCodecov
Copy link

codecovbot commentedJun 19, 2024
edited
Loading

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.42%. Comparing base(cfa55b4) to head(f60c71d).

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.
📢 Have feedback on the report?Share it here.

@github-actionsGitHub Actions
Copy link

Code size report:

   bare-arm:    +0 +0.000% minimal x86:    +0 +0.000%    unix x64:    +0 +0.000% standard      stm32:    +0 +0.000% PYBV10     mimxrt:    +0 +0.000% TEENSY40        rp2:    +0 +0.000% RPI_PICO_W       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS

@dpgeorge
Copy link
Member

Maybe we should report this to pico-sdk, and potentially they can add this argument toclocks_init()?

But for now, patching it here is OK.

Can you please split out the addition of our copy ofclocks_init() to a separate commit and update the top-level LICENSE? See8438c87

projectgus reacted with thumbs up emoji

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>
@projectgusprojectgusforce-pushed thebugfix/rp2_usb_lightsleep branch fromc1fa5e3 to068d9bfCompareJune 25, 2024 06:26
@projectgus
Copy link
ContributorAuthor

Can you please split out the addition of our copy ofclocks_init() to a separate commit and update the top-level LICENSE? See8438c87

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>
@projectgus
Copy link
ContributorAuthor

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.

@dpgeorge
Copy link
Member

All looks good, thank you!

@dpgeorgedpgeorge merged commitf60c71d intomicropython:masterJun 25, 2024
28 checks passed
@projectgusprojectgus deleted the bugfix/rp2_usb_lightsleep branchJune 26, 2024 00:19
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@projectgus@dpgeorge

[8]ページ先頭

©2009-2025 Movatter.jp