| #ifndef _IOT_ROCK_H_ | |
| #define _IOT_ROCK_H_ | |
| #include <sys/types.h> | |
| #include <sys/stat.h> | |
| #include <fcntl.h> | |
| #include <unistd.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 E_ROCK_FOTA_ADDR (-50) | |
| #define PATCH_SYSTEM (1) | |
| #define PATCH_BOOT (2) | |
| #define PATCH_TEE (3) | |
| #define PATCH_MD1IMG (4) | |
| #define PATCH_MD1DSP (5) | |
| #define PATCH_VBMETA (6) | |
| #define PATCH_OEMAPP (7) | |
| #define PATCH_OEMAPP2 (8) | |
| #define PATCH_BL33 (9) | |
| #define FULL_SYSTEM (10) | |
| #define FULL_BOOT (11) | |
| #define FULL_TEE (12) | |
| #define FULL_MD1IMG (13) | |
| #define FULL_MD1DSP (14) | |
| #define FULL_VBMETA (15) | |
| #define FULL_OEMAPP (16) | |
| #define FULL_OEMAPP2 (17) | |
| #define FULL_BL33 (18) | |
| #define MAX_OTA_ROLE (18) | |
| #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 md1dsp; //md1dsp 差分包大小 | |
| unsigned int vbmeta; //vbmeta 差分包大小 | |
| unsigned int oemapp; | |
| unsigned int oemapp2; | |
| 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_md1dsp; //md1dsp 整包大小 | |
| unsigned int full_vbmeta; //vbmeta 整包大小 | |
| unsigned int full_oemapp; | |
| unsigned int full_oemapp2; | |
| 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*9 + 4*9) | |
| #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); | |
| int lynq_nand_open(const char *pathname, int flags); | |
| ssize_t lynq_nand_read(int fd, void *buf, size_t count); | |
| ssize_t lynq_nand_write(int fd, void *buf, size_t count); | |
| int lynq_nand_close(int fd); | |
| int lynq_get_upgrade_status(void); | |
| void lynq_reboot_device(void); | |
| int lynq_fota_nrestart(void); | |
| int lynq_fota_set_addr_value(char *value,int size); | |
| int lynq_fota_get_addr_value(char *tmp); | |
| #endif | |