Skip to the content.

FOTA Module

The FOTA (Firmware Over-The-Air) module manages remote firmware updates for both application and modem firmware. It handles all the stages of the update process:

The update process begins when the module receives a FOTA_POLL_REQUEST message, typically triggered by the main application module. When an update is available, the module automatically initiates the download without requiring additional commands.

The module supports three firmware image types:

Application and delta modem images are marked ready for their respective bootloaders after download is completed and applied automatically on the next device reboot. When these downloads complete successfully, the module publishes a FOTA_SUCCESS_REBOOT_NEEDED message to indicate that a reboot is required to apply the update.

Full modem updates require that the device disconnects from the network before applying the update. For these updates, the module first sends a FOTA_IMAGE_APPLY_NEEDED message. The main application must then:

  1. Disconnect from the cellular network
  2. Send a FOTA_IMAGE_APPLY message to the FOTA module
  3. Wait for the FOTA_SUCCESS_REBOOT_NEEDED message that indicates successful application of the new modem firmware.

All update operations feature error handling with appropriate status messages, allowing the application to recover gracefully from download failures or interruptions.

Messages

The FOTA module communicates via the zbus channel FOTA_CHAN, using input and output messages defined in fota.h. All input messages are requests from the application to the FOTA module. The output messages may be responses to input messages or notifications from the FOTA module to the application.

Input Messages

Output Messages

Configurations

The following Kconfig options can be used to customize the FOTA module’s behavior:

State diagram

stateDiagram-v2
    [*] --> STATE_RUNNING

    state STATE_RUNNING {
        [*] --> STATE_WAITING_FOR_POLL_REQUEST

        STATE_WAITING_FOR_POLL_REQUEST --> STATE_POLLING_FOR_UPDATE : FOTA_POLL_REQUEST

        STATE_POLLING_FOR_UPDATE --> STATE_DOWNLOADING_UPDATE : FOTA_DOWNLOADING_UPDATE
        STATE_POLLING_FOR_UPDATE --> STATE_WAITING_FOR_POLL_REQUEST : FOTA_NO_AVAILABLE_UPDATE

        STATE_DOWNLOADING_UPDATE --> STATE_WAITING_FOR_IMAGE_APPLY : FOTA_IMAGE_APPLY_NEEDED
        STATE_DOWNLOADING_UPDATE --> STATE_REBOOT_PENDING : FOTA_SUCCESS_REBOOT_NEEDED
        STATE_DOWNLOADING_UPDATE --> STATE_WAITING_FOR_POLL_REQUEST : FOTA_DOWNLOAD_CANCELED/TIMED_OUT/FAILED

        STATE_WAITING_FOR_IMAGE_APPLY --> STATE_IMAGE_APPLYING : FOTA_IMAGE_APPLY

        STATE_IMAGE_APPLYING --> STATE_REBOOT_PENDING : FOTA_SUCCESS_REBOOT_NEEDED

        STATE_CANCELING --> STATE_WAITING_FOR_POLL_REQUEST : FOTA_DOWNLOAD_CANCELED
    }

    STATE_RUNNING --> STATE_CANCELING : FOTA_DOWNLOAD_CANCEL

    STATE_REBOOT_PENDING --> [*] : System reboot