casaroli opened a new pull request, #20491: URL: https://github.com/apache/nuttx/pull/20491
## Summary Power management for the RP2350. This PR is based on apache/nuttx#20490 (RTC alarm), whose two commits are the first two here; please review the last four. 1. **Fix nxstyle errors** in three files that PM touches, because CI checks the whole file. Whitespace only. 2. **Standby and dormant states.** `PM_STANDBY` is the RP2350 SLEEP state: a WFI with the clocks of the blocks that have no driver gated. `PM_SLEEP` is the DORMANT state: the PLLs and the crystal oscillator stop, as pico-extras does. Only a GPIO dormant-wake detector can end it, so `PM_SLEEP` gives standby when no wake pin is configured (`RP23XX_PM_WAKEUP_GPIO`), while a UART transmits, and for `RP23XX_PM_SLEEP_GUARD_MS` after boot (a dormant chip does not answer SWD). The time of day is taken from the always-on timer after the wake. `RP23XX_PM_QUIESCE_PADS` isolates the unused pads and holds the blocks with no driver in reset, against the static current of floating inputs (erratum RP2350-E9). Three board LED PM callbacks that did not build with `CONFIG_PM` are fixed. 3. **Suspend to RAM (POWMAN P1.0).** The switched core is powered off; the XIP cache and SRAM keep their contents. The chip comes back through the bootrom and the ordinary boot, and `__start` returns to the suspended thread instead of starting the OS. The idle governor never selects it: an application asks for it with the new `BOARDIOC_RP23XX_SUSPEND` boardctl() command (`arch/chip/pm.h`, `BOARDCTL_IOCTL`). The wake is the configured GPIO or the always-on timer alarm. The XIP cache is cleaned first (with the RP2350-E11 workaround), an application RTC alarm is saved and restored, and after the resume the UARTs, the PSRAM format and the dormant-wake GPIOs are set up again. 4. **`raspberrypi-pico-2:pm` and `pimoroni-pico-2-plus:pm`** configurations, with board documentation. The apps side, `examples/pmstress`, is apache/nuttx-apps#APPSPR. It is not needed to build or use this PR. ## Impact rp23xx only, and only with `CONFIG_PM`. `CONFIG_RP23XX_PM` and `CONFIG_RP23XX_PM_SUSPEND` are new and off by default. The start-up code is split into `rp23xx_hwinit()` and `__start`, with no change to a cold boot. Known limits, also in the Kconfig help: - In the dormant state the system tick stops, so timers, `sleep()` and RTC alarms wait for the next GPIO wake. An application that needs them holds a PM state with `boardctl(BOARDIOC_PM_CONTROL)`. - With the console receive pin as the wake pin, the first character that wakes the board is lost. The first characters of output after a wake can also be corrupted. I have not found the cause of the second yet. ## Testing Arm GNU Toolchain 13.2.rel1 (the CI version). Each commit builds; `raspberrypi-pico-2:pm` and `pimoroni-pico-2-plus:pm` build with no warnings; `pimoroni-pico-2-plus:nsh` and `raspberrypi-pico-2:smp` are unchanged. `tools/checkpatch.sh -c -u -m -g` passes. Hardware: Pimoroni Pico Plus 2 W (RP2350B A2, 8 MB PSRAM), `pimoroni-pico-plus-2-w:nsh` with the options of the `pm` configurations and `examples/pmstress`: | test | result | |---|---| | `pmstress suspend 5` | back after 5 s, returned 0, wake source `0x40` (timer); `date` correct | | keypress on the console during `pmstress suspend 60` | back after 0.1 s, wake source `0x2` (GPIO) | | PSRAM word written before a suspend | reads back the new value after it; heap intact | | `alarm 25`, then `pmstress suspend 3` | after the resume "active with 21 seconds to expiration"; the alarm fires | | 45 s idle after the guard | dormant (uptime 9 s for 54 s of wall time), console keypress wakes it, `date` correct | | a suspend, then 45 s idle | the keypress still wakes it | These tests found five bugs in the earlier version of this code, fixed here: dirty PSRAM lines lost across a suspend, the time of day behind after the dormant state, an application alarm overwritten by the timed wake, `rp23xx_rtc_rdalarm()` failing for an inactive alarm, and the dormant-wake GPIO lost after a suspend so that the board never woke again. The suspend current was measured earlier on this branch at 0.365 mA on a Raspberry Pi Pico 2. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
