blob: febd365b9f36b3d8e19f162be5fac3aca70aa3bc [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/*
2 * (C) Copyright 2016, ZIXC Corporation.
3 *
4 * partitions.h
5 */
6#ifndef _PARTITION_TABLE_H_
7#define _PARTITION_TABLE_H_
8
9
10
11/*
12 +--------------+
13 | magic | uint32_t
14 +--------------+ +--------------+
15 | version | uint32_t 1 | z-load |
16 +--------------+ +--------------+
17 | entry nums | uint32_t 2 | u-boot |
18 +--------------+ +--------------+
19 | crc | uint32_t 3 | m0 |
20 +==============+ +--------------+
21 | name[1] | 4 | nv_r |
22 +--------------+ +--------------+
23 | offset | 5 | nv_w |
24 +--------------+ +--------------+
25 | size | 6 | ps |
26 +==============+ +--------------+
27 | | 7 | phy |
28 +==============+ +--------------+
29 | | 8 | zsp |
30 +==============+ +--------------+
31 9 | cdrom |
32 +--------------+
33 10 | fs |
34 +--------------+
35
36*/
37
38#define VIRTUAL_PART_NUM 2
39#define ARM_PS_IMAGE "cpups"
40#define ARM_ZSP_IMAGE "cpuphy"
41#define ARM_PHY_IMAGE "proc-phy"
42#define ARM_ZSP_AMT_IMAGE "cpuzspamt" //[ZhouXin] Add for AMT.
43#define ARM_APP_IMAGE "cpuap"//"proc-app" FPGA
44#define ARM_CAP_IMAGE "cpucap"
45
46#define ARM_RAMDISK_IMAGE "ramdisk"
47#define ARM_USERDATA_IMAGE "userdata"
48#define ARM_RECOVERY_USERDATA_IMAGE "recovery"
49#define ARM_UBOOT_IMAGE "uboot"
50//#ifdef CONFIG_ZX297520V3E_MDL_AB
xf.li6c8fc1e2023-08-12 00:11:09 -070051#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
lh9ed821d2023-04-07 01:36:19 -070052#define ARM_ROOTFS_IMAGE "rootfs"
53#define ARM_ROOTFS2_IMAGE "rootfs2"
54#endif
55
56#define ARM_FOTA_BACKUP_IMAGE "fotabackup"
57#define ARM_FOTA_FLAG_IMAGE "fotaflag"
58#define ARM_FOTA_UPDATE_IMAGE "fotaupdate"
59#define ARM_FOTA_RECOVERY_IMAGE "recovery-kernel"
60
61#define ARM_NVRW_PARTITION "nvrw"
62#define ARM_AMT_FLAG_OFFSET 0x0
63
64/*nvrw·ÖÇødrv_nvrw ÆðʼµØÖ· ºóÃæ¶ÔÓ¦peripheral(3K) ÆðʼµØÖ·£¬*/
65#define DRV_NVRW_ADDRESS (0x00012000) //v3 0x32400 ,v2 0x68400
66#define ARM_DRV_PERIPHERAL_OFFSET (DRV_NVRW_ADDRESS+256+3*1024+3*1024+4*1024) /*drv_nvrw·ÖÇøOFFSET 0x2900*/
67
68
69#define ARM_FOTA_FLAG "FOTA-UPDATE"
70#define ARM_LOCAL_UPDATE_FLAG "LOCALUPDATE"
71#define ARM_RECOVERY_FLAG "FOTA-RECOVERY"
72#define ARM_FOTA_COPY_PS_FLAG "FOTA-PS" /*±íʾÐèÒª»¹Ô­ps°æ±¾*/
73#define ARM_FOTA_FLAG_LEN 32
74
75#define ARM_FOTA_UPDATE_SUCCESS_STRING "LOCAL-UP-SUCCESS"
76#define ARM_FOTA_UPDATE_FAILED_STRING "LOCAL-UP-FAIL"
77
78#define ARM_GMAC_INIT_FLAG "GMAC"
79#define ARM_GMAC_INIT_FLAG_LEN 5
80#define ARM_GMAC_INIT_OVERTIME_LEN 4
81
82
83#define ARM_RECOVERY_RESTART_OFFSET 0x40000
84#define ARM_RECOVERY_RESTART_FLAG "recovery reset"
85#define ARM_LOCALUP_RESULT_OFFSET 0x80000
86#define SZ_128K 0x00020000
87#define SZ_256K 0x00040000
88#define SZ_512K 0x00080000
89#define SZ_1M 0x00100000
90
91#define PART_TYPE_NAND "bin"
92#define PART_TYPE_ZFTL "nv"
93#define PART_TYPE_DDR "ddr"
94#define PART_TYPE_RAW "raw"
95#define PART_TYPE_FS "fs"
96
97#define PART1_NAME "zloader"
98#define PART1_OFFSET 0x00000000
99#define PART1_SIZE SZ_128K
100#define PART1_TYPE PART_TYPE_NAND
101
102#define PART2_NAME "uboot"
103#define PART2_OFFSET (PART1_OFFSET + PART1_SIZE)
104#define PART2_SIZE (SZ_1M + SZ_512K)
105#define PART2_TYPE PART_TYPE_NAND
106
107#define PART3_NAME "proc-lp"
108#define PART3_OFFSET (PART2_OFFSET + PART2_SIZE)
109#define PART3_SIZE (SZ_128K + SZ_256K)
110#define PART3_TYPE PART_TYPE_NAND
111
112#define PART4_NAME "nvr"
113#define PART4_OFFSET (PART3_OFFSET + PART3_SIZE)
114#define PART4_SIZE (SZ_1M * 2)
115#define PART4_TYPE PART_TYPE_ZFTL
116
117#define PART5_NAME "nvrw"
118#define PART5_OFFSET (PART4_OFFSET + PART4_SIZE)
119#define PART5_SIZE (SZ_1M * 8)
120#define PART5_TYPE PART_TYPE_ZFTL
121
122#define PART6_NAME "proc-ps"
123#define PART6_OFFSET (PART5_OFFSET + PART5_SIZE)
124#define PART6_SIZE (SZ_1M * 19)
125#define PART6_TYPE PART_TYPE_NAND
126
127#define PART7_NAME "proc-phy"
128#define PART7_OFFSET (PART6_OFFSET + PART6_SIZE)
129#define PART7_SIZE (SZ_1M * 19)
130#define PART7_TYPE PART_TYPE_NAND
131
132#define PART8_NAME "proc-zsp"
133#define PART8_OFFSET (PART7_OFFSET + PART7_SIZE)
134#define PART8_SIZE (SZ_1M * 1)
135#define PART8_TYPE PART_TYPE_NAND
136
137#define PART9_NAME "proc-app"
138#define PART9_OFFSET (PART8_OFFSET + PART8_SIZE)
139#define PART9_SIZE (SZ_1M * 10)
140#define PART9_TYPE PART_TYPE_NAND
141
142#define PART10_NAME "ramdisk"
143#define PART10_OFFSET (PART9_OFFSET + PART9_SIZE)
144#define PART10_SIZE (SZ_1M * 8)
145#define PART10_TYPE PART_TYPE_NAND
146
147#define PART11_NAME "cdrom"
148#define PART11_OFFSET (PART10_OFFSET + PART10_SIZE)
149#define PART11_SIZE (SZ_1M * 80)
150#define PART11_TYPE PART_TYPE_NAND
151
152#define PART12_NAME "fs-ffx"
153#define PART12_OFFSET (PART11_OFFSET + PART11_SIZE)
154#define PART12_SIZE (SZ_1M * 8)
155#define PART12_TYPE PART_TYPE_FS
156
157#define PART13_NAME "userdata"
158#define PART13_OFFSET (PART12_OFFSET + PART12_SIZE)
159#define PART13_SIZE (SZ_1M * 40)
160#define PART13_TYPE PART_TYPE_FS
161
162#define PART14_NAME "ddr"
163#define PART14_OFFSET 0x0
164#define PART14_SIZE 0xffffffff
165#define PART14_TYPE PART_TYPE_DDR
166
167#define PART15_NAME "raw"
168#define PART15_OFFSET 0x0
169#define PART15_SIZE (SZ_1M * 256)
170#define PART15_TYPE PART_TYPE_RAW
171
172#define PART_END 0,0,0
173#define PART1 PART1_NAME, PART1_TYPE, PART1_OFFSET, PART1_SIZE
174#define PART2 PART2_NAME, PART2_TYPE, PART2_OFFSET, PART2_SIZE
175#define PART3 PART3_NAME, PART3_TYPE, PART3_OFFSET, PART3_SIZE
176#define PART4 PART4_NAME, PART4_TYPE, PART4_OFFSET, PART4_SIZE
177#define PART5 PART5_NAME, PART5_TYPE, PART5_OFFSET, PART5_SIZE
178#define PART6 PART6_NAME, PART6_TYPE, PART6_OFFSET, PART6_SIZE
179#define PART7 PART7_NAME, PART7_TYPE, PART7_OFFSET, PART7_SIZE
180#define PART8 PART8_NAME, PART8_TYPE, PART8_OFFSET, PART8_SIZE
181#define PART9 PART9_NAME, PART9_TYPE, PART9_OFFSET, PART9_SIZE
182#define PART10 PART10_NAME, PART10_TYPE, PART10_OFFSET, PART10_SIZE
183#define PART11 PART11_NAME, PART11_TYPE, PART11_OFFSET, PART11_SIZE
184#define PART12 PART12_NAME, PART12_TYPE, PART12_OFFSET, PART12_SIZE
185#define PART13 PART13_NAME, PART13_TYPE, PART13_OFFSET, PART13_SIZE
186#define PART14 PART14_NAME, PART14_TYPE, PART14_OFFSET, PART14_SIZE
187#define PART15 PART15_NAME, PART15_TYPE, PART15_OFFSET, PART15_SIZE
188#define PART16 PART_END
189#define PART17 PART_END
190#define PART18 PART_END
191#define PART19 PART_END
192#define PART20 PART_END
193#define PART21 PART_END
194#define PART22 PART_END
195#define PART23 PART_END
196#define PART24 PART_END
197#define PART25 PART_END
198#define PART26 PART_END
199#define PART27 PART_END
200#define PART28 PART_END
201#define PART29 PART_END
202#define PART30 PART_END
203
204
205
206#define MAX_ENTRYS 30
207#define PARTITION_ENTRYS 15 /* ʵ¼ÊʹÓõķÖÇø¸öÊý */
208#define PARTITION_MAGIC 0x31594876 /* ͬ²½ Z-LOAD */
209#define PARTITION_PLARTNANME "WF7520"
210#define PARTITION_VERSION 0x00201304 /* */
211#define PARTITION_CRC 0x12345678
212#define PARTITION_SIZE 0X1000 /* ·ÖÇø±íµÄ´óС */
213
xf.lidf7f8ba2024-09-12 23:53:34 -0700214#define IMG_NUM 15
lh9ed821d2023-04-07 01:36:19 -0700215
216typedef struct partition_entry {
217 unsigned char part_name[16];
218 unsigned char part_type[16];
219 unsigned int part_offset;
220 unsigned int part_size;
221}partition_entry_t;
222
223typedef struct partition_table {
224 unsigned int magic;
225 unsigned char platform_name[16];
226 unsigned int version; /* ·ÖÇø°æ±¾ */
227 unsigned int entrys; /* ×ܵķÖÇø¸öÊý */
228 unsigned int crc;
229 partition_entry_t table[MAX_ENTRYS];
230}partition_table_t;
231
232typedef struct image_bin_header {
233 unsigned char filename[64]; // ÎļþÃû,total 128
234 unsigned char partitonname[16]; // ·ÖÇøÃû
235 unsigned char partitontype[16]; // ·ÖÇøÀàÐÍ
236 unsigned int filelength; // Îļþ³¤¶È
237 unsigned int partitonoffset; // ÔÚ·ÖÇøÖеĵØÖ·
238 unsigned int fileaddr; //ÎļþÔںϳÉÎļþÖеÄλÖÃ
239 unsigned char btUse[20];
240}image_bin_header_t;
241typedef struct master_header
242{
243 unsigned char btFileId[16]; // ¶àBinºÏÒ»Îļþ±êʶ,total 208bytes
244 unsigned char btVersionIn[32];
245 unsigned char btVersionOut[32];
246 unsigned int dwFileNumber;
247 unsigned int dwDeviceType;
248 unsigned int dwNV;
249
250 unsigned int dwFileLengthTotal; // Îļþ×ܳ¤¶È
251 unsigned int dwCheckSum; // УÑé
252 unsigned int dwImageOffset; // ¾µÏñÊý¾ÝÔÚ¶àBinºÏÒ»ÎļþÖÐÆ«ÒÆ
253 unsigned int dwTLoaderAdd; // TLoaderÔÚ¶àBinºÏÒ»ÎļþÖÐµÄÆ«ÒÆ
254 unsigned int dwTLoaderLength; // TLoader³¤¶È
255 unsigned int dwTBootAdd; // TBootÔÚ¶àBinºÏÒ»ÎļþÖÐµÄÆ«ÒÆ
256 unsigned int dwTBootLength; // TBoot³¤¶È
257 unsigned int dwPartitonAdd; // PartitonÔÚ¶àBinºÏÒ»ÎļþÖÐµÄÆ«ÒÆ
258 unsigned int dwPartitionLength ; // Partition³¤¶È
259 unsigned char btUse[80];
260
261 image_bin_header_t image[50];
262} master_header_t;
263
xf.li6c8fc1e2023-08-12 00:11:09 -0700264#define FLAGS_PARTITION_ERROR (0x1111) /*·ÖÇøÒì³£*/
265
266#if 0
lh9ed821d2023-04-07 01:36:19 -0700267#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
268/*
269flags partition
270
271*/
272/*˫ϵͳÀàÐÍ*/
273#define FLAGS_BOOT_FOTA_OFFSET (0X0UL)
274#define FLAGS_BOOT_FOTA_SIZE (0X80000UL)
275#define FLAGS_BOOT_ENV_OFFSET (FLAGS_BOOT_FOTA_OFFSET + FLAGS_BOOT_FOTA_SIZE)
276#define FLAGS_BOOT_ENV_SIZE (0X80000UL)
277#define FLAGS_BACKUP_OFFSET (FLAGS_BOOT_ENV_OFFSET + FLAGS_BOOT_ENV_SIZE)
278
279#define FLAGS_MAGIC (0X464C4147UL)
280
281#define DUALSYSTEM_STATUS_BOOTABLE (0XB0AB) /*¿ÉÆô¶¯*/
282#define DUALSYSTEM_STATUS_SUCCESSFUL (0X5CCF) /*Äܳɹ¦Æô¶¯*/
283#define DUALSYSTEM_STATUS_UNBOOTABLE (0XBABE) /*²»¿ÉÆô¶¯*/
284#define FLAGS_PARTITION_ERROR (0x1111) /*·ÖÇøÒì³£*/
285
286
287
288typedef struct
289{
290 int status; /*bootable/successful/unbootable*/
291 int try_cnt;
292}T_DualSystem_Status;
293
294typedef enum
295{
296 DUAL_SYSTEM = 0X875A, /*µÚÒ»¸öϵͳ*/
297 DUAL_SYSTEM2 = 0X986B, /*µÚ¶þ¸öϵͳ*/
298}T_BOOT_TARGET;
299
300/*˫ϵͳÀàÐÍ*/
301typedef enum
302{
303 DUALSYSTEM_RECOVERY = 0X7575, /*normal-recovery˫ϵͳ*/
304 DUALSYSTEM_AA = 0XAAAA, /*AA˫ϵͳ*/
305 DUALSYSTEM_AB = 0XABAB /*AB˫ϵͳ*/
306}T_BOOT_DUALSYSTEM_TYPE;
307
308typedef struct
309{
310 uint32_t magic; /*Êý¾ÝÓÐЧÐÔħÊõ×Ö*/
311 T_BOOT_TARGET boot_to; /*µ±Ç°Æô¶¯ÏµÍ³±êÖ¾*/
312 uint32_t fota_status; /*fota״̬*/
313 T_DualSystem_Status system; /*µÚÒ»¸öϵͳ״̬*/
314 T_DualSystem_Status system2; /*µÚ¶þ¸öϵͳ״̬*/
315}T_BOOT_FOTA_FLAG;
316
317typedef struct
318{
319 unsigned int magic; /*Êý¾ÝÓÐЧÐÔħÊõ×Ö*/
320 T_BOOT_DUALSYSTEM_TYPE dualsys_type; /*˫ϵͳÀàÐÍ*/
321 char system_boot_env[128];
322 char system2_boot_env[128];
323}T_BOOT_ENV;
324
325typedef struct
326{
327 T_BOOT_FOTA_FLAG boot_flag;
328 T_BOOT_ENV boot_env;
329}T_FOTA_FLAG_INFO;
330#endif
xf.li6c8fc1e2023-08-12 00:11:09 -0700331#endif
lh9ed821d2023-04-07 01:36:19 -0700332
333#ifdef CREAT_PARTITION_TABLE
334partition_table_t g_partiton_table =
335 {
336 PARTITION_MAGIC, \
337 PARTITION_PLARTNANME,\
338 PARTITION_VERSION,\
339 PARTITION_ENTRYS, \
340 PARTITION_CRC,\
341 { { PART1 },\
342 { PART2 },\
343 { PART3 },\
344 { PART4 },\
345 { PART5 },\
346 { PART6 },\
347 { PART7 },\
348 { PART8 },\
349 { PART9 },\
350 { PART10 },\
351 { PART11 },\
352 { PART12 },\
353 { PART13 },\
354 { PART14 },\
355 { PART15 },\
356 { PART16 },\
357 { PART17 },\
358 { PART18 },\
359 { PART19 },\
360 { PART20 },\
361 { PART21 },\
362 { PART22 },\
363 { PART23 },\
364 { PART24 },\
365 { PART25 },\
366 { PART26 },\
367 { PART27 },\
368 { PART28 },\
369 { PART29 },\
370 { PART30 }}
371 };
372#endif
373
374#ifndef CREAT_PARTITION_TABLE
375int read_partition_and_check( void );
376partition_entry_t *find_partition_para( uchar * name );
377void add_partition_to_bootargs(void);
378#endif
379
380#endif /* _PARTITION_TABLE_H_ */