Update Flow Overview
Introduction
This page documents the complete end-to-end update flow in AosCore — the sequence of operations that occurs when AosCloud sends a new desired state to a Unit. The flow covers both SOTA (software) and FOTA (firmware) deployments, showing how the Communication Manager (CM) orchestrates image downloads, configuration changes, service launches, and status reporting.
Understanding this flow is essential for OEMs who need to predict deployment timing, diagnose update failures, or integrate external Update Managers for firmware components.
Update Flow Sequence
The following diagram shows the end-to-end update flow as a sequence across the participating components:
loading...Flow Phases
The update flow proceeds through six sequential phases, each corresponding to a state in the CM Update Manager's state machine. The state is persisted to storage on every transition, enabling crash recovery.
1. Trigger (Cloud → CM)
The flow begins when AosCloud sends a desired-state message to the Unit over the WebSocket JSON connection. The desired state contains the complete target configuration:
| Field | Content |
|---|---|
| Nodes | Target state for each Node (provisioned or paused) |
| Unit config | Target configuration version |
| Deployable Items | Service images and firmware components with versions and OCI index digests |
| Instances | Which services to run, how many, with priority and placement labels |
| Certificates | TLS certificates needed for image Verification |
The CM Update Manager receives the desired state via ProcessDesiredStatus() and compares it against the current state.
If differences are detected, an update cycle begins. If the desired state matches the current state, no action is taken.
If a new desired state arrives while an update is already in progress, the current update is cancelled and the new one begins — the Unit always converges toward the most recent target.
2. Downloading
State: Downloading
The CM Update Manager instructs the Image Manager to download all required Deployable Item images that are not already present locally:
- The Image Manager resolves each item's OCI index digest to determine which layers need downloading
- Layers are downloaded from the URLs specified in the desired state
- Each downloaded layer is verified against its SHA-256 digest
- Successfully downloaded images are stored in the local image store
If any download fails (network error, integrity check failure, insufficient storage), the update transitions to an error state and the failure is reported to AosCloud.
3. Pending
State: Pending
All required images have been downloaded and verified. The system is ready to proceed with the actual update. This state exists as a checkpoint — the Update Manager confirms all prerequisites are met before making changes to the running system.
4. Installing
State: Installing
The CM applies configuration changes that must take effect before launching new service instances:
- Node state changes — Nodes are transitioned to their target state (provisioned or paused)
- Unit configuration — If the desired state includes a new Unit configuration version, it is applied through the Unit Config module
These changes prepare the environment for the new service instances.
5. Launching
State: Launching
This is where the actual deployment happens. The behavior differs between SOTA and FOTA:
SOTA (Software Updates)
The CM sends a RunInstances command to each Service Manager (SM) via gRPC. The command contains:
| Field | Purpose |
|---|---|
services | Service images to make available (ID, version, URL, SHA-256, size) |
layers | OCI layers required by the services |
instances | Specific instances to run (identity, UID, priority, storage paths, network config) |
force_restart | Whether to force-restart already-running instances |
The SM receives this command and:
- Stops instances that are no longer in the desired set
- Downloads any service images or layers it doesn't have locally (using URLs from the command)
- Starts new instances with the specified configuration
- Reports per-instance status back to CM via
RunInstancesStatus
FOTA (Firmware Updates)
For firmware components, the CM communicates with registered external Update Managers (UMs) through the UMService gRPC
protocol:
- CM sends
PrepareUpdatewith component information (ID, type, version, URL, SHA-256, size) - The UM downloads and prepares the firmware image
- The UM reports
UpdateStatuswith statePREPARED - CM sends
StartUpdateto apply the firmware - The UM applies the update (may require reboot)
- The UM reports
UpdateStatuswith stateUPDATED
6. WaitingActive
State: WaitingActive
After launching, the CM waits for all instances and components to reach their target state:
- SOTA: The CM monitors
RunInstancesStatusmessages from each SM, waiting for all instances to report a running state - FOTA: The CM monitors
UpdateStatusmessages from each UM, waiting for all components to reportINSTALLEDstate
This phase has a 10-minute timeout. If not all components reach their target state within this window, the update is considered failed.
7. Finalizing
State: Finalizing
Once all instances and components are active:
- The installed Deployable Items are committed as the current set in the database
- The full Unit status (all nodes, services, instances, components) is assembled
- The
UnitStatusmessage is sent to AosCloud over the WebSocket connection - The update state resets to
None(idle)
The Unit is now running the new desired state and is ready for the next update cycle.
Error Handling
If any phase fails, the update flow handles the error as follows:
| Failure Point | Behavior |
|---|---|
| Download failure | Update cancelled; error reported to cloud; system remains on previous state |
| Configuration failure | Update cancelled; error reported to cloud |
| SM launch failure | Instance error reported; CM waits for timeout then reports failure |
| UM prepare/start failure | UM reports FAILED state with error; CM may send RevertUpdate |
| Timeout in WaitingActive | Update considered failed; error status reported to cloud |
For FOTA updates, the CM can send a RevertUpdate command to the UM if StartUpdate fails, allowing the firmware to
roll back to the previous version before ApplyUpdate commits it permanently.
Crash Recovery
The CM Update Manager persists its state to the database on every state transition using the StorageItf interface:
StoreUpdateState()— saves the current state machine positionStoreDesiredStatus()— saves the desired status being processed
If the CM process crashes and restarts, it reads the persisted state and desired status from the database and resumes the update from the last completed phase. This prevents partial deployments from leaving the Unit in an inconsistent state.
Cancellation
If a new desired state arrives while an update is in progress:
- The current update is marked for cancellation (
mCancelCurrentUpdate) - The update thread detects the cancellation flag at the next state transition
- The pending desired status is stored and becomes the new target
- A new update cycle begins from the Downloading phase with the latest desired state
This ensures the Unit always converges toward the most recently received desired state from AosCloud.
Update Scheduler API
External systems can trigger and monitor updates through the UpdateSchedulerService gRPC API (proto version 3):
| RPC | Purpose |
|---|---|
StartSOTAUpdate | Triggers a software update cycle using the last received desired state |
StartFOTAUpdate | Triggers a firmware update cycle using the last received desired state |
SubscribeNotifications | Streams real-time progress notifications with per-component status |
Notifications include UpdateSOTAStatus and UpdateFOTAStatus messages with the current UpdateState (NO_UPDATE,
DOWNLOADING, READY_TO_UPDATE, UPDATING) and details about affected services, layers, and components.
Related Pages
- Deployment Flows — section overview with deployment architecture and SOTA vs FOTA comparison
- SOTA vs FOTA — detailed comparison of software and firmware update mechanisms
- Update Handler State Machine — complete FOTA Update Manager state machine with module interfaces
- Rollback and Recovery — how failed updates are detected, reverted, and reported
- Update Manager (CM module) — internal architecture of the CM Update Manager
- Service Manager — SM component that executes SOTA deployments on each Node
- Desired State Model — how the desired-state reconciliation model works
- Image Deployment Pipeline — detailed image download and verification flow