Skip to content

Basic Firmware Update#

Remotely update the firmware of your LwM2M device using the Firmware Update Object /5.

Prerequisites#

  • An active Coiote IoT DM user account
  • A device which supports Firmware Update Object /5

Note

The Anjay LwM2M Client supports the Firmware Update Object. Learn more about Anjay by visiting the official Anjay Documentation site or Anjay SDK on GitHub.

Firmware Update Object /5#

The Firmware Update process is defined in the Firmware Update Object /5. This Object contains Resources which define the update process using 4 Update States (representing the phase of the update process) and 11 Update Results (representing the most common outcomes of the firmware update process).

  • Resource /5/*/3 represents the State
  • Resource /5/*/5 represents the Update Result
ID State Description
state 0 Idle Before downloading and after successfully updating
state 1 Downloading The new firmware is on the way
state 2 Downloaded The firmware download is completed
state 3 Updating The Client starts updating its firmware, after which it changes its state back to Idle
Result Description
update result 0 Initial value
update result 1 Firmware updated successfully
update result 2 Insufficient flash memory for the new firmware package
update result 3 Out of RAM during downloading proces
update result 4 Connection lost during downloading process
update result 5 Integrity check failure for new downloaded package
update result 6 Unsupported package type
update result 7 Invalid URI
update result 8 Firmware update failed
update result 9 Unsupported protocol
update result 10 Firmware update cancelled
update result 11 Firmware update deferred

Info

Learn more about the Firmware Update Object in the OMA LwM2M Object and Resource Registry.

Prepare the Firmware Update#

  1. In the Coiote IoT Device Management platform, go to Device Inventory.

  2. Select the device you want to update by clicking on its endpoint name.

  3. Go to the Data model tab to validate if the Firmware Update Object /5 is present. If so, the Object is supported by the LwM2M Client.

    Firmware update object

  4. Go to the Firmware update tab.

  5. Click the Update Firmware button.

    Update Firmware Tab

  6. Select Basic Firmware Update.

    Basic Firmware Update

  7. Upload the firmware image.

    Upload Firmware Image

  8. Choose between Pull and Push:

    • Pull method (recommended): The LwM2M Client receives the URI of the file that is to be downloaded and pulls the file from it.

    • Push method: The LwM2M Server pushes the firmware file to the device.

    Info

    Pull supports the following transport types:

    • CoAP or CoAPs over UDP
    • CoAP or CoAPs over TCP
    • HTTP or HTTPs

    Push transmits the firmware over the same transport type as is used for device management, which is CoAPs over UDP by default.

    Which transport protocol to choose?

    Downloads using CoAP(s) over UDP tend to be slow due to the limitation of the maximum CoAP Block size of 1024 bytes and the required acknowledgements for each Block transfer.

    Choosing CoAP(s) over TCP or HTTP(s) usually results in faster download speeds. However, not every device supports these transport protocols.

    Basic Firmware Update

  9. Click Schedule Update to trigger the Firmware Update process.

Download & Upgrade Process#

If the Firmware Update is scheduled successfully, the device starts downloading the firmware at the next practical opportunity. The actual firmware update starts once the integrity and authenticity of the firmware image has been validated by the LwM2M Client.

Upgrading

Once executed successfully, the status in the Update list panel changes to Success.

Successful update

Note

While the device is updating its firmware, it will deregister and reboot using the new firmware. This process may time several minutes.

Deregistered while upgrading

Monitoring the update process#

During the update process, the status of the firmware update can be monitored by reviewing the Resources State /5/*/3 and Update Results /5/*/5.

To find the Resources, select the Data model tab and open the Firmware Update Object /5.

Firmware upgraded

If no errors occur, the update process follows this pattern:

  1. Downloading state 1 & update result 0
  2. Downloaded state 2 & update result 0
  3. Updating state 3 & update result 0
  4. Updated state 0 & update result 1

Update successful?

Does the State /5/*/3 report 0 and the Update Results /5/*/5 report 1? Congratulations! You've successfully updated the firmware of your device. 🎉

Troubleshooting#

Firmware Update only works over CoAP, not over CoAPs#

For the firmware update over CoAPs transfer to work, the LwM2M Client shall use the same security credentials (i.e. PSK or certificates) as those used for the management interface. This is the default behavior of the Anjay client, but you might need to configure it explicitly when using other LwM2M Client implementations.

Zephyr LwM2M Client configuration instruction

The security tags needs to the same in the "Security tag for FOTA download library" as in the "LwM2M server TLS tag" (e.g. using Nordic's default tag: 35724861).

To update the security tags, edit the Kconfig in the directory:

Zephyr Kernel
> Modules
    > nrf
    > Nordic nRF Connect
        > Networking
        > Application protocols
            > LwM2M client utilities library
            > Security object support
            > Firmware Update object support

Kconfig update Kconfig editor in nRF Connect for VS Code


Last update: July 19, 2023