#ifndef _IOT_ROCK_H_ | |
#define _IOT_ROCK_H_ | |
/* public */ | |
#define E_ROCK_SUCCESS (0) | |
#define E_ROCK_INVALID_DELTA (-1) | |
#define E_ROCK_DELTA_MISMATCH (-2) | |
#define E_ROCK_DELTA_CHUNK_MISMATCH (-3) | |
#define E_ROCK_READ_DELTA_ERROR (-4) | |
#define E_ROCK_READ_BLOCK_ERROR (-11) | |
#define E_ROCK_WRITE_BLOCK_ERROR (-12) | |
#define E_ROCK_RAM_NOT_ENOUGH (-20) | |
#define E_ROCK_INVALID_CTX (-30) | |
#define PATCH_SYSTEM (1) | |
#define PATCH_BOOT (2) | |
#define PATCH_TEE (3) | |
#define PATCH_MD1IMG (4) | |
#define PATCH_VBMETA (5) | |
#define PATCH_BL33 (6) | |
#define FULL_SYSTEM (7) | |
#define FULL_BOOT (8) | |
#define FULL_TEE (9) | |
#define FULL_MD1IMG (10) | |
#define FULL_VBMETA (11) | |
#define FULL_BL33 (12) | |
#define MAX_OTA_ROLE (12) | |
#define MODE_NORMAL 0 | |
#define MODE_A2B 1 | |
#define MODE_B2A 2 | |
#define WAIT 0xff | |
#define PASS 0 | |
#define ERROR -1 | |
typedef struct { | |
void* user_context; | |
unsigned int rom_base; // old rom start | |
unsigned char* ram_base; // ram working buffer start | |
unsigned int ram_len; // ram working buffer len | |
unsigned int backup_base; // ram backup storage start | |
unsigned int backup_len; // ram backup storage len | |
unsigned int update_nvram; // nvram update flag | |
int read_rom_directly; | |
int first_run; | |
} IOT_UPDATA_CONTEXT; | |
typedef struct { | |
unsigned int sys; //system 差分包大小 | |
unsigned int boot; //boot 差分包大小 | |
unsigned int tee; //tee 差分包大小 | |
unsigned int md1img; //md1img 差分包大小 | |
unsigned int vbmeta; //vbmeta 差分包大小 | |
unsigned int bl33; //bl33 差分包大小 | |
unsigned int full_sys; //system 整包大小 | |
unsigned int full_boot; //boot | |
unsigned int full_tee; //tee 整包大小 | |
unsigned int full_md1img; // 整包大小 | |
unsigned int full_vbmeta; //vbmeta 整包大小 | |
unsigned int full_bl33; //bl33 整包大小 | |
} DELTA_HEAD; | |
typedef struct { | |
char fota_flag[32]; //fota 标志保留 | |
int update_result; //升级结果 | |
int ota_run; // | |
char cid[32]; | |
char did[32]; | |
} UPDATE_INFO; | |
typedef struct { | |
int need_update; | |
int check_delta; | |
int check_rom; | |
int update_result; | |
} UPDATE_STATUS; | |
typedef struct { | |
int ota_run; | |
UPDATE_STATUS update_status[MAX_OTA_ROLE]; | |
int update_result; | |
int switch_slot; | |
} OTA_STATUS; | |
//#define DELTA_HEARD_SIZE (4*5) | |
#define DELTA_HEARD_SIZE (4*6 + 4*6) | |
#define DELTA_FULL_HEARD_SIZE 8 | |
int iot_patch(IOT_UPDATA_CONTEXT* update_ctx); | |
unsigned int iot_hash(unsigned char *buf,unsigned int len, unsigned int* value); | |
int lynq_md5_file_verfy(char* filePath, char* file_md5); | |
//int md5_file_verfy_new(char* filePath, char* file_md5,int packe_len); | |
int lynq_rock_main(int first_run); | |
int lynq_fota_func(void); | |
#endif | |