An Over-The-Air (OTA) update is wireless delivery of new software or data, configuration settings to device. In WICED, there are two snips to demonstrate OTA updates: apps/snip/ota_fr and apps/snip/ota2_example.
The update mechanism of OTA supports starting a SoftAP and perform a manual upload of a new application to replace the current application.
OTA2 has more functionalities compared to OTA.
Please refer to WICED-OTA2.pdf available in 43xxx_Wi-Fi\doc folder of WICED SDK Installation directory for more information about OTA2.
The major differences between OTA and OTA2 are tabulated below:
Update main application
Update check can be timed periodically
Update components checked with CRC
Yes, upon download and at extraction.
Update All parts of system
Yes, excluding bootloader
Keep User DCT Settings
DCT saved to separate area. Application must explicitly update the DCT data
OTA: Please follow the link for testing ota_fr snip: WICED OTA Upgrade and Factory Reset (SDK 3.1.2 through WICED Studio 4.x)
OTA2: Please follow the link for testing ota2_example snip: OTA2 Update for SDK-3.7.0
Further implementation details of OTA2 are mentioned here:
OTA2 implementation requires nearly 8 MB memory. The memory requirements are shown in the table. In WICED, the memory map for CYW943907AEVAL1F is defined in: 43xxx_Wi-Fi\platforms\CYW943907AEVAL1F\ota2_image_defines.mk.
|16K||Bootloader(Bootloader size can be <32K but for secure boot it should be <16K)|
|128K||OTA2 Failsafe Application(snip/ota2_failsafe)|
OTA2 Image- Factory Restore Area
(includes reset DCT+LUT*+filesystem+OTA2 Extractor**+Application size)
|16K||OTA2 DCT Save area (used to keep the DCT data after an upgrade so that DCT data can be recovered)|
|32K||DCT copies(DCT1 and DCT2)|
|4K||Application Look up Table(LUT*)|
|512K||Filesystem(includes WiFi Firmware)|
|256K||OTA2 Extractor**(can start using SoftAP,DHCP server and Web Server)|
|256K||Medium sized Application(WiFi)|
OTA2 Image- Staging Area
(includes new DCT+LUT* filesystem+OTA2 Extractor**+Application size)
TOTAL + Application Size
*LUT: Look Up Table- in the WICED Multi-Application Framework, this is a directory where the system(App, DCT, Resources) is located in FLASH.
**OTA2 Extractor is an application which extracts the application images and loads in the current application area.
The highlighted area in the table shows the images that OTA2 works with. There are 3 images:
- Current application image: This is the current application running in your device.
- OTA2_image- Staging Area: This is the image to be updated and it is stored in the staging area in memory. There is support for background downloading of OTA2 Update image from file server or manually providing the image through web server.
- OTA2_image- Factory reset image: If the device enters an unknown state during update (due to power loss or connection loss or error in extraction of ota2_image), this image is extracted and is loaded in the current application area. On a power loss error, the ota2_extractor first tries to extract the last thing that was being extracted. So if the image in the staging area was being extracted and the power failed, the system will first try to use the staging area before resorting to the Factory Reset Area.
Different type of images that can be generated in WICED are:
- ota2_image: OTA2 Image suitable for upgrade server
- ota2_download: OTA2 Image suitable for upgrade server + download to SFLASH OTA2 Staging Area at end of build
- ota2_factory_image: OTA2 Factory Reset Image
- ota2_factory_download: OTA2 Factory Reset Image + download to FLASH OTA2 Factory Reset Area at end of build
- ota2_manuf_download: Creates and downloads manufacturing image
For creating an OTA2 update image, the application should be build as follows: <folder>.<app_name>-<platform_name> ota2_image
This creates a binary file OTA2_image_file.bin which is located at ../build/snip.<app_name>-<platform_name>/OTA2_image_file.bin(This is the file which is provided for update through Webserver or through client's designated update server).
The functioning of OTA2 requires three applications:
- OTA2 Bootloader
- OTA2 Failsafe
- OTA2 Extract
These applications are already built and downloaded when the Ota2_example snip is executed. Few details about these applications are mentioned here:
OTA2 Bootloader: On boot, ota2_bootloader checks the OTA2 Staging Area downloaded Image status and the OTA2 Factory Reset Image status and the Factory Reset Button.
If download status says Extract on Reboot ---->>> start ota2_extract to start extraction from the Staging Area
else if button(USER_1) hold ~5 seconds ---->>> start ota2_extract to start the SoftAP, DHCP server and web server for manual update
else if button hold ~10 seconds or force_factory_reset is set in the DCT --->>> start ota2_extract to extract the Factory Reset Image
else --->>> start current application
If power loss occurs during extraction, the ota2 bootloader checks the boot_type from DCT and decides on the image to be extracted. It extracts the apps LUT and ota2_extractor from the staging area or the factory restore area to restore enough of the system to do a full extraction.
OTA2 Failsafe: waf/ota2_failsafe
This application is loaded from the bootloader when needed to provide extraction of the Application LUT and snip/ota2_extract to allow for full extraction on reboot. The OTA2 Failsafe Application can restore a system to the valid OTA2 image in the Staging Area or the OTA2 Factory Reset Image if the system fails to boot(device was reset during OTA2 extraction). It is required for all builds, and is automatically built and downloaded with the ota2_bootloader.
OTA2 Extract: snip/ota2_extract
This application does all the extraction functionality for a normal extraction. It can also run the SoftAP, DHCP, and Web Server when instructed to do so by the ota2_bootloader. You need to build the ota2_extract application before building your full application. It is automatically downloaded when the ota2_example application is build as the make file of ota2_example points to the binary of ota2_extract. Following directives should be added in the make file of application for OTA2 support
#OTA SoftAp application
OTA_APPLICATION := snip.ota2_extract-$(PLATFORM)
OTA_APP := build/$(OTA_APPLICATION)/binary/$(OTA_APPLICATION).stripped.elf
As already discussed in the Bootloader section, the ota2_extract application is extracted from the OTA2 staging area/OTA2 factory restore area hence it should be a part of the update image. To include ota2_extract in the image, the OTA_APP directive should be added to the make file of the application as mentioned above.