-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
RP2350 Watchdog and lightsleep issue #17229
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
Comments
Aside: I am a little hesitant to propose these changes. If the maintainers decide to reject this pull request I will understand. Lightsleep on rp2 is gradually getting more complex and these changes would contribute to that complexity. Fixes RP2040 issue micropython#17228 and RP2350 issue micropython#17229. RP2040 issue is when watchdog timer expires while lightsleep is running the RP2040 will lock up during power-on startup. This occurs because the power-on state machine is configured to not re-initialize the ROSC and lightsleep stopped the ROSC. RP2350 issue is the watchdog timer does not decrement while lightsleep is running. Once lightsleep returns the timer will start decrementing again. This occurs because lightsleep clears the bit CLOCKS_SLEEP_EN1_CLK_SYS_WATCHDOG_BITS while sleeping. I ran the reproduction tests from the two issues. I also ran tests/port/rp2/rp2_lightsleep.py. General alternative. Document that lightsleep and watchdog don't play well together and leave the code as is. Alternatives for RP2040 issue micropython#17228: - Raise issue for pico-sdk. Get them to change function _watchdog_enable() so the ROSC and XOSC do get reset on a watchdog timeout. The existing behavior in _watchdog_enable() has been there from day one. There might not be a good reason for it. Disadvantage: a possible long wait for a new pico-sdk release. - Modify lightsleep to not stop the ROSC. I measure 4.96 milli-amps when lightsleep disables ROSC and 5.09 milli-amps when it does not. This is a small change. Alternatives for the RP2350 issue micropython#17229: - I don't have any :-). Signed-off-by: Carl Pottle <cpottle9@outlook.com>
in RP2350 lightsleep is not working it just pass with no sleep from machine import lightsleep sleep_ms(3000)
|
sorry for the hashtag this is the code with no remark |
@alke lightsleep works fine on a Pico 2. I just ran your code on a Pico 2 with micropython 1.25.0 and it worked. |
Sorry, yes you are right it is not working on Pico 2 W |
Uh oh!
There was an error while loading. Please reload this page.
Port, board and/or hardware
Raspberry Pi Pico2
MicroPython version
MicroPython v1.25.0 on 2025-04-15; Raspberry Pi Pico2 with RP2350
Reproduction
Copy the following into wdt_lightsleep_2350.py.
Do 'mpremote run wdt_lightsleep_2350.py'.
Expected behaviour
Expect the same behavior seen when the lightsleep is replaced with sleep_ms.
File wdt_sleep_ms_2350.py
Note: most of traceback removed.
This time the print did not execute because the watchdog timer triggered during the second sleep_ms(3000).
Observed behaviour
The print statement does execute and the watchdog timer triggers during the last sleep_ms(3000).
Note: most of traceback removed.
Additional Information
I have changes to lightsleep in modmachine.c which fix this problem.
I will prepare a pull request with this fix.
The root cause is the watchdog timer does not count down while lightsleep() is running.
This problem is RP2350 specific and is not seen on RP2040.
Code of Conduct
Yes, I agree
The text was updated successfully, but these errors were encountered: