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

WIP: rp2: Make GPIO wakeup from lightsleep consistent.#16442

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

Draft
projectgus wants to merge1 commit intomicropython:master
base:master
Choose a base branch
Loading
fromprojectgus:bugfix/rp2_lightsleep_indefinite_wake

Conversation

projectgus
Copy link
Contributor

@projectgusprojectgus commentedDec 18, 2024
edited
Loading

Summary

Make thePin.irq() wakeup behaviour more consistent on rp2.Closes#7035 and partial fix for#16180

Goal is that any pin which hasPin.irq() and atrigger set will wake rp2 port from anymachine.lightsleep() call.

Details

Currently:

  • A Pin with an irq() trigger is a wakeup source only whenmachine.lightsleep(n) is used with a timeout, and only if an IRQ handler is set.

After this PR:

  • A Pin with an irq() trigger is a wakeup source from both indefinitemachine.lightsleep() andmachine.lightsleep(n) with a timeout.

  • A Pin with an irq() trigger is a wakeup source even if no handler function is set.

TODOs

  • Waking RP2040 repeatedly frommachine.lightsleep() with no timeout and USB causes the USB connection to misbehave and eventually the CPU hangs. This is the same thing fixed for lightsleep with a timeout inrp2: Selectively leave the USB clocks enabled in light sleep. #15111 andrp2: Fix USB PLL glitch during wake from light sleep. #15301 . However, with no timeout argument the RP2 goes to the lower power "DORMANT" mode so keeping USB clock running isn't an option. Callingtud_disconnect()/tud_connect() ortud_deinit()/tud_init() before and after going to dormant mode doesn't seem to be enough to fix this. One heavy-handed workaround would be to not select DORMANT if USB is enabled, just call WFI instead. However, then the wakeup conditions are a lot different which may be confusing if developing and testing via USB and then deploying...
  • Test on RP2350. I have hardware coming, otherwise help is welcome.
  • This implementation doesn't match the machine.Pin docs re: irq(wake=) argument. However, I think only cc3200 port has actually implemented this argument as documented, so the fix here might be to make the docs match the current reality rather than the other way around.

This work was funded through GitHub Sponsors.

Testing

  • TBD

Trade-offs and Alternatives

  • It seems likemachine.lightsleep() has had very limited utility until now (i.e. no possible wake source?) so maybe we should refactor to only use DORMANT mode for deep sleep where we don't have to worry about recovering the USB peripheral. Keeping clocks running does increase consumption, though.

Before this commit:- A Pin with an irq() trigger is a wakeup source only when  machine.lightsleep(n) is used with a timeout, and only if an IRQ handler  is set.After this commit:- A Pin with an irq() trigger is a wakeup source from both  indefinite machine.lightsleep() and machine.lightsleep(n) with  a timeout.- A Pin with an irq() trigger is a wakeup source even if no handler  function is set.Issues at present:- Waking RP2040 repeatedly from machine.lightsleep() with no timeout and  USB causes the USB connection to misbehave and eventually the CPU hangs.- This implementation doesn't match the machine.Pin docs re: irq(wake=)  argument. However, I think only cc3200 port has actually implemented  this argument as documented.This work was funded through GitHub Sponsors.Signed-off-by: Angus Gratton <angus@redyak.com.au>
@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:   +24 +0.003% RPI_PICO_W       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS  qemu rv32:    +0 +0.000% VIRT_RV32

@Gadgetoid
Copy link
Contributor

Just ran afoul of this while testing#16454 so I'm dropping a cross reference in for posterity.

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.

rp2: Can't wake from lightsleep with Pin IRQ
2 participants
@projectgus@Gadgetoid

[8]ページ先頭

©2009-2025 Movatter.jp