Updating device firmware¶
This guide shows how to use the nRF Cloud firmware over-the-air (FOTA) update service.
Requirements¶
This guide is written for devices using the nRF9160 SiP. Devices using the nRF Cloud FOTA service must be provisioned, but are not required to use MQTT.
Thingy:91 and nRF9160 DK devices are factory programmed with older versions of Asset Tracker v1 and modem firmware. Asset Tracker v1 is now deprecated. To update devices using the nRF Cloud FOTA service, you must first program a version of Asset Tracker v2 (or another nRF Cloud FOTA-enabled application) based on the nRF Connect SDK v1.5.0 or later.
Precompiled images for the Thingy:91 and nRF9160 DK are available.
Note
Devices using the nRF Cloud FOTA service through the REST API must use modem firmware v1.3.x, which has its own hardware requirements.
You cannot use the nRF Cloud FOTA service to upgrade to modem firmware v1.3.x from a previous version. Updating to v1.3.x requires a wired connection.
Getting started¶
Devices can access the FOTA service through MQTT or REST.
Protocol | Authentication | Key differences |
---|---|---|
MQTT | Mutual TLS | Requires cloud and certificate provisioning. |
REST | JSON Web Token (JWT) | Requires cloud provisioning, but not certificate provisioning if FOTA is used through the REST API only. |
Click to expand the following sections for more information according to your protocol.
MQTT prerequisites for FOTA¶
When accessing the FOTA service through MQTT:
- Create device certificate.
- Provision the device to your account.
-
Enable the
CONFIG_NRF_CLOUD_MQTT
option to enable FOTA functionality in the application.For more information, including supported FOTA types, see Firmware over-the-air (FOTA) updates in the nRF Cloud library documentation for nRF Connect SDK.
-
Provide the supported FOTA types to nRF Cloud by writing a
fota_v2
field containing an array of FOTA types into theserviceInfo
field in the device's shadow.
For more information, see Device shadows and the FOTA update documentation linked in the previous step.
REST prerequisites for FOTA¶
When accessing the FOTA service through REST:
-
If you only use the REST API, you do not need to provision the certificates to your device.
-
Provision the device to your account.
If you use the
ProvisionDevices
endpoint, you can provide the supported FOTA types during provisioning instead of Step 5. -
To make REST calls, configure a
nrf_cloud_rest_context
structure as described in the nRF Cloud REST library. -
Create a JSON Web Token (JWT) for your device. The JWT must either be signed with the private key used to sign the device certificate, or registered with the
RegisterPublicKeys
endpoint.See authentication for the REST API for more information.
-
Provide the supported FOTA types to nRF Cloud by writing a
fota_v2
field containing an array of FOTA types into theserviceInfo
field in the device's shadow. You do not need to do this if you provided the supported types during provisioning.For more information, see Device shadows in nRF Cloud documentation, and Firmware over-the-air (FOTA) updates in the nRF Cloud library documentation for nRF Connect SDK.
Performing a FOTA update in the nRF Cloud portal¶
This section explains how to update devices through FOTA using the nRF Cloud portal.
Creating a device group¶
Define the scope of the update job by creating a group containing the target devices. If your target devices are already in a group, you can skip this step.
Creating a FOTA bundle¶
The firmware bundle consists of the manifest and binary update file or files in a compressed zip folder. See the UploadFirmware
API reference for an example of an update manifest.
If you have created a bundle already, you can skip these steps.
To create a FOTA bundle:
- Go to the Device Management > Firmware Updates page.
-
In the Bundles card, click the three-dot menu and select New Bundle.
A pop-up opens.
-
Specify the required update type, unique name, version, and optional description.
- Drag and drop the bundle file or click the box to select a file in the file explorer.
- Click Create/Upload Bundle. The bundle now appears in the Bundles card.
Create and deploy the update job¶
Once you have a firmware bundle, create and deploy the update job:
-
Click the Create Update button in the Updates card or the upper right corner of the Firmware Updates page.
If you have previously created update jobs, the card shows your update history instead of an additional Create Update button.
-
Select the target device group and firmware bundle.
Select the Deploy now checkbox to deploy the update at the same time as creating it.
You can also leave this option unselected and deploy later from this page using the Deploy update button.
-
Click the Create Update button. This adds the update job to the Updates card.
A page opens showing update status, with progress indicators for each job execution.
Performing a FOTA update through the REST API¶
To perform a FOTA update using the REST API:
- Define the target device group.
-
Create a firmware bundle using
UploadFirmware
.See the reference documentation for more information about bundle format requirements and an example of a manifest. Note the bundle ID.
-
Create a FOTA job using the
CreateFOTAJob
endpoint with the following JSON-formatted data in the message body:- Firmware bundle ID
- Tags (group name)
- Job name
- Job description
Include
"autoApply": "true"
to begin the deployment at the same time as the job is created. -
Deploy the FOTA job with
ApplyFOTAJob
.This initiates the job execution. If you included
"autoApply": "true"
in your call to create a FOTA job, you do not need to initiate the job execution separately. -
Check the execution status with
FetchFOTAJob
.