blob: a2865d807a0995c01542297b92675e818b82968f [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/*
2 * (C) Copyright 2016 ZXIC Inc.
3 *
4 */
5
6#ifndef __IMAGE_H__
7#define __IMAGE_H__
8
9#define IH_NMLEN 32 /* Image Name Length */
10#define IH_MAGIC 0x27051956 /* Image Magic Number */
11
12
13#define CFG_PARTITION_MAGIC 0x31594876 /* ͬ²½ U-BOOT */
14
15
16
17/*
18 +--------------+
19 | magic | uint32_t
20 +--------------+
21 | version | uint32_t
22 +--------------+
23 | entry nums | uint32_t
24 +--------------+
25 | crc | uint32_t
26 +==============+
27 | name[1] |
28 +--------------+
29 | offset |
30 +--------------+
31 | size |
32 +==============+
33 | |
34 +==============+
35 | |
36 +==============+
37
38*/
39#define MAX_ENTRYS 30
40
41typedef struct partition_entry {
42 unsigned char part_name[16];
43 unsigned char part_type[16];
44 unsigned int part_offset;
45 unsigned int part_size;
46}partition_entry_t;
47
48typedef struct partition_table {
49 unsigned int magic;
50 unsigned char platform_name[16];
51 unsigned int version; /* ·ÖÇø°æ±¾ */
52 unsigned int entrys; /* ×ܵķÖÇø¸öÊý */
53 unsigned int crc;
54 partition_entry_t table[MAX_ENTRYS];
55}partition_table_t;
56
xf.li6c8fc1e2023-08-12 00:11:09 -070057#if 0
lh9ed821d2023-04-07 01:36:19 -070058#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
59/*
60flags partition
61
62*/
63/*˫ϵͳÀàÐÍ*/
64#define FLAGS_BOOT_FOTA_OFFSET (0X0UL)
65//#define FLAGS_BOOT_FOTA_SIZE (0X80000UL)
66//#define FLAGS_BOOT_ENV_OFFSET (FLAGS_BOOT_FOTA_OFFSET + FLAGS_BOOT_FOTA_SIZE)
67//#define FLAGS_BOOT_ENV_SIZE (0X80000UL)
68//#define FLAGS_BACKUP_OFFSET (FLAGS_BOOT_ENV_OFFSET + FLAGS_BOOT_ENV_SIZE)
69
70#define FLAGS_MAGIC (0X464C4147UL)
71
72#define DUALSYSTEM_STATUS_BOOTABLE (0XB0AB) /*¿ÉÆô¶¯*/
73#define DUALSYSTEM_STATUS_SUCCESSFUL (0X5CCF) /*Äܳɹ¦Æô¶¯*/
74#define DUALSYSTEM_STATUS_UNBOOTABLE (0XBABE) /*²»¿ÉÆô¶¯*/
75
76typedef struct
77{
78 int status; /*bootable/successful/unbootable*/
79 int try_cnt;
80}T_DualSystem_Status;
81
82typedef enum
83{
84 DUAL_SYSTEM = 0X875A, /*µÚÒ»¸öϵͳ*/
85 DUAL_SYSTEM2 = 0X986B, /*µÚ¶þ¸öϵͳ*/
86}T_BOOT_TARGET;
87
88/*˫ϵͳÀàÐÍ*/
89typedef enum
90{
91 DUALSYSTEM_RECOVERY = 0X7575, /*normal-recovery˫ϵͳ*/
92 DUALSYSTEM_AA = 0XAAAA, /*AA˫ϵͳ*/
93 DUALSYSTEM_AB = 0XABAB /*AB˫ϵͳ*/
94}T_BOOT_DUALSYSTEM_TYPE;
95
96typedef struct
97{
98 uint32_t magic; /*Êý¾ÝÓÐЧÐÔħÊõ×Ö*/
99 T_BOOT_TARGET boot_to; /*µ±Ç°Æô¶¯ÏµÍ³±êÖ¾*/
100 uint32_t fota_status; /*fota״̬*/
101 T_DualSystem_Status system; /*µÚÒ»¸öϵͳ״̬*/
102 T_DualSystem_Status system2; /*µÚ¶þ¸öϵͳ״̬*/
103}T_BOOT_FOTA_FLAG;
104
105typedef struct
106{
107 unsigned int magic; /*Êý¾ÝÓÐЧÐÔħÊõ×Ö*/
108 T_BOOT_DUALSYSTEM_TYPE dualsys_type; /*˫ϵͳÀàÐÍ*/
109 char system_boot_env[128];
110 char system2_boot_env[128];
111}T_BOOT_ENV;
112
113typedef struct
114{
115 T_BOOT_FOTA_FLAG boot_flag;
116 T_BOOT_ENV boot_env;
117}T_FOTA_FLAG_INFO;
118#endif
xf.li6c8fc1e2023-08-12 00:11:09 -0700119#endif
lh9ed821d2023-04-07 01:36:19 -0700120/*
121 * Legacy format image header, sizeof(image_header_t) = 64
122 * all data in network byte order (aka natural aka bigendian).
123 */
124typedef struct image_header {
125 uint32_t ih_magic; /* Image Header Magic Number */
126 uint32_t ih_hcrc; /* Image Header CRC Checksum */
127 uint32_t ih_time; /* Image Creation Timestamp */
128 uint32_t ih_size; /* Image Data Size */
129 uint32_t ih_load; /* Data Load Address */
130 uint32_t ih_ep; /* Entry Point Address used ************* */
131 uint32_t ih_dcrc; /* Image Data CRC Checksum */
132 uint8_t ih_os; /* Operating System */
133 uint8_t ih_arch; /* CPU architecture */
134 uint8_t ih_type; /* Image Type */
135 uint8_t ih_comp; /* Compression Type */
136 uint8_t ih_name[IH_NMLEN]; /* Image Name */
137} image_header_t;
138
139typedef struct
140{
141 u32 uiPubKeyRsaE[32];
142 u32 uiPubKeyRsaN[32];
143 u32 uiHashY[32];
144} sImageHeader;
145
146
147extern int read_uboot_image(uint8_t *name, uint32_t *uboot_entry_point);
148extern int nand_read_m0(uint32_t *m0_entry_point);
149
150
151#endif /* __IMAGE_H__ */