blob: b87bf51aa4651c85b61ae2dbf14d52e3c0ae6dbe [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001#ifndef _IOT_ROCK_H_
2#define _IOT_ROCK_H_
3
4/* public */
5
6#define E_ROCK_SUCCESS (0)
7#define E_ROCK_INVALID_DELTA (-1)
8#define E_ROCK_DELTA_MISMATCH (-2)
9#define E_ROCK_DELTA_CHUNK_MISMATCH (-3)
10#define E_ROCK_READ_DELTA_ERROR (-4)
11#define E_ROCK_READ_BLOCK_ERROR (-11)
12#define E_ROCK_WRITE_BLOCK_ERROR (-12)
13#define E_ROCK_RAM_NOT_ENOUGH (-20)
14#define E_ROCK_INVALID_CTX (-30)
15
16
17#define PATCH_SYSTEM (1)
18#define PATCH_BOOT (2)
19#define PATCH_TEE (3)
20#define PATCH_MD1IMG (4)
21#define PATCH_VBMETA (5)
22#define PATCH_BL33 (6)
23#define FULL_SYSTEM (7)
24#define FULL_BOOT (8)
25#define FULL_TEE (9)
26#define FULL_MD1IMG (10)
27#define FULL_VBMETA (11)
28#define FULL_BL33 (12)
29
30#define MAX_OTA_ROLE (12)
31
32
33
34#define MODE_NORMAL 0
35#define MODE_A2B 1
36#define MODE_B2A 2
37
38#define WAIT 0xff
39#define PASS 0
40#define ERROR -1
41
42typedef struct {
43 void* user_context;
44 unsigned int rom_base; // old rom start
45 unsigned char* ram_base; // ram working buffer start
46 unsigned int ram_len; // ram working buffer len
47
48 unsigned int backup_base; // ram backup storage start
49 unsigned int backup_len; // ram backup storage len
50
51 unsigned int update_nvram; // nvram update flag
52
53 int read_rom_directly;
54 int first_run;
55} IOT_UPDATA_CONTEXT;
56
57
58typedef struct {
59 unsigned int sys; //system 差分包大小
60 unsigned int boot; //boot 差分包大小
61 unsigned int tee; //tee 差分包大小
62 unsigned int md1img; //md1img 差分包大小
63 unsigned int vbmeta; //vbmeta 差分包大小
64 unsigned int bl33; //bl33 差分包大小
65 unsigned int full_sys; //system 整包大小
66 unsigned int full_boot; //boot
67 unsigned int full_tee; //tee 整包大小
68 unsigned int full_md1img; // 整包大小
69 unsigned int full_vbmeta; //vbmeta 整包大小
70 unsigned int full_bl33; //bl33 整包大小
71} DELTA_HEAD;
72
73typedef struct {
74
75 char fota_flag[32]; //fota 标志保留
76 int update_result; //升级结果
77 int ota_run; //
78 char cid[32];
79 char did[32];
80} UPDATE_INFO;
81
82
83typedef struct {
84 int need_update;
85 int check_delta;
86 int check_rom;
87 int update_result;
88
89} UPDATE_STATUS;
90
91
92typedef struct {
93 int ota_run;
94 UPDATE_STATUS update_status[MAX_OTA_ROLE];
95 int update_result;
96 int switch_slot;
97
98} OTA_STATUS;
99
100
101
102
103
104//#define DELTA_HEARD_SIZE (4*5)
105
106#define DELTA_HEARD_SIZE (4*6 + 4*6)
107#define DELTA_FULL_HEARD_SIZE 8
108
109
110
111int iot_patch(IOT_UPDATA_CONTEXT* update_ctx);
112
113unsigned int iot_hash(unsigned char *buf,unsigned int len, unsigned int* value);
114int lynq_md5_file_verfy(char* filePath, char* file_md5);
115//int md5_file_verfy_new(char* filePath, char* file_md5,int packe_len);
116int lynq_rock_main(int first_run);
117int lynq_fota_func(void);
118#endif
119
120
121