nRF5 SDK for Thread and Zigbee v3.2.0
Macros | Functions
Low level API for OTA

Macros

#define OTA_UPGRADE_HEADING_DATA   (sizeof(zb_zcl_ota_upgrade_file_header_t) + 2 /* fw tag Id */ + 4 /* fw length */)
 
#define OTA_UPGRADE_HASH_SIZE   16
 
#define OTA_UPGRADE_TRAILING_DATA   (2 /* hash tag Id */ + 4 /* hash length */ + OTA_UPGRADE_HASH_SIZE /* Hash */)
 

Functions

void * zb_osif_ota_open_storage (void)
 
void zb_osif_ota_close_storage (void *dev)
 
void zb_osif_ota_erase_fw (void *dev, zb_uint_t offset, zb_uint_t size)
 
zb_uint32_t zb_osif_ota_get_erase_portion (void)
 
void zb_osif_ota_write (void *dev, zb_uint8_t *data, zb_uint32_t off, zb_uint32_t block_size, zb_uint32_t image_size)
 
void zb_osif_ota_mark_fw_ready (void *ota_dev, zb_uint32_t size, zb_uint32_t revision)
 
void zb_osif_ota_mark_fw_absent (void)
 
void zb_osif_ota_mark_fw_updated (void)
 
zb_bool_t zb_osif_ota_verify_integrity (void *dev, zb_uint32_t raw_len)
 
zb_bool_t zb_osif_ota_verify_integrity_async (void *dev, zb_uint32_t raw_len)
 
zb_void_t zb_osif_ota_verify_integrity_done (zb_uint8_t integrity_is_ok)
 
void zb_osif_ota_read (void *dev, zb_uint8_t *data, zb_uint32_t addr, zb_uint32_t size)
 
zb_bool_t zb_osif_ota_fw_size_ok (zb_uint32_t image_size)
 
zb_uint8_tzb_osif_ota_srv_get_image (void *dev, zb_uint32_t offset, zb_uint32_t len)
 
zb_uint8_tzb_osif_ota_srv_get_image_header (void *dev)
 

Detailed Description

Function Documentation

void zb_osif_ota_close_storage ( void *  dev)

Close device used for OTA image write

Parameters
devflash device handle used to write OTA image
See also
zb_osif_ota_open_storage
void zb_osif_ota_erase_fw ( void *  dev,
zb_uint_t  offset,
zb_uint_t  size 
)

Erase flash to be used for OTA image store.

Note: offset and size must be aligned to minimal eraseable page boundary -

See also
zb_osif_ota_get_erase_portion().
Parameters
devflash device handle
See also
zb_osif_ota_open_storage
Parameters
offsetfile offset in flash memory
sizeOTA file image size
zb_bool_t zb_osif_ota_fw_size_ok ( zb_uint32_t  image_size)

Check that image size is not too big

Parameters
image_sizeOTA file image size
Returns
ZB_TRUE if ok, ZB_FALSE if error
zb_uint32_t zb_osif_ota_get_erase_portion ( void  )

Get portion of OTA storage which can be erased at once.

Returns
erase block size in bytes
void zb_osif_ota_mark_fw_absent ( void  )

Mark new FW as absent so bootloader does not attempt to re-flash it.

To be called when starting OTA.

void zb_osif_ota_mark_fw_ready ( void *  ota_dev,
zb_uint32_t  size,
zb_uint32_t  revision 
)

Mark FW as downloaded and ready to use by bootloader.

To be called when finishing OTA, after FW loaded and verified.

Parameters
ota_devflash device handle used to write OTA image
See also
zb_osif_ota_open_storage
Parameters
sizeOTA image size, without CRC
revisionOTA image revision
void zb_osif_ota_mark_fw_updated ( void  )

Mark FW upgrade finished, so bootloader just loads current FW.

To be called from newly started application FW. Usually not need to be called by the application. ZBOSS kernel cares about it.

void* zb_osif_ota_open_storage ( void  )

Open device to be used for OTA image write or read.

Take into account which flash (A or B) current FW is running at.

See also
zb_osif_ota_close_storage
Returns
handle
zb_uint8_t* zb_osif_ota_srv_get_image ( void *  dev,
zb_uint32_t  offset,
zb_uint32_t  len 
)

Get OTA image data at OTA server

Parameters
devflash device handle used to write OTA image
See also
zb_osif_ota_open_storage
Parameters
offsetoffset in the OTA image
len- length of image block to get
Returns
pointer to image block
zb_bool_t zb_osif_ota_verify_integrity ( void *  dev,
zb_uint32_t  raw_len 
)

Verify OTA file image written to device dev.

Parameters
devflash device handle used to write OTA image
See also
zb_osif_ota_open_storage
Parameters
raw_len- OTA image file length
Returns
ZB_TRUE if ok, ZB_FALSE if error
void zb_osif_ota_write ( void *  dev,
zb_uint8_t data,
zb_uint32_t  off,
zb_uint32_t  block_size,
zb_uint32_t  image_size 
)

Write OTA image data to flash.

Deal with alignment.

Parameters
devflash device handle
See also
zb_osif_ota_open_storage
Parameters
datapointer to the data to write
offoffset in OTA file
block_sizeamount of data to write
image_sizetotal image size

Documentation feedback | Developer Zone | Subscribe | Updated