SWUpdate Update Flow¶
SWUpdatePlugin (plugin id swupdate) delegates the actual firmware
install to systemd, and only supervises it.
When the OTA state machine enters its installing state, install_update
starts a fresh transient unit, swupdate@<timestamp>.service, by calling
StartUnit on the system D-Bus. It then returns without waiting for the unit
to finish.
A separate task, monitor_update, polls the unit's ActiveState and
SubState once per second until it reaches a terminal state, then drives the
OTA state machine to update_successful or a failure state. On success,
reboot_system starts systemd-reboot.service to boot into the new firmware.
A successful update reboots the device
Reaching update_successful triggers an immediate system reboot. Any
service or workload running on the device will be interrupted.
Design notes¶
- A transient unit per install. Each attempt uses a uniquely named
instance of the
swupdate@.servicetemplate, isolating its systemd state and leaving a per-attempt journal. - A separate monitor task.
StartUnitonly confirms that systemd accepted the request, so completion is observed asynchronously bymonitor_updateafterinstall_updatereturns. - Reboot only on success. A failed install leaves the current, working
firmware in place; only
update_successfultriggers the reboot.
Relationship to the OTA state machine¶
install_update and monitor_update implement, for systemd, the generic
transitions Py ToloMEO's OTA state machine defines. See the
OTA State Machine
reference for the states and transitions, and
OTA Mechanism
for how the FSM, checkpointing, and plugin hooks fit together across any
OTAPlugin.