Skip to content

OTA State Machine

OTAStateMachine tracks one firmware update.

State Diagram

OTA State Machine — light mode OTA State Machine — dark mode

States

The state is the status of every OTA command reply and the otaStatus of every status event.

State Checkpointed Description
bootstrapping No Startup: reads the checkpoint and resolves to a state
updated Deleted No update pending. Idle state
update_available Yes An update was notified
downloading Yes The package is downloading
paused Yes The download is paused
download_failed Yes The download failed
update_ready Yes The package is downloaded and ready to install
updating No The package is installing
update_failed Yes The install failed
update_successful Deleted The install succeeded. Final state: no transition leaves it

Checkpointed tells what entering the state does to the checkpoint file: Yes writes it, Deleted removes it, No leaves the previous one in place.

Transitions

Trigger From To Fired by
notify updated, update_available update_available NotifyOTAUpdate
download update_available, download_failed downloading StartOTADownload
pause downloading paused Download task paused
resume paused downloading Download task resumed
download_fail downloading, paused download_failed Download task failed
download_success downloading update_ready Download task completed
install update_ready, update_failed updating The plugin's install_update
update_fail updating update_failed The plugin, on install failure
update_success updating update_successful The plugin, on install success
abort download_failed, update_failed update_available AbortOTAUpdate
clear update_available updated ClearOTAUpdate
cancel downloading, paused, update_ready update_available CancelOTAUpdate
reset Any except updating, update_successful bootstrapping ResetOTAState, plugin startup

Bootstrap Transitions

bootstrapping reads the checkpoint and fires one detect_* trigger:

Checkpointed state Trigger To
None, unreadable, or unknown detect_up_to_date updated
update_available detect_update_available update_available
downloading, paused detect_download_paused paused
update_ready, package present detect_update_ready update_ready
download_failed detect_download_error download_failed
update_failed, package present detect_update_error update_failed
update_ready or update_failed, package missing detect_update_available update_available

The pending update is checked first, with the same version rule as NotifyOTAUpdate. An update that fails the check is dropped and bootstrapping fires detect_up_to_date.

See also

  • OTA Commands — the commands that fire the transitions
  • OTA Mechanism — why the update is a state machine and how the checkpoint works