Ota
概述
OTA技术(Over-the-Air Technology)是一种允许数据和服务通过无线方式远程发送到移动设备的技术。 我们为用户提供完备的固件升级服务流程,具体可参考ota.md。
API 介绍
Defines
-
OTA_SIZE_UNKNOWN
Used for wq_ota_begin() if new image size is unknown
-
IMAGE_DESC_MAGIC_WORD
The magic word for the image_desc_t structure.
-
TLV_ID_FW_HASH
-
TLV_ID_FW_SIG
Typedefs
-
typedef struct image_desc_t image_desc
image header description , describe information of compressed image block.
-
typedef struct secure_tlv_header secure_tlv_header_t
Description about secure tlv data header.
-
typedef struct secure_ota_firmware_header secure_ota_firmware_header_t
Description about secure image header.
-
typedef uint32_t ota_handle_t
Opaque handle for an application OTA update.
wq_ota_begin() returns a handle which is then used for subsequent calls to wq_ota_write() and wq_ota_end().
Functions
-
WQ_RET wq_ota_begin(size_t image_size, ota_handle_t *out_handle)
Commence an OTA update writing to the specified zone.
The ota zone is erased to the specified compressed ota package size.
If package size is not yet known, pass 0 or OTA_SIZE_UNKNOWN which will cause the entire zone to be erased.
On success, this function allocates memory that remains in use until wq_ota_end() is called with the returned handle.
- 参数:
image_size -- Size of new OTA compressed package image. Ota zone will be erased in order to receive this size of image. If 0 or OTA_SIZE_UNKNOWN, the entire zone is erased.
out_handle -- On success, returns a handle(>0) which should be used for subsequent wq_ota_write() and wq_ota_end() calls.
- 返回:
WQ_RET_OK: OTA operation commenced successfully.
WQ_RET_*: zone or out_handle arguments were NULL,or other internal error happened,like erase flash failed
-
WQ_RET wq_ota_resume_begin(size_t image_size, uint32_t offset, ota_handle_t *out_handle)
Commence an OTA update with resume broken transfe.
On success, this function allocates memory that remains in use until wq_ota_end() is called with the returned handle.
- 参数:
image_size -- Size of new OTA compressed package image. Ota zone will be erased in order to receive this size of image. If 0 or OTA_SIZE_UNKNOWN, the entire zone is erased.
offset -- offset of wrote data in ota zone.
out_handle -- On success, returns a handle(>0) which should be used for subsequent wq_ota_write() and wq_ota_end() calls.
- 返回:
WQ_RET_OK: OTA operation commenced successfully.
WQ_RET_*: zone or out_handle arguments were NULL,or other internal error happened,like erase flash failed
-
WQ_RET wq_ota_write_data(ota_handle_t handle, const void *data, size_t size, uint32_t offset)
Write OTA compressed package to OTA zone.
This function can be called multiple times as data is received during the OTA operation. Data is written sequentially to flash.
- 参数:
handle -- Handle obtained from wq_ota_begin
data -- Data buffer to write
size -- Size of data buffer in bytes.
offset -- Flash write offset of ota partition.
- 返回:
WQ_RET_OK: Data was written to flash successfully.
WQ_RET_*: ota not begin firstly or handle arguments were NULL,or other internal error happened,like write flash failed
-
WQ_RET wq_ota_read_data(ota_handle_t handle, void *data, size_t size, uint32_t offset)
Read OTA compressed package from OTA zone.
- 参数:
handle -- Handle obtained from wq_ota_begin
data -- Data buffer from read
size -- Size of data buffer in bytes.
offset -- Flash read offset of ota partition.
- 返回:
WQ_RET_OK: Data was read to flash successfully.
WQ_RET_*: ota not begin firstly or handle arguments were NULL,or other internal error happened,like read flash failed
-
WQ_RET wq_ota_verify(ota_handle_t handle)
OTA update and validate newly written app image.
- 参数:
handle -- Handle obtained from wq_ota_begin().
- 返回:
WQ_RET_OK: Newly written OTA app image is valid.
WQ_RET_*: OTA handle was not found.
-
WQ_RET wq_ota_end(ota_handle_t handle)
Finish OTA update and release OTA handle.
备注
After calling wq_ota_end(), the handle is no longer valid and any memory associated with it is freed.
- 参数:
handle -- Handle obtained from wq_ota_begin().
- 返回:
WQ_RET_OK: Newly written OTA app image is valid.
WQ_RET_*: OTA handle was not found.
-
WQ_RET wq_ota_commit(bool reboot)
Commit flag which enable OTA image to flash.
备注
Pleace call this API After calling wq_ota_end() finished correctly
- 参数:
reboot -- True will do soft reboot when commit flag finished, otherwise only commit flag to flash.
- 返回:
WQ_RET_OK: Enable ota flag OK.
WQ_RET_*: Enable ota flag Failed.
-
uint32_t wq_ota_get_base_addr(void)
Get OTA partition's flash mapping address.
- 返回:
uint32_t is flash mapping address.
-
uint32_t wq_ota_get_space_size(void)
Get OTA partition's flash size.
- 返回:
uint32_t is flash size.
-
struct image_desc_t
- #include <ota.h>
image header description , describe information of compressed image block.
-
struct pack_desc_t
- #include <ota.h>
Description about image.
-
struct secure_tlv_header
- #include <ota.h>
Description about secure tlv data header.
-
struct secure_ota_firmware_header
- #include <ota.h>
Description about secure image header.