Skip to main content
Version: Torizon OS 6.x.y

How to Suspend/Resume on Torizon OS

Introduction

This case-oriented article delves into the process of suspending and resuming a SoM running on Torizon OS. By using a containerized environment, you can achieve low-power modes without root permissions, streamlining the integration of power management strategies into your applications.

Reboot and Suspend/Resume

Altering the power state usually requires root permissions. Since running containers with root (privileged) permissions isn't in best practices, these tasks can be performed without root permissions inside a container. The key to success is using a bind mount for the required files - and it can be applied in many scenarios, not only this one.

From a security perspective, bind mounting /proc/sysrq-trigger, which allows performing some low-level commands, or /var/run/dbus, which provides access to system services, may potentially pose a vulnerability, even though this is probably more secure than a regular non-containerized embedded use case.

Reboot via D-Bus is a more proper way to do it, since it will gently ask all daemons and containers to stop before reboot, while sysrq will not do that. Learn more about sysrq-trigger options in the Linux kernel documentation page Linux Magic System Request Key Hacks to decide if this is acceptable to bind mount in your case.

Prerequisites

Reboot

The below example reboots the device by writing to /proc/sysrq-trigger:

# docker run -it --rm -v /proc/sysrq-trigger:/procw/sysrq-trigger torizon/debian:3-bookworm
## echo "b" > /procw/sysrq-trigger

Or reboot with using D-Bus:

# docker run -it --rm -v /var/run/dbus:/var/run/dbus torizon/debian:3-bookworm
## apt update && apt-get install -y dbus
## dbus-send --system --print-reply --dest=org.freedesktop.login1 /org/freedesktop/login1 "org.freedesktop.login1.Manager.Reboot" boolean:true

It is also possible to use a D-Bus library for your preferred language. If you use Python, you can use our D-Bus Python sample as a starting point.

Suspend and Wake-Up

You can put the system into supported low-power modes without root permissions inside a container. For a general list of supported power modes by our BSP, see the article Suspend/Resume (Linux).

The below examples suspends/resumes the device by writing to the various files:

Suspend and wakeup using RTC

# docker run -it --rm -v /sys/class/rtc/rtc1/wakealarm:/sys/class/rtc/rtc1/wakealarm -v /sys/power/state:/sys/power/state torizon/debian:3-bookworm
## echo +5 > /sys/class/rtc/rtc1/wakealarm; echo mem > /sys/power/state

Suspend and wakeup over UART

# docker run -it --rm -v /sys/class/tty/ttymxc0/power/wakeup:/sys/class/tty/ttymxc0/power/wakeup -v /sys/power/state:/sys/power/state torizon/debian:3-bookworm
## echo enabled > /sys/class/tty/ttymxc0/power/wakeup
## echo mem > /sys/power/state
Press any button to wakeup from suspend...

Some SoMs require to use a different UART (e.g. ttyLP3 on Colibri iMX8X). Check UART (Linux) to learn more about the corresponding UART names for your SoM.



Send Feedback!