This guide provides instructions on how to manually test suspend and resume on a device running a suitable Workbench image.
Perform manual suspend and resume
With serial
Connect to the device via USB.
Take an Application Activity lease via
ffx power's helper component:ffx power suspend preventDrop the session wake lease:
ffx session drop-power-leaseDisconnect USB to eliminate the persistent wake lease caused by the USB or charger connection.
Either physically unplug the USB cable, or, if the device supports
cable-breaker, disconnect USB in software and schedule an automatic reconnect over serial:usb-cli cable-breaker --duration 15sEnsure
--durationis long enough to run the next command and allow the device to suspend before USB automatically reconnects.Using serial, drop the Application Activity lease and reacquire it after a delay:
powerutil suspend prevent --restart --wait-time 5sThis will allow the system to suspend as long as no other wake leases are active.
Wait until serial logs show evidence of system suspension. Logs are not necessarily flushed prior to suspension, so you may see them abruptly stop.
Reconnect USB (or wait for the
cable-breaker--durationtimer to expire and automatically reconnect USB) or take another suitable action (touch, button press, etc.) to resume the device. If--wait-timehas elapsed, the helper component will reacquire an Application Activity lease and prevent further suspension on its own.
Without serial
Connect to the device via USB.
Take an Application Activity lease via
ffx power's helper component:ffx power suspend preventDrop the session wake lease:
ffx session drop-power-leaseDrop the Application Activity lease (reacquiring it after a delay) and disconnect USB to eliminate the persistent wake lease caused by the USB or charger connection:
Physical unplug: Run the following command and unplug the USB cable before
--wait-timeelapses:ffx power suspend prevent --restart --wait-time 5sUsing
cable-breaker: Becauseffx power suspend prevent --restartblocks until--wait-timeelapses, run it in the background and immediately invokecable-breakerwith a--durationlonger than--wait-time:ffx power suspend prevent --restart --wait-time 5s & ffx component explore /core/usb-policy -c "usb-cli cable-breaker --duration 15s"
Wait for several seconds. Without a serial connection, you will not be able to confirm whether suspension has occurred until USB is reconnected.
Reconnect USB (or wait for the
cable-breaker--durationtimer to expire and automatically reconnect USB).Use
ffx logto look for evidence of suspension. There isn't a canonical message to indicate this, but at time of writing, the kernel messageINFO: Suspending non-boot CPUs...is a good indicator. You can also checksuspend_statsvia Inspect:ffx inspect show bootstrap/system-activity-governor:root/suspend_stats
Troubleshooting
Check cable-breaker support
To check whether your device supports software USB disconnect via
usb-cli cable-breaker, verify that /core/usb-policy exposes
fuchsia.usb.policy.Configuration:
ffx component capability fuchsia.usb.policy.ConfigurationCheck wake leases
Any active wake leases prevent the system from suspending. To check active wake leases:
Serial
inspect show bootstrap/system-activity-governor:root/wake_leasesUSB
ffx inspect show bootstrap/system-activity-governor:root/wake_leasesIncrease delay before wake lease reacquisition
To give the system longer to suspend, increase the delay using the --wait-time
option:
powerutil suspend prevent --restart --wait-time 10s