-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Implement alarm-module for RP2350 #9965
Conversation
Thanks for doing this! So this will disable some peripherals during light sleep now? Is the RP2350 sleep current high because it doesn't use POWMAN to shutdown ram? |
To be tested, but probably yes, due to the switch to dormant-state. For light-sleep with serial-connection, there should be no change.
I think so, dormant does nothing with other units than the cores. |
Please mark this as a draft PR. The Pico-W (and probably the Pico2-W) need some more investigation. In my tests, the CYW43 did complain with messages like:
There is a Pinging @eightycc: any ideas? |
@bablokb The I'll reproduce the failure here and get back with a more detailed analysis. |
The best source of technical specs for the CYW43439 that I've been able to find is the source code for Infineon's WHD driver: https://github.com/Infineon/wifi-host-driver. The KSO (Keep SDIO On) bit managed by |
In The CYW43439 does expose power management controls, but the best I say for the documentation is that it's murky. There might be an alternative to pulling the plug there? |
@eightycc thanks for your input. I will do some more analyses and tests next week. Maybe it makes more sense to put the driver into a quiescent state and leave the chip as is. Or I will try to reinitialize the chip. Although I don't really like the idea, because currently this is a lengthy process with a hard-coded delay of one whole second. |
Because It may be worthwhile to look into the power management features of the chip exposed by |
I added two small changes:
The code from the PR is now also working for Pico-W and Pico2-W, but it is necessary that the user disables WLAN ( Looking at the measurements, the W variants draw a lot of current, probably more than what can be attributed to the CYW-chip. Light-sleep currently does not touch the CYW, so here is still some room for improvement. The goal would be to bring current draw down to deep-sleep level at least for the RP2350 (which would imply turning of the chip and reinitializing after wakeup). Disabling the radio is currently a task for the user-code. This could be integrated into the firmware. Re-enabling could probably also be done, but re-connecting to the AP will always have to be done by the user (especially if turning off the chip during light-sleep works). This must be cleanly documented. The measurements show considerable improvements for light-sleep and time-alarms (RP2040). The figures for the RP2350 are similar. Pico-W (RP2040)Test-Setups:
¹ connected (Pico2-W) RP2350ATest-Setups:
¹ connected |
@dhalbert: I am still working on this, trying to fix a pin-alarm related problem. I found this piece of code while searching for a solution (see: https://github.com/adafruit/circuitpython/blame/d965980a986c44c3048fd744e7112c5dda782288/ports/raspberrypi/common-hal/alarm/pin/PinAlarm.c#L31):
I don't understand the "if"-part of this. I think to "set it again" I would need both function-calls from the else-part but with Otherwise, I am making good progress. I managed to shutdown (and restart) the CYW-chip, so current in light-sleep is down to deep-sleep levels. I will update the PR as soon as I sorted out the last few problems. |
This is now ready for review (and merging IMHO). I don't know why there is a complaint about a conflict in I also updated the measurements in the comments above. For the Pico-W for example a light-sleep time-alarm is now down from 60mA to below 2mA. |
I changed that file in #10018, which was recently merged. Your PR is against an older commit of that file. So could you rebase or merge from upstream? That should clear the conflict, but check the changes. I think your rework will make that change moot, but try the test program in #10018. Thanks. |
I actually integrated your recent change already. I will try a rebase and see if this resolves the issues. |
Ok, seems I need a new PR since I could not push the rebased branch without deleting my upstream branch. |
@bablokb FYI, a |
|
This PR implements the alarm-module for the RP2350 variant of the pico and fixes #9491.
Notes
light_sleep_until_alarms(maximize_power_save=True)
. But for real life use running on batteries, I cannot imagine that anybody really wants more than the absolute necessary stuff running during sleep.Light-Sleep/Deep-Sleep Current for RP2xxx
All measurements at 5V with Nordic PPKII powering via USB
(i.e. USB-serial not connected).
Notes:
time.sleep()
cpu.frequency = 25000000; time.sleep()
RP2040 (Pico)
RP2350A (Pico2)