LwM2M: Remote Firmware Updates for IoT Devices Demystified

2023-06-09
关注

Illustration: © IoT For All

As more and more resource-constrained IoT devices are being deployed, firmware updates over the air (FOTA) are becoming increasingly important. As physical access is often expensive, or even impossible to realize when operating large deployments in remote, hard-to-reach locations, FOTA provides a way to fix bugs, patch security vulnerabilities, or add functionality throughout the lifespan of a connected device. Lightweight M2M (LwM2M) defines the process for remote firmware updates in detail. When following the standardized guidelines provided by the protocol, updating the firmware of resource-constrained devices remotely can be accomplished effortlessly, regardless of the device or platform used.

“As more and more resource-constrained IoT devices are being deployed, firmware updates over the air (FOTA) are becoming increasingly important.“

Updating Firmware with LwM2M

Every platform or device vendor can develop a custom FOTA mechanism, also known as FUOTA (Firmware Update OTA) or DFU (Device Firmware Upgrade). As there is no globally unified method to update device firmware, many different implementations can be found on the market.

Embedded developers can simply get one of the available libraries from their specific hardware vendor or cloud service provider to manage the update process. However, these implementations are specific to the vendor or platform and cannot be easily ported to other systems. Adopting a new platform usually means redesigning the FOTA process from scratch.

The problem of vendor compatibility can be resolved by adopting the LwM2M standard, which is hardware agnostic and can be implemented on any hardware platform. The standard provides clear guidelines on how devices should report their data, how remote configuration can be performed using server commands, and how firmware updates can be executed, regardless of the device manufacturer, firmware version, or hardware platform used.

Firmware Update Process

Generally speaking, the LwM2M firmware update process consists of four steps:

  1. The IoT device (referred to as the LwM2M Client) is triggered to initiate the firmware update process.

  2. The LwM2M Client downloads the firmware and reports to the LwM2M Server when the download is finished.

  3. The LwM2M Client performs the firmware update after validating the integrity and authenticity of the new firmware which is done through a process called secure boot.

  4. The Client attempts to run the new firmware and reports the status to the Server. If succeeded, the device starts running the new firmware, if an error is encountered the device performs a rollback to the earlier firmware version.

This procedure is defined in detail in the LwM2M specifications (see LwM2M specifications). To add firmware update capabilities to a device, the Firmware Update Object /5 needs to be implemented containing all essential functionalities for conducting the update and reporting the status. Several LwM2M Clients natively support this Firmware Update Object.

Updating a device’s firmware

Downloading New Firmware

Timing is critical when it comes to firmware updates. If the radio signal quality is poor, transferring data can take a lot of time due to low throughput caused by lost data packets that need to get retransmitted. Since the device’s radio module must be in the connected state for a long time, downloading the file in such circumstances results in a faster battery drain.

The LwM2M standard defines two methods to perform a firmware update, allowing either the Server or the Client to decide on the best moment to initiate the firmware download process. The two methods are PULL and PUSH:

PULL

With the p0ull method, a device receives the location of the file that is to be downloaded and pulls the file from it. In the PULL scenario, the LwM2M Server provides the device with the address of the server containing the firmware file known as the package URI. The device subsequently downloads the firmware from the so-called firmware repository at the earliest available opportunity.

PUSH

An LwM2M Server pushes the firmware file to the device. In the PUSH scenario, the LwM2M Server determines the moment to initiate the firmware download, ideally based on the connectivity conditions. The device must have access to information such as Radio Signal Strength and Link Quality to support such server-side decision-making these resources are available in the LwM2M Connectivity Monitoring Object /4.

Pull vs. push

Firmware Update Object

The FOTA process is defined in the Firmware Update Object /5. This Object defines the update process using four states(defined by Resource/5/*/3), as well as multiple update results(defined by Resource/5/*/5) representing the most common outcomes of the firmware update process.

Firmware update

Firmware Update Object States

State 0: Idle

Before downloading and after successfully updating the firmware, the device reports its state as idle.

State 1: Downloading

The new firmware is on the way from the firmware repository to the Client.

Possible Update Results Errors:

URI resolution failed due to:
Unsupported package type (result 6)
Invalid URI (result 7)
Unsupported protocol (result 9)

Download failed due to:
Insufficient flash memory (result 2)
Insufficient RAM (result 3)
Connection loss (result 4)
Integrity check failed (result 5)

State 2: Downloaded

The firmware download is completed and all packets are received successfully.

State 3: Updating

When the update resource is triggered, the LwM2M Client starts updating its firmware. If the update was performed successfully, the state changes back to Idle (state 0).

Possible Update Results:
Firmware update failed (result 8)
Integrity check failed (result 5)
Firmware updated successfully (result 1)

State 0: Idle

After successfully updating the firmware, the device reports its state as idle and its Update Result as Firmware Updated Successfully.

Firmware updated successfully

Essential Device Updates

Remote IoT device updates are essential for the long-term success of IoT applications. Software bugs and security vulnerabilities will be found when deploying devices in the field which should be operational for years. As physical access to devices is often impossible to realize, FOTA is required for each, if not all IoT deployments.

Updating firmware remotely poses some serious challenges. Devices are constrained in terms of (flash) memory, battery capacity, and available bandwidth, and often use unstable connections to the cloud. The LwM2M standard proposes a method to update the firmware of resource-constrained IoT devices. Through a structured approach with standardized states and error codes, developers can be assured that new firmware images can be safely sent to their fleet of devices in the field, regardless of the hardware vendor or cloud platform used.

Tweet

Share

Share

Email

  • Connectivity
  • Data Analytics
  • Hardware Components
  • Machine Learning
  • Network and Protocols

  • Connectivity
  • Data Analytics
  • Hardware Components
  • Machine Learning
  • Network and Protocols

  • en
您觉得本篇内容如何
评分

相关产品

EN 650 & EN 650.3 观察窗

EN 650.3 version is for use with fluids containing alcohol.

Acromag 966EN 温度信号调节器

这些模块为多达6个输入通道提供了一个独立的以太网接口。多量程输入接收来自各种传感器和设备的信号。高分辨率,低噪音,A/D转换器提供高精度和可靠性。三路隔离进一步提高了系统性能。,两种以太网协议可用。选择Ethernet Modbus TCP\/IP或Ethernet\/IP。,i2o功能仅在6通道以太网Modbus TCP\/IP模块上可用。,功能

雷克兰 EN15F 其他

品牌;雷克兰 型号; EN15F 功能;防化学 名称;防化手套

Honeywell USA CSLA2EN 电流传感器

CSLA系列感应模拟电流传感器集成了SS490系列线性霍尔效应传感器集成电路。该传感元件组装在印刷电路板安装外壳中。这种住房有四种配置。正常安装是用0.375英寸4-40螺钉和方螺母(没有提供)插入外壳或6-20自攻螺钉。所述传感器、磁通收集器和壳体的组合包括所述支架组件。这些传感器是比例测量的。

TMP Pro Distribution C012EN RF 音频麦克风

C012E射频从上到下由实心黄铜制成,非常适合于要求音质的极端环境,具有非常坚固的外壳。内置的幻像电源模块具有完全的射频保护,以防止在800 Mhz-1.2 Ghz频段工作的GSM设备的干扰。极性模式:心形频率响应:50赫兹-18千赫灵敏度:-47dB+\/-3dB@1千赫

ValueTronics DLRO200-EN 毫欧表

"The DLRO200-EN ducter ohmmeter is a dlro from Megger."

评论

您需要登录才可以回复|注册

提交评论

广告
提取码
复制提取码
点击跳转至百度网盘