Usage Guide
Build PM Sample
This sample contains tests for multiple wake-up sources.
Build with the following command:
./nuwa.py build -d rtl8721f_evb//mcuboot -a applications/mcuboot_pm_system_manage --sysbuild
Download the firmware
Power on again, and you will see the following log showing the system entering sleep and being woken up sequentially by rtc, counter, and gpio. To trigger gpio wake-up, connect
PB5to 3.3V15:21:27.245 Going sleep. 15:21:27.245 state: 4 15:21:27.246 [00:00:00.006,000] <inf> soc_pm: call pm_state_set: 4 15:21:29.130 ?NPPW 15:21:29.131 APPW 15:21:29.133 [00:00:00.006,000] <inf> soc_pm: [pm_state_exit_post_ops] AP wake: 4 15:21:29.134 Wake up by: rtc@4080aa00. 15:21:29.134 Created the thread. 15:21:29.135 Going sleep. 15:21:29.136 state: 4 15:21:29.312 [00:00:00.006,000] <inf> soc_pm: call pm_state_set: 4 15:21:29.312 APPG 15:21:29.312 NPPG 15:21:30.137 NPPW 15:21:30.137 APPW 15:21:30.140 [00:00:00.006,000] <inf> soc_pm: [pm_state_exit_post_ops] AP wake: 4 15:21:30.141 Wake up by: counter@40819000. 15:21:30.400 Connect pin gpiob5 with 3.3V to wakeup 15:21:30.400 Created the thread. 15:21:30.401 Going sleep. 15:21:30.401 state: 4 15:21:30.402 [00:00:00.006,000] <inf> soc_pm: call pm_state_set: 4 15:21:30.403 APPG 15:21:38.455 NPPG 15:22:56.501 NPPW 15:22:56.502 APPW 15:22:56.502 [00:00:00.006,000] <inf> soc_pm: [pm_state_exit_post_ops] AP wake: 4 15:22:56.503 Wake up by: gpio@40811400.
Configuration Steps
Enable PM and the wake-up source devices to be used in Kconfig
# Enable PM
CONFIG_PM=y
# Increase stack to avoid crash due to Stack overflow
CONFIG_IDLE_STACK_SIZE=4096
# Enable RTC device as precondition of wakeup-source
CONFIG_RTC=y
CONFIG_RTC_ALARM=y
CONFIG_RTC_AMEBA=y
# Enable timer(counter) device as precondition of wakeup-source
CONFIG_COUNTER=y
# Enable GPIO device as precondition of wakeup-source
CONFIG_GPIO=y
Add the
wakeup-sourceproperty to the wake-up source device in DTS (overlay) to enable its wake-up source function, for example:
&rtc {
status = "okay";
wakeup-source;
};
&gpiob {
status = "okay";
wakeup-source;
};
&timer0 {
status = "okay";
wakeup-source;
};
Initialize the device in the code