OTA Storage Simple EEPROM#

API and Callbacks for the OTA Storage Simple EEPROM Component.

This is a driver for the Over-the-Air simple storage module component. It uses an EEPROM as the underlying storage device. It provides a means to record data being read or written, as well as metadata with information about how far along a client download is. It can be used either by an OTA Client or an OTA Server. Note that this component assumes that the flash storage does not have read-modify-write support. Users should ensure this value matches the flash storage device used by the application. A mismatch between the project-configured value and the actual flash storage support value will result in an application that asserts upon startup.

API#

uint32_t

Returns the OTA Storage EEPROM starting address. This is determined by either ::SL_ZIGBEE_AF_PLUGIN_OTA_STORAGE_SIMPLE_EEPROM_STORAGE_START or the slot start address, if using slots.

uint32_t

Returns the OTA Storage EEPROM end address. This is determined by either ::SL_ZIGBEE_AF_PLUGIN_OTA_STORAGE_SIMPLE_EEPROM_STORAGE_END or the slot end address, if using slots.

uint32_t

Returns the OTA Storage EEPROM image information start address.

Callbacks#

void

Function callback after an EEPROM erase operation completes.

Macros#

#define

This is configured by SL_ZIGBEE_AF_PLUGIN_OTA_STORAGE_SIMPLE_EEPROM_SOC_BOOTLOADING_SUPPORT in ota-storage-simple-eeprom-config.h.

#define

SOC Read-Modify-Write Support which is configured by: SL_ZIGBEE_AF_PLUGIN_OTA_STORAGE_SIMPLE_EEPROM_READ_MODIFY_WRITE_SUPPORT in ota-storage-simple-eeprom-config.h.

#define
EEPROM_START SL_ZIGBEE_AF_PLUGIN_OTA_STORAGE_SIMPLE_EEPROM_STORAGE_START

The begining of the OTA Storage slot.

#define
EEPROM_END SL_ZIGBEE_AF_PLUGIN_OTA_STORAGE_SIMPLE_EEPROM_STORAGE_END

This is the last offset for where the OTA image may be stored in the EEPROM.

#define
SAVE_RATE SL_ZIGBEE_AF_PLUGIN_OTA_STORAGE_SIMPLE_EEPROM_DOWNLOAD_OFFSET_SAVE_RATE

Frequency for Saving Download Offset to EEPROM in bytes.

#define
SLOT_STRATEGY SL_ZIGBEE_AF_PLUGIN_OTA_STORAGE_SIMPLE_EEPROM_GECKO_BOOTLOADER_STORAGE_SUPPORT

The SLOT_STRATEGY defines if the Gecko Bootloader Storage Support.

#define
MAGIC_NUMBER 0x01, 0x09, 0x05, 0x01, 0x00, 0x02, 0x00, 0x00

Magic number to indicate that the stored download meta-data is valid.

#define
VERSION_NUMBER 0x00, 0x00, 0x00, 0x03

Version number information:
0x00000001 - Addition of the Page-erase required support
0x00000002 - Support for 2-byte word sizes (previously-previously 1-byte was assumed)
0X00000003 - Support for 4-byte word sizes (previously 2-byte was assumed)
We changed the size of the bytemask to 512 to support Local Storage which means bumping the version number.

#define
EBL_START_OFFSET_INDEX (VERSION_NUMBER_INDEX + VERSION_NUMBER_SIZE)

The Offset within the OTA file (relative to offset 0) where the GBL data starts.

#define
SAVED_DOWNLOAD_OFFSET_INDEX (EBL_START_OFFSET_INDEX + EBL_START_OFFSET_SIZE)

The last recorded offset we downloaded.

#define

Limits the maximum size of the download image because it determines how many pages we can record as "fully downloaded".

#define
OTA_HEADER_INDEX (SAVED_DOWNLOAD_OFFSET_INDEX + MAX_BYTEMASK_LENGTH)

The OTA header index.

#define
MAX_IMAGE_INFO_AND_OTA_HEADER_SIZE (MAX_BYTEMASK_LENGTH + 1024)

The maximum image information and OTA header size.

#define
MINIMUM_FILE_SIZE_TO_STORE_OFFSET (OTA_MINIMUM_HEADER_LENGTH)

The minimum offset we will write that determines if we store the current download offset persistently.

API Documentation#

otaStorageEepromGetStorageStartAddress#

uint32_t otaStorageEepromGetStorageStartAddress ()

Returns the OTA Storage EEPROM starting address. This is determined by either ::SL_ZIGBEE_AF_PLUGIN_OTA_STORAGE_SIMPLE_EEPROM_STORAGE_START or the slot start address, if using slots.

Returns

  • A ::uint32_t value indicating the starting address


otaStorageEepromGetStorageEndAddress#

uint32_t otaStorageEepromGetStorageEndAddress ()

Returns the OTA Storage EEPROM end address. This is determined by either ::SL_ZIGBEE_AF_PLUGIN_OTA_STORAGE_SIMPLE_EEPROM_STORAGE_END or the slot end address, if using slots.

Returns

  • A ::uint32_t value indicating the end address.


otaStorageEepromGetImageInfoStartAddress#

uint32_t otaStorageEepromGetImageInfoStartAddress ()

Returns the OTA Storage EEPROM image information start address.

Returns

  • A ::uint32_t value indicating the image information start address


Callbacks Documentation#

sl_zigbee_af_ota_storage_simple_eeprom_erase_complete_cb#

void sl_zigbee_af_ota_storage_simple_eeprom_erase_complete_cb (bool success)

Function callback after an EEPROM erase operation completes.

Parameters
TypeDirectionArgument NameDescription
bool[out]success

The result of the erase operation. Ver.: always

The input parameter will be set to true if the EEPROM erase returned :EEPROM_SUCCESS.


Macro Definition Documentation#

SOC_BOOTLOADING_SUPPORT_ENABLED#

#define SOC_BOOTLOADING_SUPPORT_ENABLED
Value:
false

This is configured by SL_ZIGBEE_AF_PLUGIN_OTA_STORAGE_SIMPLE_EEPROM_SOC_BOOTLOADING_SUPPORT in ota-storage-simple-eeprom-config.h.

This option enables bootloading support for SOC devices. When enabled, it will re-map the OTA image file so that the GBL data is at the top of the EEPROM and therefore can be accessed by all existing bootloaders. It requires that the GBL portion of the image is the first TAG in the file. The OTA storage starting offset should be 0 when this is enabled.


SOC_BOOTLOADING_SUPPORT_TEXT#

#define SOC_BOOTLOADING_SUPPORT_TEXT
Value:
"no"

READ_MODIFY_WRITE_SUPPORT_TEXT#

#define READ_MODIFY_WRITE_SUPPORT_TEXT
Value:
"no"

SOC Read-Modify-Write Support which is configured by: SL_ZIGBEE_AF_PLUGIN_OTA_STORAGE_SIMPLE_EEPROM_READ_MODIFY_WRITE_SUPPORT in ota-storage-simple-eeprom-config.h.

This indicates to the OTA code whether the underlying EEPROM driver has support for 'read-modify-write'. Read-modify-write assumes a page erase is not required prior to writing, and any location or length of data can be re-written. If not present, then the OTA code will note each full page of data downloaded and must erase entire pages before downloading a chunk of data.


EEPROM_START#

#define EEPROM_START
Value:
SL_ZIGBEE_AF_PLUGIN_OTA_STORAGE_SIMPLE_EEPROM_STORAGE_START

The begining of the OTA Storage slot.

This is defined by SL_ZIGBEE_AF_PLUGIN_OTA_STORAGE_SIMPLE_EEPROM_STORAGE_START set in the ota-storage-simple-eeprom-config.h file.


EEPROM_END#

#define EEPROM_END
Value:
SL_ZIGBEE_AF_PLUGIN_OTA_STORAGE_SIMPLE_EEPROM_STORAGE_END

This is the last offset for where the OTA image may be stored in the EEPROM.

This is defined by SL_ZIGBEE_AF_PLUGIN_OTA_STORAGE_SIMPLE_EEPROM_STORAGE_END set in the ota-storage-simple-eeprom-config.h file.


SAVE_RATE#

#define SAVE_RATE
Value:
SL_ZIGBEE_AF_PLUGIN_OTA_STORAGE_SIMPLE_EEPROM_DOWNLOAD_OFFSET_SAVE_RATE

Frequency for Saving Download Offset to EEPROM in bytes.

If set to 0 it will always be written to EEPROM. This is only used for "read-modify-write" drivers.


SLOT_STRATEGY#

#define SLOT_STRATEGY
Value:
SL_ZIGBEE_AF_PLUGIN_OTA_STORAGE_SIMPLE_EEPROM_GECKO_BOOTLOADER_STORAGE_SUPPORT

The SLOT_STRATEGY defines if the Gecko Bootloader Storage Support.

It can be configured to:
<DO_NOT_USE_SLOTS=> Do not use slots
<USE_FIRST_SLOT=> Use first slot
<USE_LAST_SLOT=> Use last slot
<USE_SPECIFIC_SLOT=> Use specific slot
This option dictates the method for saving OTA images to slots. This is only applicable if a Gecko storage bootloader is running on the chip. The Slot Manager plugin must be selected in order for slots to be used. If a Gecko storage bootloader is not present on the chip, the offsets entered below will be used. If "Do not use slots" is selected, then the offsets entered below will be used to determine where to save the image. This is not recommended, as using set offsets to addresses with a Gecko storage bootloader requires knowledge of storage slot addresses and boundaries. A mismatch in addresses will cause OTA to not work.


MAGIC_NUMBER#

#define MAGIC_NUMBER
Value:
0x01, 0x09, 0x05, 0x01, 0x00, 0x02, 0x00, 0x00

Magic number to indicate that the stored download meta-data is valid.


VERSION_NUMBER#

#define VERSION_NUMBER
Value:
0x00, 0x00, 0x00, 0x03

Version number information:
0x00000001 - Addition of the Page-erase required support
0x00000002 - Support for 2-byte word sizes (previously-previously 1-byte was assumed)
0X00000003 - Support for 4-byte word sizes (previously 2-byte was assumed)
We changed the size of the bytemask to 512 to support Local Storage which means bumping the version number.


EBL_START_OFFSET_INDEX#

#define EBL_START_OFFSET_INDEX
Value:
(VERSION_NUMBER_INDEX + VERSION_NUMBER_SIZE)

The Offset within the OTA file (relative to offset 0) where the GBL data starts.

We assume GBL data starts right after the 1st tag meta-data. However OTA headers are variable in size so we must keep track of how big the header is. This #define is actually the LOCATION where that offset is stored, not the actual offset.


EBL_START_OFFSET_SIZE#

#define EBL_START_OFFSET_SIZE
Value:
4

SAVED_DOWNLOAD_OFFSET_INDEX#

#define SAVED_DOWNLOAD_OFFSET_INDEX
Value:
(EBL_START_OFFSET_INDEX + EBL_START_OFFSET_SIZE)

The last recorded offset we downloaded.

This may not be the same as the value stored in RAM by the OTA cluster itself. This value will be the absolute offset of the file, regardless of the re-mapping this code does. It is an offset understood by the OTA storage interfaces relative to the start of the OTA file.


MAX_BYTEMASK_LENGTH#

#define MAX_BYTEMASK_LENGTH
Value:
1024

Limits the maximum size of the download image because it determines how many pages we can record as "fully downloaded".


OTA_HEADER_INDEX#

#define OTA_HEADER_INDEX
Value:
(SAVED_DOWNLOAD_OFFSET_INDEX + MAX_BYTEMASK_LENGTH)

The OTA header index.


MAX_IMAGE_INFO_AND_OTA_HEADER_SIZE#

#define MAX_IMAGE_INFO_AND_OTA_HEADER_SIZE
Value:
(MAX_BYTEMASK_LENGTH + 1024)

The maximum image information and OTA header size.


MINIMUM_FILE_SIZE_TO_STORE_OFFSET#

#define MINIMUM_FILE_SIZE_TO_STORE_OFFSET
Value:
(OTA_MINIMUM_HEADER_LENGTH)

The minimum offset we will write that determines if we store the current download offset persistently.

This is equal to the minimum OTA header size.