144 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			144 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /****************************************************************************
 | |
| 
 | |
| Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
 | |
| 
 | |
| This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
 | |
| be copied by any method or incorporated into another program without
 | |
| the express written consent of Aerospace C.Power. This Information or any portion
 | |
| thereof remains the property of Aerospace C.Power. The Information contained herein
 | |
| is believed to be accurate and Aerospace C.Power assumes no responsibility or
 | |
| liability for its use in any way and conveys no license or title under
 | |
| any patent or copyright and makes no representation or warranty that this
 | |
| Information is free from patent or copyright infringement.
 | |
| 
 | |
| ****************************************************************************/
 | |
| 
 | |
| #ifndef _IOT_BT_EXT_DFU_PROTOCOL_H_
 | |
| #define _IOT_BT_EXT_DFU_PROTOCOL_H_
 | |
| 
 | |
| #ifdef __cplusplus
 | |
| extern "C" {
 | |
| #endif
 | |
| 
 | |
| /* dfu protocol notify requst code */
 | |
| #define IOT_BT_EXT_DFU_NOTIFY_REQ                       0x01
 | |
| /* dfu protocol notify response code */
 | |
| #define IOT_BT_EXT_DFU_NOTIFY_RSP                       0x02
 | |
| 
 | |
| /* dfu error code success */
 | |
| #define IOT_BT_EXT_DFU_ERR_SUCCESS                      0x00
 | |
| /* dfu error code fail */
 | |
| #define IOT_BT_EXT_DFU_ERR_FAIL                         0x01
 | |
| /* dfu error packet len */
 | |
| #define IOT_BT_EXT_DFU_ERR_LENGTH                       0x02
 | |
| /* dfu error prog */
 | |
| #define IOT_BT_EXT_DFU_ERR_PROG                         0x03
 | |
| /* dfu error erase */
 | |
| #define IOT_BT_EXT_DFU_ERR_ERASE                        0x04
 | |
| /* dfu error invalid */
 | |
| #define IOT_BT_EXT_DFU_ERR_INVALID                      0x05
 | |
| /* dfu error notify id */
 | |
| #define IOT_BT_EXT_DFU_ERR_NOTIFY                       0x06
 | |
| /* dfu error operate code */
 | |
| #define IOT_BT_EXT_DFU_ERR_OPCODE                       0x07
 | |
| 
 | |
| #pragma pack(push)
 | |
| #pragma pack(1)
 | |
| 
 | |
| /* bt upgrade operate code */
 | |
| typedef enum _iot_bt_ext_dfu_opcode {
 | |
|     IOT_BT_EXT_DFU_OPCODE_START_DFU = 0x01,
 | |
|     IOT_BT_EXT_DFU_OPCODE_WR_IMG,
 | |
|     IOT_BT_EXT_DFU_OPCODE_CHK_FW_VLD,
 | |
|     IOT_BT_EXT_DFU_OPCODE_IMG_RST,
 | |
|     IOT_BT_EXT_DFU_OPCODE_SYS_RST,
 | |
|     IOT_BT_EXT_DFU_OPCODE_RPT_TGT_INFO,
 | |
|     IOT_BT_EXT_DFU_OPCODE_MAX
 | |
| } iot_bt_ext_dfu_opcode_t;
 | |
| 
 | |
| /* upgrade protocol format */
 | |
| typedef struct _iot_bt_ext_dfu_hdr {
 | |
|     /* notify id */
 | |
|     uint8_t notify_id;
 | |
|     /* operate code */
 | |
|     uint8_t opcode;
 | |
|     /* payload length */
 | |
|     uint16_t payload_len;
 | |
|     /* payload data */
 | |
|     uint8_t payload[0];
 | |
| } iot_bt_ext_dfu_hdr_t;
 | |
| 
 | |
| /* request payload of write image */
 | |
| typedef struct _iot_bt_ext_dfu_req_pld_wr_img {
 | |
|     /* send image address */
 | |
|     uint32_t offset;
 | |
|     /* send image data */
 | |
|     uint8_t img[0];
 | |
| } iot_bt_ext_dfu_req_pld_wr_img_t;
 | |
| 
 | |
| /* request payload of image control header */
 | |
| typedef struct _iot_bt_ext_dfu_req_pld_img_ctl_hdr {
 | |
|     uint8_t ic_type;
 | |
|     uint8_t secure_version;
 | |
|     union
 | |
|     {
 | |
|         uint16_t value;
 | |
|         struct
 | |
|         {
 | |
|             uint16_t xip: 1; // payload is executed on flash
 | |
|             uint16_t enc: 1; // all the payload is encrypted
 | |
|             uint16_t load_when_boot: 1; // load image when boot
 | |
|             uint16_t enc_load: 1; // encrypt load part or not
 | |
|             uint16_t enc_key_select: 3; // referenced to ENC_KEY_SELECT
 | |
|             uint16_t not_ready : 1; //for copy image in ota
 | |
|             uint16_t not_obsolete : 1; //for copy image in ota
 | |
|             uint16_t rsvd: 7;
 | |
|         };
 | |
|     } ctrl_flag;
 | |
|     uint16_t signature;
 | |
|     uint16_t crc16;
 | |
|     uint32_t image_length;
 | |
| } iot_bt_ext_dfu_req_pld_img_ctl_hdr_t;
 | |
| 
 | |
| /* response payload of report target info */
 | |
| typedef struct _iot_bt_ext_dfu_rsp_pld_tgt_info {
 | |
|     /* error number */
 | |
|     uint8_t err_no;
 | |
|     /* dfu version */
 | |
|     uint8_t dfu_version;
 | |
|     /* current ic type */
 | |
|     uint8_t ic_type;
 | |
|     /* dfu bank id */
 | |
|     uint8_t bank_id;
 | |
|     /* dfu receive buffer byte size */
 | |
|     uint16_t buffer_size;
 | |
|     /* origin version */
 | |
|     uint32_t origin_version;
 | |
|     /* vendor version */
 | |
|     uint32_t vendor_version;
 | |
| } iot_bt_ext_dfu_rsp_pld_tgt_info_t;
 | |
| 
 | |
| /* response payload of write image */
 | |
| typedef struct _iot_bt_ext_dfu_rsp_pld_wr_img {
 | |
|     /* error number */
 | |
|     uint8_t err_no;
 | |
|     /* next receve image offset */
 | |
|     uint32_t next_offset;
 | |
| } iot_bt_ext_dfu_rsp_pld_wr_img_t;
 | |
| 
 | |
| /* response payload of normal transport */
 | |
| typedef struct _iot_bt_ext_dfu_rsp_pld_normal {
 | |
|     /* error number */
 | |
|     uint8_t err_no;
 | |
|     /* parameter */
 | |
|     uint8_t para[0];
 | |
| } iot_bt_ext_dfu_rsp_pld_normal_t;
 | |
| 
 | |
| #pragma pack(pop)
 | |
| 
 | |
| #ifdef __cplusplus
 | |
| }
 | |
| #endif
 | |
| 
 | |
| #endif
 |