Firmware Update Methods#
There are two ways to update the SiWx917’s NWP firmware.
Firmware Update via Bootloader
Over The Air (OTA) Firmware Update
Before going through the methods, consider the following figure which illustrates where in NWP Flash memory map, the Firmware Image and Firmware Image Backup areas reside. The Firmware Image location is the target location from where the Firmware executes, and the Firmware Image backup location is used for storing the new Firmware Image temporarily during Firmware update. The Bootloader resides in the ROM.
Firmware Update via Bootloader#
The Bootloader is the first piece of code that executes when the SiWx917 is powered up or reset. It controls the initial operation of the device. In this method, upon SiWx917’s power-up, the firmware update process is carried out by the Bootloader through message exchanges between SiWx917 and host over SPI/UART/SDIO interface. The host can be Tera Term or an external host MCU application.
In this method, the NWP Bootloader can update Firmware Image in one of the two modes:
Non-safe or Fast Update mode
Safe Update mode
The Fast or Safe Update mode can be configured using an SDK v3.x API. This API is not yet implemented.
Non-Safe or Fast Update Mode#
The Non-safe or Fast Update mode is a single-stage Firmware update process that allows the Firmware Image to be placed into the target location of flash memory, overwriting the existing Firmware Image.
Procedure:
Initially, the SiWx917 can be without any firmware (when received for the first time) or can be with some existing firmware say SiWG917-B.a.b.c.d.e.f.rps.
Upon Power up, the SiWx917 boots into Bootloader.
The SiWG917-B.u.v.w.x.y.z.rps is transferred in chunks from host to Bootloader.
As soon as the Bootloader receives a chunk, it transfers the chunk to the Firmware Image location.
After the complete Firmware Image is transferred, the Bootloader verifies the Integrity and Authenticity of the new Firmware Image.
If the Image is valid, the Bootloader executes the new Firmware Image - SiWG917-B.u.v.w.x.y.z.rps, else if the Image is invalid, the Bootloader does not execute the Image.
Note:
In case of the Non-safe Update mode, if the Firmware Image Update is interrupted for any reason, the device shall be left without a functional and valid firmware. During the next power up, the bootloader detects that the existing Firmware Image is not valid anymore and the SiWx917 enters the firmware update mode.
Safe Update Mode#
The Safe Update mode is a two-stage Firmware Update process where the Bootloader places the Firmware Image in a separate download location called “Firmware Image backup” temporarily and then does the integrity and authenticity check of the received image. If the image is valid, the Bootloader replaces the current Firmware Image with the newly verified Firmware Image.
Procedure:
Initially, the SiWx917 can be without any firmware (when received for the first time) or can be with some existing firmware say SiWG917-B.a.b.c.d.e.f.rps.
Upon Power up, the SiWx917 boots into Bootloader.
The SiWG917-B.u.v.w.x.y.z.rps is transferred in chunks from host to Bootloader.
The Bootloader transfers these chunks to Firmware Image backup location of flash in parallel.
After the complete Firmware Image is transferred, the Bootloader verifies the Integrity and Authenticity of the new Firmware Image.
If the Image is valid, the Bootloader will move the new Firmware Image to the target location from where it would run and erase the old firmware data.
The Bootloader loads and executes the new Firmware Image - SiWG917-B.u.v.w.x.y.z.rps, else if the Image is invalid, the Bootloader does not execute the Image.
Note:
In case of Safe Update mode, if the firmware update process is interrupted for any reason, the existing Firmware Image is not affected but the whole process of updating to a new image will have to be repeated from the beginning.
Over The Air (OTA) Firmware Update#
OTA Firmware Update is always performed in a Safe Update mode. In this method, the Firmware file is hosted on the remote Server/Cloud and SiWx917 downloads the Firmware Image wirelessly over a network or Internet.
Procedure:
The firmware file is hosted at a Remote Server/Cloud.
The SiWx917 should have a valid Firmware Image to perform OTA-based Firmware Update.
The host application initializes the SiWx917, drives it to connect to a Wi-Fi Network and indeed connect to the Remote Server/Cloud via TCP or HTTP.
The host application initiates a file download and SiWx917 receives the Firmware Image in chunks.
As soon as it receives a chunk, the SiWx917 firmware writes it to the Firmware Image backup location of flash.
After receiving all the chunks, the Firmware verifies the new Firmware Image by verifying the Integrity and Authenticity of the new Firmware Image based on the RPS Header configuration.
If the image is valid, the current firmware informs the same to host and the host does a soft reset to allow SiWx917 to boot into the bootloader.
The Bootloader finds that a new firmware is available in the Firmware Image backup location and again does an Integrity and Authenticity verification of the Firmware Image.
After the image is verified, if the image is valid, the Bootloader transfers the Firmware Image from the Firmware Image backup location to the target location.