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