System State Framework (SSF) - Experimental


This document describes an extensible design for tracking and publishing the system state for our NG800.

The system state is a simple string variable that reflects the run-level of the overall system (off, booting, starting, up, shutdown-pending, shutting-down, powering-down). This value is published to user applications through the sysfs (file system).

At the core of the design a state machine tracks the system state and processes multiple inputs such as the ignition signal. Before shutting down Linux because of a de-asserted ignition signal, the state machine grants user-space application time to properly shut down. User applications can prolong the shutdown timer if they need more time to terminate. If the timer elapses, the state machine instructs the kernel to shut down.

File System Entries

All the entries are available under the directory /sys/kernel/broker:

  • ignition
    • status of the ignition signal
  • system-state-target
    • state of the system: starting, up, shutdown-pending, …
  • shutdown-delay
    • adding a new delay before shutting down
  • remaining-shutdown-delay
    • countdown with the remaining time until the device shuts down
  • start-reason
    • information about what was the reason for the start-up

Delaying a Shutdown

Let’s assume the default shutdown is 60s and after 30s we notice that we need to delay it for 75s:

echo "75" > /sys/kernel/broker/shutdown-delay

With this command the shutdown countdown start again from 75s.

NOTE: The maximum total delay is 300s.

RTC wake-up

With the SSF the start reason differs also an RTC wake-up form an ignition signal. To set up an RTC wake-up you can just use the linux command rtcwake.

If I want to wake-up my device after 90s from now and in the meanwhile it shall be powered off, I can call this:

rtcwake -s 90 -m off