[Feature][ZXW-88]merge P50 version

Only Configure: No
Affected branch: master
Affected module: unknown
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: No

Change-Id: I34667719d9e0e7e29e8e4368848601cde0a48408
diff --git a/boot/common/scripts/Makefile b/boot/common/scripts/Makefile
index daaa447..f9e743a 100755
--- a/boot/common/scripts/Makefile
+++ b/boot/common/scripts/Makefile
@@ -67,6 +67,10 @@
 board=vehicle_dc

 endif

 

+ifeq ($(BOARD_TYPE),VEHICLE_DC_REF)

+board=vehicle_dc_ref

+endif

+

 ifeq ($(BOARD_TYPE),MDL_MINI)

 board=mdl_mini

 endif

@@ -89,6 +93,9 @@
 else ifeq ($(strip $(board)),$(filter $(board),vehicle_dc))

 	ram_text=0x27EF0000

 	V3T_RAM_TEXT_128M_UBOOT=y

+else ifeq ($(strip $(board)),$(filter $(board),vehicle_dc_ref))

+	ram_text=0x27EF0000

+	V3T_RAM_TEXT_128M_UBOOT=y

 else

 	ram_text=0x21EF0000

 endif

@@ -101,6 +108,10 @@
 	key_path=mdl

 endif

 

+ifeq ($(strip $(board)),$(filter $(board),vehicle_dc_ref))

+	key_path=mdl

+endif

+

 ifeq ($(strip $(board)),$(filter $(board),mdl_mini mifi_mini ufi_mini))

 	key_path=$(subst _mini,,$(board))

 endif

diff --git a/boot/common/src/loader/config.mk b/boot/common/src/loader/config.mk
index 458bb4c..bc87baf 100755
--- a/boot/common/src/loader/config.mk
+++ b/boot/common/src/loader/config.mk
@@ -73,6 +73,10 @@
 PLATFORM_CPPFLAGS+= -DCONFIG_ZX297520V3E_VEHICLE_DC
 endif
 
+ifeq ($(strip $(board)),$(filter $(board),vehicle_dc_ref))
+PLATFORM_CPPFLAGS+= -DCONFIG_ZX297520V3E_VEHICLE_DC_REF
+endif
+
 ifdef	ARCH
 sinclude $(TOPDIR)/$(ARCH)_config.mk	# include architecture dependend rules
 endif
diff --git a/boot/common/src/loader/drivers/bbt.c b/boot/common/src/loader/drivers/bbt.c
index bf46266..471a86f 100755
--- a/boot/common/src/loader/drivers/bbt.c
+++ b/boot/common/src/loader/drivers/bbt.c
@@ -56,7 +56,7 @@
 	uint32_t block_size = flash.block_size;
 	uint8_t oob[256];   /* ÕâÀﶨÒå×î´óµÄOOB SIZE */
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 	uint32_t block_nums = 72;
 #else
 	uint32_t block_nums = 17;
diff --git a/boot/common/src/loader/drivers/image.c b/boot/common/src/loader/drivers/image.c
index 8903e14..09c296a 100755
--- a/boot/common/src/loader/drivers/image.c
+++ b/boot/common/src/loader/drivers/image.c
@@ -11,7 +11,7 @@
 
 #include "flash.h"
 #include <bbt.h>
-
+#include "pub_flags.h"
 
 /*
  ******************************************************************************
@@ -112,10 +112,10 @@
 }
 
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 int read_flags_image(uint8_t *name)
 {
-    T_BOOT_FOTA_FLAG *fotaFlag;
+    T_FLAGS_INFO *fotaFlag;
 	uint32_t uiPageSize = 0;
     uint32_t flags_offset = 0;
 	uint32_t off = 0;
@@ -125,7 +125,7 @@
 	uint32_t work_area_offset = 0;
 	uint32_t backup_area_offset = 0;
 	int32_t ret = 0;
-	int32_t fota_size = sizeof(T_BOOT_FOTA_FLAG);
+	int32_t fota_size = sizeof(T_FLAGS_INFO);
 	int32_t block_size = flash.block_size;
 
 	fota_size = page_align(fota_size);
@@ -173,9 +173,9 @@
 		return -1;
 	}
 
-	fotaFlag = (T_BOOT_FOTA_FLAG *)(CFG_TEMP_ADDR);
+	fotaFlag = (T_FLAGS_INFO *)(CFG_TEMP_ADDR);
 	
-	if(fotaFlag->magic != FLAGS_MAGIC)
+	if(fotaFlag->magic_start != FLAGS_MAGIC || fotaFlag->magic_end != FLAGS_MAGIC)
 	{
         ret = flash.read(backup_area_offset, fota_size, CFG_TEMP_ADDR);
 		if(ret != 0)
@@ -184,8 +184,8 @@
 			
 			return -1;
 		}
-		fotaFlag = (T_BOOT_FOTA_FLAG *)(CFG_TEMP_ADDR);
-		if(fotaFlag->magic != FLAGS_MAGIC)
+		fotaFlag = (T_FLAGS_INFO *)(CFG_TEMP_ADDR);
+		if(fotaFlag->magic_start != FLAGS_MAGIC || fotaFlag->magic_end != FLAGS_MAGIC)
 		{
             printf("flags magic err.\n");
 		    return -1;
diff --git a/boot/common/src/loader/include/configs/zx297520v3.h b/boot/common/src/loader/include/configs/zx297520v3.h
index 71d6d50..c463be8 100755
--- a/boot/common/src/loader/include/configs/zx297520v3.h
+++ b/boot/common/src/loader/include/configs/zx297520v3.h
@@ -16,7 +16,7 @@
 #define CFG_PRINTF       1    
 #else
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)|| defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 #define CFG_PRINTF       0
 #else
 #define CFG_PRINTF       1    
@@ -51,7 +51,7 @@
  * partition name
 ***/
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 #define M0_PARTITION_NAME       "cpurpm"
 #define UBOOT_IMAGE    	    	"uboot"
 #define UBOOT2_IMAGE    	    "uboot2"
diff --git a/boot/common/src/loader/include/image.h b/boot/common/src/loader/include/image.h
index 26249e9..a2865d8 100755
--- a/boot/common/src/loader/include/image.h
+++ b/boot/common/src/loader/include/image.h
@@ -54,7 +54,7 @@
     partition_entry_t  table[MAX_ENTRYS];   
 }partition_table_t;
 
-//#ifdef CONFIG_ZX297520V3E_MDL_AB
+#if 0
 #if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
 /*
 flags partition
@@ -116,7 +116,7 @@
 	T_BOOT_ENV            boot_env;
 }T_FOTA_FLAG_INFO;
 #endif
-
+#endif
 /*
  * Legacy format image header,  sizeof(image_header_t) = 64
  * all data in network byte order (aka natural aka bigendian).
diff --git a/boot/common/src/loader/lib/board.c b/boot/common/src/loader/lib/board.c
index 3d138a9..09417af 100755
--- a/boot/common/src/loader/lib/board.c
+++ b/boot/common/src/loader/lib/board.c
@@ -17,6 +17,7 @@
 #include "ddr.h"
 #include "../drivers/efuse.h"
 #include "../drivers/flash.h"
+#include "pub_flags.h"
 
 #define FLAGS_PARTITION_ERROR (0x1111) /*·ÖÇøÒì³£*/
 
@@ -134,7 +135,7 @@
 }
 
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 void start_armboot (void)
 {
 	int32_t ret = 0;
@@ -142,9 +143,8 @@
 	uint32_t amt_value = 0;
 	int32_t err_flag = 0;
     T_BOOT_TARGET bootTarget;
-	T_BOOT_FOTA_FLAG flagsData;
-	T_BOOT_FOTA_FLAG *fotaFlag;
-	T_FOTA_FLAG_INFO *fotaFlagInfo;
+	T_FLAGS_INFO flagsData;
+	T_FLAGS_INFO *fotaFlag;
 	T_BOOT_DUALSYSTEM_TYPE dualSystemType;
 
 	clk_init();
@@ -218,25 +218,26 @@
 		err_flag = 1;
 		
 		/*ĬÈÏflags·ÖÇøÊý¾Ý*/
-		flagsData.magic = FLAGS_MAGIC;
-		flagsData.boot_to = DUAL_SYSTEM;
-		flagsData.fota_status = 1;
-		flagsData.system.status = DUALSYSTEM_STATUS_BOOTABLE;
-		flagsData.system2.status = DUALSYSTEM_STATUS_BOOTABLE;
+		flagsData.magic_start = FLAGS_MAGIC;
+		flagsData.boot_fota_flag.boot_to = DUAL_SYSTEM;
+		flagsData.boot_fota_flag.fota_status = 1;
+		flagsData.boot_fota_flag.system.status = DUALSYSTEM_STATUS_BOOTABLE;
+		flagsData.boot_fota_flag.system2.status = DUALSYSTEM_STATUS_BOOTABLE;
+		flagsData.magic_end = FLAGS_MAGIC;
 		fotaFlag = &flagsData;
 	}
 	else
 	{
-        fotaFlag = (T_BOOT_FOTA_FLAG *)(CFG_TEMP_ADDR);
+        fotaFlag = (T_FLAGS_INFO *)(CFG_TEMP_ADDR);
 	}
 
-	bootTarget = fotaFlag->boot_to;
+	bootTarget = fotaFlag->boot_fota_flag.boot_to;
 
 	writel(DUALSYSTEM_STATUS_BOOTABLE, BOOT_FLAG_ADDR);/*ĬÈÏ¿ÉÆô¶¯*/
 	
     if(bootTarget == DUAL_SYSTEM)
     {
-        if (fotaFlag->system.status == DUALSYSTEM_STATUS_UNBOOTABLE)
+        if (fotaFlag->boot_fota_flag.system.status == DUALSYSTEM_STATUS_UNBOOTABLE)
         {
             printf("dual_system status is unbootable!");
 		    goto error;
@@ -258,7 +259,7 @@
 	}
     else if(bootTarget == DUAL_SYSTEM2)
     {
-        if (fotaFlag->system2.status == DUALSYSTEM_STATUS_UNBOOTABLE)
+        if (fotaFlag->boot_fota_flag.system2.status == DUALSYSTEM_STATUS_UNBOOTABLE)
         {
             printf("dual_system2 status is unbootable!");
 		    goto error;
diff --git a/boot/common/src/uboot/arch/arm/lib/bootm.c b/boot/common/src/uboot/arch/arm/lib/bootm.c
index 10a90b7..57bb639 100755
--- a/boot/common/src/uboot/arch/arm/lib/bootm.c
+++ b/boot/common/src/uboot/arch/arm/lib/bootm.c
@@ -105,7 +105,7 @@
 }
 
 //#ifdef CONFIG_ZX297520V3E_WATCH_CAP
-#if defined(CONFIG_ZX297520V3E_WATCH_CAP) || defined (CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_WATCH_CAP) || defined (CONFIG_ZX297520V3E_VEHICLE_DC) || defined (CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 #define SYS_CPUCAP_PARAM_ADDR	0x10200C
 extern uint32_t arm_cpucap_ep;
 void set_cpucap_tag(int arch, uint parameter)
@@ -158,7 +158,7 @@
 		bootm_linux_fdt(machid, images);
 	}
 #endif
-#ifdef CONFIG_ZX297520V3E_VEHICLE_DC
+#if defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
         debug("start device tree...\n");
 		bootm_linux_fdt(machid, images);
 		//fdt_chosen(images->ft_addr, 1);
@@ -197,7 +197,7 @@
 #endif
 
 //#ifdef CONFIG_ZX297520V3E_WATCH_CAP	
-#if defined(CONFIG_ZX297520V3E_WATCH_CAP) || defined (CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_WATCH_CAP) || defined (CONFIG_ZX297520V3E_VEHICLE_DC) || defined (CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 	memset(ICP_CAP_BUF_ADDR, 0, ICP_CAP_BUF_LEN);
 	memset(IRAM_BASE_ADDR_SYS_TRACE, 0, IRAM_BASE_LEN_SYS_TRACE);
 	if(!read_fota_update_flag())
diff --git a/boot/common/src/uboot/board/zte/zx297520v3/Makefile b/boot/common/src/uboot/board/zte/zx297520v3/Makefile
index 1f438e4..bce5c4e 100755
--- a/boot/common/src/uboot/board/zte/zx297520v3/Makefile
+++ b/boot/common/src/uboot/board/zte/zx297520v3/Makefile
@@ -44,6 +44,7 @@
 COBJS-$(CONFIG_ZX297520V3E_UFI_MINI) += zx297520v3_ufi_mini.o
 COBJS-$(CONFIG_ZX297520V3E_MDL_AB)	+= zx297520v3_mdl_ab.o
 COBJS-$(CONFIG_ZX297520V3E_VEHICLE_DC)	+= zx297520v3_vehicle_dc.o
+COBJS-$(CONFIG_ZX297520V3E_VEHICLE_DC_REF)	+= zx297520v3_vehicle_dc_ref.o
 
 SOBJS	:= lowlevel_init.o
 
diff --git a/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_mdl_ab.c b/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_mdl_ab.c
index a426667..d06ec00 100755
--- a/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_mdl_ab.c
+++ b/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_mdl_ab.c
@@ -37,6 +37,7 @@
 #include <lcd.h>
 #include <peripheral.h>
 #include "board.h"
+#include "pub_flags.h"
 
 #include <drvs_gpio.h>
 
@@ -408,10 +409,10 @@
 	int ret = 0;
 	int type = 0;
 	uchar * flags_name = "flags";
-	T_FOTA_FLAG_INFO fotaFlagInfo;
+	T_FLAGS_INFO fotaFlagInfo = {0};
 	T_DualSystem_Status system_status;
 	system_status.status = DUALSYSTEM_STATUS_UNBOOTABLE;
-	u32 fota_size = sizeof(T_FOTA_FLAG_INFO);
+	u32 fota_size = sizeof(T_FLAGS_INFO);
 	fota_size = page_align(fota_size);
 	
 	nand_info_t *nand = &nand_info[nand_curr_device];
@@ -436,12 +437,14 @@
 	flags_size = entry->part_size;
 	
 	/*ÉèÖÃĬÈÏflags·ÖÇøÊý¾Ý*/
-	fotaFlagInfo.boot_flag.magic = FLAGS_MAGIC;
-	fotaFlagInfo.boot_flag.boot_to = DUAL_SYSTEM;
-	fotaFlagInfo.boot_flag.fota_status = 1;
-	fotaFlagInfo.boot_flag.system.status = DUALSYSTEM_STATUS_BOOTABLE;
-	fotaFlagInfo.boot_flag.system2.status = DUALSYSTEM_STATUS_BOOTABLE;
-
+    fotaFlagInfo.magic_start = FLAGS_MAGIC;
+	fotaFlagInfo.boot_fota_flag.boot_to = DUAL_SYSTEM;
+	fotaFlagInfo.boot_fota_flag.fota_status = 1;
+	fotaFlagInfo.boot_fota_flag.system.status = DUALSYSTEM_STATUS_BOOTABLE;
+	fotaFlagInfo.boot_fota_flag.system2.status = DUALSYSTEM_STATUS_BOOTABLE;
+    fotaFlagInfo.boot_env.dualsys_type = DUALSYSTEM_AB;
+	fotaFlagInfo.magic_end = FLAGS_MAGIC;
+	
 	/*дÈëflags·ÖÇø*/
 	if(type == IF_TYPE_NAND || type == IF_TYPE_SPI_NAND)
 	{
@@ -552,11 +555,10 @@
 	int ret = 0;
 	int type = 0;
 	uchar * flags_name = "flags";
-	T_BOOT_FOTA_FLAG fotaFlag;
-	T_FOTA_FLAG_INFO fotaFlagInfo;
+	T_FLAGS_INFO fotaFlagInfo = {0};
 	T_DualSystem_Status system_status;
 	system_status.status = DUALSYSTEM_STATUS_UNBOOTABLE;
-	u32 fota_size = sizeof(T_FOTA_FLAG_INFO);
+	u32 fota_size = sizeof(T_FLAGS_INFO);
 	fota_size = page_align(fota_size);
 	
 	nand_info_t *nand = &nand_info[nand_curr_device];
@@ -589,10 +591,10 @@
 	}
 
 	/*д»Øflags·ÖÇø*/
-    if(fotaFlagInfo.boot_flag.boot_to == DUAL_SYSTEM)
+    if(fotaFlagInfo.boot_fota_flag.boot_to == DUAL_SYSTEM)
     {
-        fotaFlagInfo.boot_flag.boot_to = DUAL_SYSTEM2;
-		fotaFlagInfo.boot_flag.system = system_status;
+        fotaFlagInfo.boot_fota_flag.boot_to = DUAL_SYSTEM2;
+		fotaFlagInfo.boot_fota_flag.system = system_status;
 
 		if(type == IF_TYPE_NAND || type == IF_TYPE_SPI_NAND)
 		{
@@ -686,10 +688,10 @@
 		printf("system boot status is changed to unbootable!\n");
 		//system_reset();
 	}
-	else if(fotaFlagInfo.boot_flag.boot_to == DUAL_SYSTEM2)
+	else if(fotaFlagInfo.boot_fota_flag.boot_to == DUAL_SYSTEM2)
     {
-        fotaFlagInfo.boot_flag.boot_to = DUAL_SYSTEM;
-		fotaFlagInfo.boot_flag.system2 = system_status;
+        fotaFlagInfo.boot_fota_flag.boot_to = DUAL_SYSTEM;
+		fotaFlagInfo.boot_fota_flag.system2 = system_status;
 
 		if(type == IF_TYPE_NAND || type == IF_TYPE_SPI_NAND)
 		{
@@ -819,8 +821,7 @@
 {
     int ret = 0;
     /* ¶ÁÈ¡flags·ÖÇø */
-	T_BOOT_FOTA_FLAG fotaFlag;
-	T_FOTA_FLAG_INFO fotaFlagInfo;
+	T_FLAGS_INFO fotaFlagInfo;
 	ret = load_flags(&fotaFlagInfo);
 	if(ret != 0)
 	{
@@ -828,12 +829,12 @@
 		return -1;
 	}
 	
-    if(fotaFlagInfo.boot_flag.boot_to == DUAL_SYSTEM)
+    if(fotaFlagInfo.boot_fota_flag.boot_to == DUAL_SYSTEM)
     {
         imagefs_flag = 1;
 		printf("imagefs entry......\n");
 	}
-	else if(fotaFlagInfo.boot_flag.boot_to == DUAL_SYSTEM2)
+	else if(fotaFlagInfo.boot_fota_flag.boot_to == DUAL_SYSTEM2)
     {
         imagefs_flag = 2;
 		printf("imagefs2 entry......\n");
diff --git a/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_vehicle_dc.c b/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_vehicle_dc.c
index 08b530f..79c0241 100755
--- a/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_vehicle_dc.c
+++ b/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_vehicle_dc.c
@@ -37,6 +37,7 @@
 #include <lcd.h>
 #include <peripheral.h>
 #include "board.h"
+#include "pub_flags.h"
 
 #include <drvs_gpio.h>
 
@@ -408,10 +409,10 @@
 	int ret = 0;
 	int type = 0;
 	uchar * flags_name = "flags";
-	T_FOTA_FLAG_INFO fotaFlagInfo;
+	T_FLAGS_INFO fotaFlagInfo = {0};
 	T_DualSystem_Status system_status;
 	system_status.status = DUALSYSTEM_STATUS_UNBOOTABLE;
-	u32 fota_size = sizeof(T_FOTA_FLAG_INFO);
+	u32 fota_size = sizeof(T_FLAGS_INFO);
 	fota_size = page_align(fota_size);
 	
 	nand_info_t *nand = &nand_info[nand_curr_device];
@@ -436,12 +437,14 @@
 	flags_size = entry->part_size;
 	
 	/*ÉèÖÃĬÈÏflags·ÖÇøÊý¾Ý*/
-	fotaFlagInfo.boot_flag.magic = FLAGS_MAGIC;
-	fotaFlagInfo.boot_flag.boot_to = DUAL_SYSTEM;
-	fotaFlagInfo.boot_flag.fota_status = 1;
-	fotaFlagInfo.boot_flag.system.status = DUALSYSTEM_STATUS_BOOTABLE;
-	fotaFlagInfo.boot_flag.system2.status = DUALSYSTEM_STATUS_BOOTABLE;
-
+	fotaFlagInfo.magic_start = FLAGS_MAGIC;
+	fotaFlagInfo.boot_fota_flag.boot_to = DUAL_SYSTEM;
+	fotaFlagInfo.boot_fota_flag.fota_status = 1;
+	fotaFlagInfo.boot_fota_flag.system.status = DUALSYSTEM_STATUS_BOOTABLE;
+	fotaFlagInfo.boot_fota_flag.system2.status = DUALSYSTEM_STATUS_BOOTABLE;
+    fotaFlagInfo.boot_env.dualsys_type = DUALSYSTEM_AB;
+	fotaFlagInfo.magic_end = FLAGS_MAGIC;
+	
 	/*дÈëflags·ÖÇø*/
 	if(type == IF_TYPE_NAND || type == IF_TYPE_SPI_NAND)
 	{
@@ -552,11 +555,10 @@
 	int ret = 0;
 	int type = 0;
 	uchar * flags_name = "flags";
-	T_BOOT_FOTA_FLAG fotaFlag;
-	T_FOTA_FLAG_INFO fotaFlagInfo;
+	T_FLAGS_INFO fotaFlagInfo = {0};
 	T_DualSystem_Status system_status;
 	system_status.status = DUALSYSTEM_STATUS_UNBOOTABLE;
-	u32 fota_size = sizeof(T_FOTA_FLAG_INFO);
+	u32 fota_size = sizeof(T_FLAGS_INFO);
 	fota_size = page_align(fota_size);
 	
 	nand_info_t *nand = &nand_info[nand_curr_device];
@@ -589,10 +591,10 @@
 	}
 
 	/*д»Øflags·ÖÇø*/
-    if(fotaFlagInfo.boot_flag.boot_to == DUAL_SYSTEM)
+    if(fotaFlagInfo.boot_fota_flag.boot_to == DUAL_SYSTEM)
     {
-        fotaFlagInfo.boot_flag.boot_to = DUAL_SYSTEM2;
-		fotaFlagInfo.boot_flag.system = system_status;
+        fotaFlagInfo.boot_fota_flag.boot_to = DUAL_SYSTEM2;
+		fotaFlagInfo.boot_fota_flag.system = system_status;
 
 		if(type == IF_TYPE_NAND || type == IF_TYPE_SPI_NAND)
 		{
@@ -686,10 +688,10 @@
 		printf("system boot status is changed to unbootable!\n");
 		//system_reset();
 	}
-	else if(fotaFlagInfo.boot_flag.boot_to == DUAL_SYSTEM2)
+	else if(fotaFlagInfo.boot_fota_flag.boot_to == DUAL_SYSTEM2)
     {
-        fotaFlagInfo.boot_flag.boot_to = DUAL_SYSTEM;
-		fotaFlagInfo.boot_flag.system2 = system_status;
+        fotaFlagInfo.boot_fota_flag.boot_to = DUAL_SYSTEM;
+		fotaFlagInfo.boot_fota_flag.system2 = system_status;
 
 		if(type == IF_TYPE_NAND || type == IF_TYPE_SPI_NAND)
 		{
@@ -819,8 +821,7 @@
 {
     int ret = 0;
     /* ¶ÁÈ¡flags·ÖÇø */
-	T_BOOT_FOTA_FLAG fotaFlag;
-	T_FOTA_FLAG_INFO fotaFlagInfo;
+	T_FLAGS_INFO fotaFlagInfo;
 	ret = load_flags(&fotaFlagInfo);
 	if(ret != 0)
 	{
@@ -828,12 +829,12 @@
 		return -1;
 	}
 	
-    if(fotaFlagInfo.boot_flag.boot_to == DUAL_SYSTEM)
+    if(fotaFlagInfo.boot_fota_flag.boot_to == DUAL_SYSTEM)
     {
         imagefs_flag = 1;
 		printf("imagefs entry......\n");
 	}
-	else if(fotaFlagInfo.boot_flag.boot_to == DUAL_SYSTEM2)
+	else if(fotaFlagInfo.boot_fota_flag.boot_to == DUAL_SYSTEM2)
     {
         imagefs_flag = 2;
 		printf("imagefs2 entry......\n");
diff --git a/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_vehicle_dc_ref.c b/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_vehicle_dc_ref.c
new file mode 100755
index 0000000..11db015
--- /dev/null
+++ b/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_vehicle_dc_ref.c
@@ -0,0 +1,1043 @@
+/*********************************************************************
+ Copyright 2016 by	ZIXC Corporation.
+*
+* FileName::	zx297520.c
+* File Mark:
+* Description:
+* Others:
+* Version:	 v1.0
+* Author:	zhouqi
+* Date:	  2014-1-15
+
+* History 1:
+*	  Date:
+*	  Version:
+*	  Author:
+*	  Modification:
+* History 2:
+**********************************************************************/
+
+#include <common.h>
+#include <errno.h>
+#include <nand.h>
+#include <asm/arch/nand.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/uart.h>
+#include <asm/arch/lsp_crpm.h>
+#include <power.h>
+#include <partition_table.h>
+
+#include <mmc.h>
+#include <dwmmc.h>
+#include <boot_mode.h>
+#include <load_image.h>
+#include <zx234290.h>
+#include <charge.h>
+//#include <led.h>
+#include <lcd.h>
+#include <peripheral.h>
+#include "board.h"
+#include "pub_flags.h"
+
+#include <drvs_gpio.h>
+
+#include <asm/arch/gmac.h>
+#include <command.h>
+#include <version.h>
+#include <secure_verify.h>
+#include <asm/arch/efuse.h>
+
+#include "cmd_downver.h"
+#include <../drivers/dma/zx29_dma.h>
+
+#include <watchdog.h>
+#include <linux/mtd/partitions.h>
+
+#include <linux/mtd/nor_spifc.h>
+
+#define RET_BOOT_READY		1
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#if	TIME_DEBUG
+#define time_debug_reset(fmt)	fmt = get_timer(0)
+#define time_debug_printf(fmt, val)	printf(fmt ,get_timer(val))
+#else
+#define time_debug_reset(fmt)
+#define time_debug_printf(fmt, val)
+#endif	/* TIME_DEBUG */
+
+typedef struct {
+	int 	(*Init)(void);
+	char	func_name[20];
+}sys_init_func_t;
+
+#ifdef CONFIG_ZX297520V3E_VEHICLE_DC_REF
+int imagefs_flag;
+extern struct fsl_qspi spi_nor_flash;
+extern int flash_dmabuf_disable_flag;
+#endif
+extern boot_reason_t g_boot_reason;
+extern uint32_t g_gmac_init_flag;
+extern uint32_t g_gmac_init_overtime;
+extern unsigned char g_ddr_size_flag;
+
+unsigned int g_uiDebugLevel = UBOOT_NOTICE;
+unsigned int g_sys_kernel_sdram_size = CONFIG_SYS_SDRAM32_A9_SIZE;
+
+
+#ifndef CFG_TEMP_ADDR
+#define CFG_TEMP_ADDR	0x22000000
+#endif
+
+#define reg32(addr)			(*(volatile unsigned long *)(addr))
+
+#define UDELAY_PARAM_1SEC	(100000/3)
+
+/* DebugLevel - Controlled at compile time
+ * UBOOT_ERR	-> Noncritical error conditions.
+ * UBOOT_WARN	-> Warning conditions that should be taken care of.
+ * UBOOT_NOTICE -> Normal, but significant events.
+ * UBOOT_DBG	-> Informational messages that require no action.
+ * UBOOT_INFO	-> Debugging messages, output if the developer enabled debugging.
+ */
+//unsigned int g_uiDebugLevel = UBOOT_NOTICE;
+extern int copy_ddr_allbin(void);
+
+/*******************************************************************************
+ * Function:	board_init
+ * Description:
+ * Parameters:
+ *	 Input:
+ *
+ *	 Output:
+ *
+ * Returns:
+ *
+ *
+ * Others:
+ ********************************************************************************/
+int board_init(void)
+{
+	return 0;
+}
+
+/*******************************************************************************
+ * Function:	dram_init_banksize
+ * Description:
+ * Parameters:
+ *	 Input:
+ *
+ *	 Output:
+ *
+ * Returns:
+ *
+ *
+ * Others:
+ ********************************************************************************/
+void dram_init_banksize(void)
+{
+	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
+	gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
+}
+
+/*******************************************************************************
+ * Function:	dram_init
+ * Description:
+ * Parameters:
+ *	 Input:
+ *
+ *	 Output:
+ *
+ * Returns:
+ *
+ *
+ * Others:
+ ********************************************************************************/
+int dram_init(void)
+{
+	gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
+				PHYS_SDRAM_1_SIZE);
+
+	return 0;
+}
+
+/*******************************************************************************
+ * Function:	checkboard
+ * Description:
+ * Parameters:
+ *	 Input:
+ *
+ *	 Output:
+ *
+ * Returns:
+ *
+ *
+ * Others:
+ ********************************************************************************/
+int checkboard(void)
+{
+#ifdef CONFIG_DISPLAY_BOARDINFO
+	printf("Board: ZX297520V3\n");
+#endif
+
+	return 0;
+}
+
+void clear_iram(uint32_t addr, uint32_t len)
+{
+	uint32_t i = 0;
+	for(i = addr; i < addr + len; i+=4)
+	{
+		writel(0x0, i);
+	}
+}
+
+void clear_tmp_buf(void)
+{
+	clear_iram(CONFIG_SYS_SDRAM_TEMP_BASE, 0x800);
+}
+
+/*
+ * EC: 616000510470
+ */
+static int mdl_poweron(void)
+{
+	pmu_pull_on_ps_hold();
+
+	return 0;
+}
+
+static int gmac_download_init(void)
+{
+	int ret = 0;
+
+	get_gmac_init_flag();
+	BOOT_PRINTF(UBOOT_DBG, "get_gmac_init_flag = 0x%x, read_gmac_init_flag = 0x%x.\n", get_gmac_init_flag(), read_gmac_init_flag());
+	if(1 == read_gmac_init_flag())
+	{
+		BOOT_PRINTF(UBOOT_NOTICE, "gmac init overtime[%ds].....$$$$$$$$$$$$$$\n", read_gmac_init_overtime());
+
+		puts("Net:	");
+		eth_initialize(gd->bd);
+
+		if (run_command ("downver allbins", 0) >= 0)
+		{
+			ret = copy_ddr_allbin();
+			if(ret != 0)
+			{
+				BOOT_PRINTF(UBOOT_ERR, "net load write from ddr to nand FAILED !!!\n");
+			}
+		}
+		else
+		{
+			BOOT_PRINTF(UBOOT_ERR, "run_command downver allbins FAILED !!!\n");
+		}
+	}
+
+	return 0;
+}
+
+static int test_env_entry(void)
+{
+	/* Ó²¼þ²âÊÔ */
+#if CONFIG_HARDWARE_TEST
+	hardware_test();
+#endif
+
+#if CONFIG_MUTUAL_DEBUG	//ÖÃ1Ö®ºó¾Í¿ÉÒÔ½øÈëUBoot¿ØÖÆÌ¨ÃüÁîÐÐ
+	for (;;)
+	{
+		main_loop();
+	}
+#endif
+
+	return 0;
+}
+
+static int boot_reason_init(void)
+{
+	int ret = 0;
+	unsigned int amt_flag = 0;
+	unsigned int key_times = 0;
+	unsigned int *poweron_type = (unsigned int *)POWERON_TYPE_ADDR;	 //ÁÙʱʹÓÃ
+
+	BOOT_PRINTF(UBOOT_DBG, "Normal mode.\n");
+
+	amt_flag = readl(POWERON_TYPE_ADDR);
+	BOOT_PRINTF(UBOOT_NOTICE, "VALUE = 0x%x!\n", amt_flag);
+	if(amt_flag == AMT_MODE_FLAG)
+	{
+		BOOT_PRINTF(UBOOT_NOTICE, "AMT VALUE = AMT_MODE_FLAG!\n");
+		g_boot_reason = RB_AMT;
+	}
+	else
+	{
+		ret = get_boot_reason();
+		if(ret != 0)
+		{
+			BOOT_PRINTF(UBOOT_ERR, "get boot reason ERROR !!!\n");
+			/* TBD: Error Return. */
+		}
+	}
+
+	if(read_fota_update_flag() == FOTA_RECOVERY)
+	{
+		*poweron_type = POWER_ON_FOTA;
+	}
+	else if(read_fota_update_flag() == FOTA_LOCALUPDATE)
+	{
+		*poweron_type = POWER_ON_LOCALUPDATE;
+	}
+	else if(g_boot_reason == RB_AMT)
+	{
+		*poweron_type = POWER_ON_AMT;
+	}
+	else if(g_boot_reason == RB_PRODUCTION)
+	{
+		*poweron_type = POWER_ON_PRODUCTION;
+	}
+	else if((g_boot_reason & 0xF0) == ZX234290_WDT_RST_FLAG)
+	{
+		*poweron_type = g_boot_reason & 0x0F;
+	}
+	else if(g_boot_reason == RB_RESET_NOMAL)
+	{
+		*poweron_type = POWER_ON_NORMAL;
+	}
+	else if(g_boot_reason == RB_RTC)
+	{
+		*poweron_type = POWER_ON_RTC; //POWER_ON_NORMAL;
+	}
+	else if(g_boot_reason == RB_RESET_EXCEPT)
+	{
+		*poweron_type = POWER_ON_EXCEPTRESET;
+	}
+	else if(g_boot_reason == RB_POWER_BOOST_IN)
+	{
+		*poweron_type = POWER_ON_BOOST_IN;
+	}
+	else if(g_boot_reason == RB_RESET_ALARM)
+	{
+		*poweron_type = POWER_ON_NORMAL;
+	}
+	else
+	{
+		*poweron_type = POWER_ON_NORMAL;
+	}
+	BOOT_PRINTF(UBOOT_NOTICE, "poweron_type=0x%x.\n", *poweron_type);
+	zx234290_write_flag(ZX234290_WDT_RST_FLAG | *poweron_type);
+
+	return 0;
+}
+
+static int bat_detect(void)
+{
+	return 0;
+}
+
+void display_boot_animation(unsigned int poweron_type)
+{
+	switch (poweron_type) {
+	case POWER_ON_LOCALUPDATE:
+		Show_UpdateWait();
+		break;
+
+	case POWER_ON_NORMAL:
+		Show_PowerOn_Normal();
+		break;
+
+	case POWER_ON_FOTA:
+		Show_PowerOn_Fota();
+		break;
+
+	case POWER_ON_CHARGING:
+		Show_Charging();
+		break;
+
+	default:
+		break;
+	}
+}
+
+static int boot_prepare(void)
+{
+	unsigned int poweron_type = reg32(POWERON_TYPE_ADDR);	 //ÁÙʱʹÓÃ
+
+/*
+	if (poweron_type == POWER_ON_CHARGING) {
+		pmu_pull_off_ps_hold();
+	} else {
+		pmu_pull_on_ps_hold();
+	}
+*/
+#if 1
+	//zx234290_set_softon(1);
+#else
+	zx234290_set_softon(0);
+	pmu_pull_off_ps_hold();
+#endif
+
+	display_boot_animation(poweron_type);
+
+	return 0;
+}
+
+#ifdef CONFIG_ZX297520V3E_VEHICLE_DC_REF
+static uint32_t page_align(uint32_t offset)
+{
+	struct flash_ops *flash = NULL;
+	uint32_t page_size = 0;
+
+	flash = get_flash_ops();
+	page_size = flash->page_size;
+	if( offset & (page_size - 1) )
+	{
+		offset &= (~(page_size - 1));
+		offset += page_size;
+	}
+	return offset;
+}
+
+int rewrite_flags(void)
+{
+    uint32_t off = 0;
+	uint32_t flags_size = 0;/*flags·ÖÇø2M*/
+	uint32_t blockNum = 0;
+	uint32_t work_area_offset = 0;
+	uint32_t backup_area_offset = 0;
+	int ret = 0;
+	int type = 0;
+	uchar * flags_name = "flags";
+	T_FLAGS_INFO fotaFlagInfo = {0};
+	T_DualSystem_Status system_status;
+	system_status.status = DUALSYSTEM_STATUS_UNBOOTABLE;
+	u32 fota_size = sizeof(T_FLAGS_INFO);
+	fota_size = page_align(fota_size);
+	
+	nand_info_t *nand = &nand_info[nand_curr_device];
+	struct fsl_qspi *nor = &spi_nor_flash;
+	uint32_t part_offset = 0;
+	struct flash_ops *flash = NULL;
+	flash_dmabuf_disable_flag = 1;
+	nand_erase_options_t opts;
+
+	flash = get_flash_ops();
+	type = read_boot_flashtype();
+
+	/* ѰÕÒ·ÖÇø */
+	partition_entry_t * entry = find_partition_para(flags_name);
+	if( entry == NULL )
+	{
+		BOOT_PRINTF(UBOOT_ERR, "[%s]: can't find the partition...\n", flags_name);
+		return -1;
+	}
+	/* »ñµÃ·ÖÇøÊ×µØÖ·ºÍ´óС */
+	part_offset = entry->part_offset;
+	flags_size = entry->part_size;
+	
+	/*ÉèÖÃĬÈÏflags·ÖÇøÊý¾Ý*/
+	fotaFlagInfo.magic_start = FLAGS_MAGIC;
+	fotaFlagInfo.boot_fota_flag.boot_to = DUAL_SYSTEM;
+	fotaFlagInfo.boot_fota_flag.fota_status = 1;
+	fotaFlagInfo.boot_fota_flag.system.status = DUALSYSTEM_STATUS_BOOTABLE;
+	fotaFlagInfo.boot_fota_flag.system2.status = DUALSYSTEM_STATUS_BOOTABLE;
+    fotaFlagInfo.boot_env.dualsys_type = DUALSYSTEM_AB;
+	fotaFlagInfo.magic_end = FLAGS_MAGIC;
+	
+	/*дÈëflags·ÖÇø*/
+	if(type == IF_TYPE_NAND || type == IF_TYPE_SPI_NAND)
+	{
+        
+	   /*È·¶¨¹¤×÷ÇøºÍ±¸·ÝÇøÆ«ÒÆµØÖ·*/
+		for (off = part_offset; off < part_offset+flags_size; off += nand->erasesize)
+		{
+			if (!(nand_block_isbad(nand,off))) 
+				blockNum += 1;
+			
+			if(blockNum == 1)
+				work_area_offset = off;
+			
+			else if(blockNum == 2)
+			{
+				 backup_area_offset = off;
+				 break;
+			}		
+		}
+	
+		if(blockNum < 2)
+		{
+			printf("flags partition have not enough space!\n");
+				
+			return -1;
+		}
+		
+		/*²Á³ýflagsÖ÷·ÖÇø*/
+		memset(&opts, 0, sizeof(opts));
+		opts.offset = work_area_offset;
+		opts.length = fota_size;
+		ret = flash->erase(nand,&opts);
+
+		if( ret != 0 )
+ 		{
+ 			BOOT_PRINTF(UBOOT_ERR, "[%s]: erase the flags imagefs work area error!\n", flags_name);
+ 			return 1;
+ 		}
+
+		ret = flash->write(nand,(loff_t)(work_area_offset),
+				  &fota_size,(u_char *)(&fotaFlagInfo),0);
+		
+ 		if( ret != 0 )
+ 		{
+ 			BOOT_PRINTF(UBOOT_ERR, "[%s]: write the flags imagefs work area error!\n", flags_name);
+ 			return 1;
+ 		}
+	
+		/*²Á³ýflags±¸ÓÃÇø*/
+		memset(&opts, 0, sizeof(opts));
+		opts.offset = backup_area_offset;
+		opts.length = fota_size;
+		ret += flash->erase(nand,&opts);
+
+		if( ret != 0 )
+ 		{
+ 			BOOT_PRINTF(UBOOT_ERR, "[%s]: erase the flags imagefs backup area error!\n", flags_name);
+ 			return 1;
+ 		}
+		
+		ret += flash->write(nand,(loff_t)(backup_area_offset),
+				  &fota_size,(u_char *)(&fotaFlagInfo),0);
+ 		if( ret != 0 )
+ 		{
+ 			BOOT_PRINTF(UBOOT_ERR, "[%s]: write the flags imagefs backup area error!\n", flags_name);
+ 			return 1;
+ 		}
+	}
+	else if(type == IF_TYPE_NOR)
+	{   
+        /*²Á³ýflags·ÖÇø*/
+		work_area_offset = part_offset;
+        backup_area_offset = part_offset + nor->nor[0].mtd.erasesize;
+		ret = nand_erase(&(nor->nor[0].mtd), (loff_t)(work_area_offset), fota_size);
+		ret += nand_erase(&(nor->nor[0].mtd), (loff_t)(backup_area_offset), fota_size);
+		if( ret != 0 )
+ 		{
+ 			BOOT_PRINTF(UBOOT_ERR, "[%s]: erase the flags imagefs error!\n", flags_name);
+ 			return 1;
+ 		}
+		
+		ret = nand_write(&(nor->nor[0].mtd), (loff_t)(work_area_offset), 
+						&fota_size, (u_char *)(&fotaFlagInfo));
+		ret += nand_write(&(nor->nor[0].mtd), (loff_t)(backup_area_offset), 
+						&fota_size, (u_char *)(&fotaFlagInfo));
+		if(ret != 0)
+		{
+			BOOT_PRINTF(UBOOT_ERR, "[%s]: write the flags imagefs error!\n", flags_name);
+			return 1;
+		}
+	}
+	
+	printf("flags partition data is error,already rewrite default parameters!\n");
+	//system_reset();
+	
+	flash_dmabuf_disable_flag = 0; 
+    flush_dcache_all();
+    return 0;
+}
+
+int writeback_flags(void)
+{
+    uint32_t off = 0;
+	uint32_t flags_size = 0;/*flags·ÖÇø2M*/
+	uint32_t blockNum = 0;
+	uint32_t work_area_offset = 0;
+	uint32_t backup_area_offset = 0;
+	int ret = 0;
+	int type = 0;
+	uchar * flags_name = "flags";
+	T_FLAGS_INFO fotaFlagInfo = {0};
+	T_DualSystem_Status system_status;
+	system_status.status = DUALSYSTEM_STATUS_UNBOOTABLE;
+	u32 fota_size = sizeof(T_FLAGS_INFO);
+	fota_size = page_align(fota_size);
+	
+	nand_info_t *nand = &nand_info[nand_curr_device];
+	struct fsl_qspi *nor = &spi_nor_flash;
+	uint32_t part_offset = 0;
+	struct flash_ops *flash = NULL;
+	flash_dmabuf_disable_flag = 1;
+	nand_erase_options_t opts;
+
+	flash = get_flash_ops();
+	type = read_boot_flashtype();
+
+	/* ѰÕÒ·ÖÇø */
+	partition_entry_t * entry = find_partition_para(flags_name);
+	if( entry == NULL )
+	{
+		BOOT_PRINTF(UBOOT_ERR, "[%s]: can't find the partition...\n", flags_name);
+		return -1;
+	}
+	/* »ñµÃ·ÖÇøÊ×µØÖ·ºÍ´óС */
+	part_offset = entry->part_offset;
+	flags_size = entry->part_size;
+	
+	/*¶ÁÈ¡flags·ÖÇø*/
+	ret = load_flags(&fotaFlagInfo);
+	if(ret != 0)
+	{
+		printf("read flags partition err.\n");
+		return -1;
+	}
+
+	/*д»Øflags·ÖÇø*/
+    if(fotaFlagInfo.boot_fota_flag.boot_to == DUAL_SYSTEM)
+    {
+        fotaFlagInfo.boot_fota_flag.boot_to = DUAL_SYSTEM2;
+		fotaFlagInfo.boot_fota_flag.system = system_status;
+
+		if(type == IF_TYPE_NAND || type == IF_TYPE_SPI_NAND)
+		{
+            
+		   /*È·¶¨¹¤×÷ÇøºÍ±¸·ÝÇøÆ«ÒÆµØÖ·*/
+			for (off = part_offset; off < part_offset+flags_size; off += nand->erasesize)
+			{
+				if (!(nand_block_isbad(nand,off))) 
+					blockNum += 1;
+				
+				if(blockNum == 1)
+					work_area_offset = off;
+				
+				else if(blockNum == 2)
+				{
+					 backup_area_offset = off;
+					 break;
+				}		
+			}
+		
+			if(blockNum < 2)
+			{
+				printf("flags partition have not enough space!\n");
+					
+				return -1;
+			}
+			
+			/*²Á³ýflagsÖ÷·ÖÇø*/
+			memset(&opts, 0, sizeof(opts));
+			opts.offset = work_area_offset;
+			opts.length = fota_size;
+			ret = flash->erase(nand,&opts);
+
+			if( ret != 0 )
+	 		{
+	 			BOOT_PRINTF(UBOOT_ERR, "[%s]: erase the flags imagefs work area error!\n", flags_name);
+	 			return 1;
+	 		}
+
+			ret = flash->write(nand,(loff_t)(work_area_offset),
+					  &fota_size,(u_char *)(&fotaFlagInfo),0);
+	 		if( ret != 0 )
+	 		{
+	 			BOOT_PRINTF(UBOOT_ERR, "[%s]: write the flags imagefs work area error!\n", flags_name);
+	 			return 1;
+	 		}
+			
+			/*²Á³ýflags±¸ÓÃÇø*/
+			memset(&opts, 0, sizeof(opts));
+			opts.offset = backup_area_offset;
+			opts.length = fota_size;
+			ret += flash->erase(nand,&opts);
+
+			if( ret != 0 )
+	 		{
+	 			BOOT_PRINTF(UBOOT_ERR, "[%s]: erase the flags imagefs backup area error!\n", flags_name);
+	 			return 1;
+	 		}
+			
+			ret += flash->write(nand,(loff_t)(backup_area_offset),
+					  &fota_size,(u_char *)(&fotaFlagInfo),0);
+	 		if( ret != 0 )
+	 		{
+	 			BOOT_PRINTF(UBOOT_ERR, "[%s]: write the flags imagefs backup area error!\n", flags_name);
+	 			return 1;
+	 		}
+		}
+		else if(type == IF_TYPE_NOR)
+		{   
+            /*²Á³ýflags·ÖÇø*/
+			work_area_offset = part_offset;
+	        backup_area_offset = part_offset + nor->nor[0].mtd.erasesize;
+			ret = nand_erase(&(nor->nor[0].mtd), (loff_t)(work_area_offset), fota_size);
+			ret += nand_erase(&(nor->nor[0].mtd), (loff_t)(backup_area_offset), fota_size);
+			if( ret != 0 )
+	 		{
+	 			BOOT_PRINTF(UBOOT_ERR, "[%s]: erase the flags imagefs error!\n", flags_name);
+	 			return 1;
+	 		}
+			
+			ret = nand_write(&(nor->nor[0].mtd), (loff_t)(work_area_offset), 
+							&fota_size, (u_char *)(&fotaFlagInfo));
+			ret += nand_write(&(nor->nor[0].mtd), (loff_t)(backup_area_offset), 
+							&fota_size, (u_char *)(&fotaFlagInfo));
+			if(ret != 0)
+			{
+				BOOT_PRINTF(UBOOT_ERR, "[%s]: write the flags imagefs error!\n", flags_name);
+				return 1;
+			}
+		}
+		printf("system boot status is changed to unbootable!\n");
+		//system_reset();
+	}
+	else if(fotaFlagInfo.boot_fota_flag.boot_to == DUAL_SYSTEM2)
+    {
+        fotaFlagInfo.boot_fota_flag.boot_to = DUAL_SYSTEM;
+		fotaFlagInfo.boot_fota_flag.system2 = system_status;
+
+		if(type == IF_TYPE_NAND || type == IF_TYPE_SPI_NAND)
+		{
+            /*È·¶¨¹¤×÷ÇøºÍ±¸·ÝÇøÆ«ÒÆµØÖ·*/
+			for (off = part_offset; off < part_offset+flags_size; off += nand->erasesize)
+			{
+				if (!(nand_block_isbad(nand,off))) 
+					blockNum += 1;
+				
+				if(blockNum == 1)
+					work_area_offset = off;
+				
+				else if(blockNum == 2)
+				{
+					 backup_area_offset = off;
+					 break;
+				}		
+			}
+		
+			if(blockNum < 2)
+			{
+				printf("flags partition have not enough space!\n");
+					
+				return -1;
+			}
+			
+			/*²Á³ýflagsÖ÷·ÖÇø*/
+			memset(&opts, 0, sizeof(opts));
+			opts.offset = work_area_offset;
+			opts.length = fota_size;
+			ret = flash->erase(nand,&opts);
+
+			if( ret != 0 )
+	 		{
+	 			BOOT_PRINTF(UBOOT_ERR, "[%s]: erase the flags imagefs work area error!\n", flags_name);
+	 			return 1;
+	 		}
+
+			ret = flash->write(nand,(loff_t)(work_area_offset),
+					  &fota_size,(u_char *)(&fotaFlagInfo),0);
+	
+	 		if( ret != 0 )
+	 		{
+	 			BOOT_PRINTF(UBOOT_ERR, "[%s]: write the flags imagefs work area error!\n", flags_name);
+	 			return 1;
+	 		}
+		
+			/*²Á³ýflags±¸ÓÃÇø*/
+			memset(&opts, 0, sizeof(opts));
+			opts.offset = backup_area_offset;
+			opts.length = fota_size;
+			ret += flash->erase(nand,&opts);
+
+			if( ret != 0 )
+	 		{
+	 			BOOT_PRINTF(UBOOT_ERR, "[%s]: erase the flags imagefs backup area error!\n", flags_name);
+	 			return 1;
+	 		}
+			
+			ret += flash->write(nand,(loff_t)(backup_area_offset),
+					  &fota_size,(u_char *)(&fotaFlagInfo),0);
+	 		if( ret != 0 )
+	 		{
+	 			BOOT_PRINTF(UBOOT_ERR, "[%s]: write the flags imagefs backup area error!\n", flags_name);
+	 			return 1;
+	 		}
+		}
+		else if(type == IF_TYPE_NOR)
+		{
+            /*²Á³ýflags·ÖÇø*/
+			work_area_offset = part_offset;
+	        backup_area_offset = part_offset + nor->nor[0].mtd.erasesize;
+			ret = nand_erase(&(nor->nor[0].mtd), (loff_t)(work_area_offset), fota_size);
+			ret += nand_erase(&(nor->nor[0].mtd), (loff_t)(backup_area_offset), fota_size);
+			if( ret != 0 )
+	 		{
+	 			BOOT_PRINTF(UBOOT_ERR, "[%s]: erase the flags imagefs error!\n", flags_name);
+	 			return 1;
+	 		}
+			
+			ret = nand_write(&(nor->nor[0].mtd), (loff_t)(work_area_offset), 
+							&fota_size, (u_char *)(&fotaFlagInfo));
+			ret += nand_write(&(nor->nor[0].mtd), (loff_t)(backup_area_offset), 
+							&fota_size, (u_char *)(&fotaFlagInfo));
+			if(ret != 0)
+			{
+				BOOT_PRINTF(UBOOT_ERR, "[%s]: write the flags imagefs error!\n", flags_name);
+				return -1;
+			}
+		}
+		//flash.write(nand,(loff_t)part_offset,&flagsSize,(u_char *)(&fotaFlag),0);
+		printf("system2 boot status is changed to unbootable!\n");
+	}
+	
+	flash_dmabuf_disable_flag = 0; 
+    flush_dcache_all();
+    return 0;
+}
+
+int system_boot_status(void)
+{
+    int ret;
+	u32 bootFlags = readl(BOOT_FLAG_ADDR);
+	
+	if(bootFlags == DUALSYSTEM_STATUS_UNBOOTABLE)
+	{
+        ret = writeback_flags();
+		if(ret != 0)
+			return -1;
+		system_reset();
+		return 0;
+	}
+	else if(bootFlags == DUALSYSTEM_STATUS_BOOTABLE)
+	{
+        return 0;
+	}
+	else if(bootFlags == FLAGS_PARTITION_ERROR)
+	{
+		ret = rewrite_flags();
+		if(ret != 0)
+			return -1;
+		return 0;
+	}
+}
+
+static int read_imagefs_flag(void)
+{
+    int ret = 0;
+    /* ¶ÁÈ¡flags·ÖÇø */
+	T_FLAGS_INFO fotaFlagInfo;
+	ret = load_flags(&fotaFlagInfo);
+	if(ret != 0)
+	{
+		printf("read flags partition err.\n");
+		return -1;
+	}
+	
+    if(fotaFlagInfo.boot_fota_flag.boot_to == DUAL_SYSTEM)
+    {
+        imagefs_flag = 1;
+		printf("imagefs entry......\n");
+	}
+	else if(fotaFlagInfo.boot_fota_flag.boot_to == DUAL_SYSTEM2)
+    {
+        imagefs_flag = 2;
+		printf("imagefs2 entry......\n");
+	}
+	
+	return 0;
+}
+#endif
+static int boot_entry(void)
+{
+	int ret = 0;
+	unsigned int poweron_type = reg32(POWERON_TYPE_ADDR);	 //ÁÙʱʹÓÃ
+
+	//g_ddr_size_flag = CHIP_DDR_IS_32M;
+
+	switch (poweron_type) {
+	case POWER_ON_LOCALUPDATE:
+		break;
+	case POWER_ON_FOTA:
+		BOOT_PRINTF(UBOOT_NOTICE, "Fota entry!\n");
+		if(g_ddr_size_flag == CHIP_DDR_IS_32M)
+		{
+			g_sys_kernel_sdram_size = CONFIG_SYS_SDRAM32_RECOVERY_A9_SIZE;
+		}
+		else if(g_ddr_size_flag == CHIP_DDR_IS_64M)
+		{
+			g_sys_kernel_sdram_size = CONFIG_SYS_SDRAM64_RECOVERY_A9_SIZE;
+		}
+		else if(g_ddr_size_flag == CHIP_DDR_IS_128M)
+		{
+			g_sys_kernel_sdram_size = CONFIG_SYS_SDRAM128_RECOVERY_A9_SIZE;
+		}		
+		else
+		{
+			g_sys_kernel_sdram_size = CONFIG_SYS_SDRAM256_RECOVERY_A9_SIZE;
+		}
+		
+		ret = fs_load_arm_image_linux(ARM_RECOVERY_USERDATA_IMAGE);	/*FOTA-UPDATE*/
+		break;
+	default:
+		BOOT_PRINTF(UBOOT_NOTICE, "Normal entry!\n");
+		g_sys_kernel_sdram_size = DDR_BASE_LEN_AP;
+#if 0
+		if(g_ddr_size_flag == CHIP_DDR_IS_32M)
+		{
+			g_sys_kernel_sdram_size = CONFIG_SYS_SDRAM32_A9_SIZE;
+		}
+		else if(g_ddr_size_flag == CHIP_DDR_IS_64M)
+		{
+			g_sys_kernel_sdram_size = CONFIG_SYS_SDRAM64_A9_SIZE;
+		}
+		else if(g_ddr_size_flag == CHIP_DDR_IS_128M)
+		{
+			g_sys_kernel_sdram_size = CONFIG_SYS_SDRAM128_A9_SIZE;
+		}
+		else
+		{
+			g_sys_kernel_sdram_size = CONFIG_SYS_SDRAM256_A9_SIZE;
+		}
+#endif
+		ret = fs_load_m0_image();
+		ret += fs_load_zsp_image();
+		ret += fs_load_dtb_image();
+		ret += fs_load_arm_image_linux(ARM_CAP_IMAGE);
+		ret += fs_load_arm_image_linux(ARM_APP_IMAGE);
+		break;
+	}
+
+#if VERSION_RELEASE
+	if( ret != 0 )
+	{
+		BOOT_PRINTF(UBOOT_ERR, "load images ERROR !!!\n");
+#ifdef CONFIG_ZX297520V3E_VEHICLE_DC_REF
+        writeback_flags();
+		system_reset();
+#endif
+	}
+#endif
+
+	return 0;
+}
+
+static const sys_init_func_t uboot_init_func_tbl[] =
+{
+	{mdl_poweron,			"pull on pshold"},
+	{wdt_get_reboot_reason,	"wdt_reboot"},
+	{dma_init,				"dma"},
+	{i2c_init,				"i2c"},
+	{peripheral_init,		"peri"},
+	{nand_init,				"nand"},
+	{partition_init,		"partition"},	
+	{gmac_download_init,	"gmac"},
+	{test_env_entry,		"test"},
+	{efuse_init,			"efuse"},
+#ifdef CONFIG_ZX297520V3E_VEHICLE_DC_REF
+    {system_boot_status,    "system_boot_status"},
+	{read_imagefs_flag,     "read_imagefs_flag"},
+#endif
+	{nvrw_flag_init,		"nvrw_flag"},
+	{boot_reason_init,		"boot_reason"},
+	{wdt_init,				"wdt"},
+	{bat_detect,			"bat_det"},
+	{boot_prepare,			"boot_prepare"},
+	{NULL,					{}}
+};
+
+static const sys_init_func_t tboot_init_func_tbl[] =
+{
+	{wdt_get_reboot_reason,	"wdt_reboot"},
+	{dma_init,				"dma"},
+	{i2c_init,				"i2c"},
+	{peripheral_init,		"peri"},
+	{nand_init,				"nand"},
+	{NULL,					{}}
+};
+
+int uboot_init_func(void)
+{
+	unsigned int dev_index;
+	int ret;
+
+	BOOT_PRINTF(UBOOT_NOTICE, "go into uboot init func\n");
+
+	for (dev_index = 0; (uboot_init_func_tbl[dev_index].Init != NULL); dev_index++)
+	{
+		ret = uboot_init_func_tbl[dev_index].Init();
+
+		if (ret < 0) {
+			BOOT_PRINTF(UBOOT_ERR, "uboot init %s fail, ret = %d\n",
+				uboot_init_func_tbl[dev_index].func_name, ret);
+			BUG();
+			return ret;
+		} else {
+			BOOT_PRINTF(UBOOT_NOTICE, "uboot init %s success\n",
+				uboot_init_func_tbl[dev_index].func_name);
+		}
+	}
+
+	return SUCCESS;
+}
+
+int tboot_init_func(void)
+{
+	unsigned int dev_index;
+	int ret;
+
+	BOOT_PRINTF(UBOOT_NOTICE, "go into tboot init func\n");
+
+	for (dev_index = 0; (tboot_init_func_tbl[dev_index].Init != NULL); dev_index++)
+	{
+		ret = tboot_init_func_tbl[dev_index].Init();
+		if (ret < 0) {
+			BOOT_PRINTF(UBOOT_ERR, "tboot init %s fail, ret = %d\n",
+				tboot_init_func_tbl[dev_index].func_name, ret);
+			BUG();
+			return ret;
+		} else {
+			BOOT_PRINTF(UBOOT_NOTICE, "tboot init %s success\n",
+				tboot_init_func_tbl[dev_index].func_name);
+		}
+	}
+
+	return SUCCESS;
+}
+
+/*******************************************************************************
+ * Function:	sys_entry
+ * Description: ϵͳÖ÷Á÷³Ì
+ * Parameters:
+ *	 Input:
+ *
+ *	 Output:
+ *
+ * Returns:
+ *
+ *
+ * Others:
+ ********************************************************************************/
+void sys_entry(void)
+{
+	BOOT_PRINTF(UBOOT_NOTICE, "sys_entry ...\n");
+
+	switch (get_load_mode()) {
+	case TLOAD_MODE:
+		tboot_init_func();
+		run_command("downloader", 0);
+		break;
+	case ZLOAD_MODE:
+		uboot_init_func();
+		boot_entry();
+		//clear_tmp_buf();
+		break;
+	default:
+		break;
+	}
+
+	add_partition_to_bootargs();
+	for (;;)
+	{
+		main_loop();
+	}
+
+	hang();
+	/* NOTREACHED - no way out of command loop except booting */
+}
+
diff --git a/boot/common/src/uboot/common/image.c b/boot/common/src/uboot/common/image.c
index a43ab1d..1eb2b49 100755
--- a/boot/common/src/uboot/common/image.c
+++ b/boot/common/src/uboot/common/image.c
@@ -1275,7 +1275,8 @@
 		    (void *)(ulong) lmb_alloc_base(lmb, of_len, 0x1000,
 						   getenv_bootm_mapsize()
 						   + getenv_bootm_low());
-#ifdef CONFIG_ZX297520V3E_VEHICLE_DC
+
+#if defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 		of_start = *of_flat_tree;
 #endif
 	}
diff --git a/boot/common/src/uboot/downloader/cmd_set.c b/boot/common/src/uboot/downloader/cmd_set.c
index 9e98959..8831694 100755
--- a/boot/common/src/uboot/downloader/cmd_set.c
+++ b/boot/common/src/uboot/downloader/cmd_set.c
@@ -98,6 +98,29 @@
 	""

 );

 

+static unsigned int gen_crc(char *pInput, int InputLen)

+{

+

+	char pOutput[4];

+	unsigned int *pcrc = (unsigned int *)pOutput;

+	int OutputLen = 4;

+	char *check = pOutput;

+	int i, j;

+	memcpy(check, pInput, OutputLen);

+	pInput += OutputLen;

+

+	for(i = 0; i < InputLen; i += OutputLen)

+	{

+		for(j = 0; j < OutputLen; j++)

+		{

+			check[j] ^= pInput[i + j];

+		}

+	}

+

+	return *pcrc;

+

+}

+

 /*******************************************************************************

  * Function:set_partitions

  * Description:

@@ -117,6 +140,7 @@
 	partition_entry_t *part_nvr_dl = NULL;

 	partition_table_t *table_dl = NULL;

 	char *table_new = (char*)(CONFIG_USB_DMA_BUF_ADDR); /*USB DMA BUFFER*/

+	uint32_t crc_cal = 0;

 

 	/* UE´ÓPC»ñÈ¡·ÖÇø±í */

 	downloader_serial_read_actuallen((char *)table_new, size); 

@@ -128,9 +152,11 @@
 		printf("set_partitions kzalloc failed.\n");

 		return -1;

 	}

-	

+	/*·ÖÇø±ícrcУÑé*/

+    crc_cal = gen_crc(((unsigned char*)table_dl) + 32, table_dl->entrys * sizeof(partition_entry_t));

+

 	memcpy(g_partition_table_dl,table_dl,size);

-	if(table_dl->magic != PARTITION_MAGIC)

+	if((table_dl->magic != PARTITION_MAGIC) || crc_cal != table_dl->crc)

 	{

 	    sprintf(tsp_console_buffer,"FAIL INVALID_PARTITION_TABLE");

         downloader_serial_write(tsp_console_buffer, strlen(tsp_console_buffer)+1);

diff --git a/boot/common/src/uboot/drivers/misc/boot_mode.c b/boot/common/src/uboot/drivers/misc/boot_mode.c
index fafe3c7..2408bbc 100755
--- a/boot/common/src/uboot/drivers/misc/boot_mode.c
+++ b/boot/common/src/uboot/drivers/misc/boot_mode.c
@@ -30,7 +30,7 @@
 
 #define NVRWALL_PATH "/nvrwall.bin"
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 extern int imagefs_flag;
 #endif
 
@@ -47,7 +47,7 @@
 	char cmd[64] = {0};
 
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
     if(imagefs_flag == 1)
 	    sprintf(cmd, "fsload imagefs 0x%x %s", (ulong)CONFIG_SYS_SDRAM_TEMP_BASE, NVRWALL_PATH);
 	else
diff --git a/boot/common/src/uboot/drivers/misc/load.c b/boot/common/src/uboot/drivers/misc/load.c
index c44dc9b..bbb6c27 100755
--- a/boot/common/src/uboot/drivers/misc/load.c
+++ b/boot/common/src/uboot/drivers/misc/load.c
@@ -31,6 +31,7 @@
 #include <asm/arch/cpu.h>
 #include <secure_verify.h>
 #include <linux/mtd/nor_spifc.h>
+#include "pub_flags.h"
 
 #if	LOAD_IMAGE_DEBUG
 #define load_debug_printf(fmt,args...)	printf (fmt ,##args)
@@ -66,7 +67,7 @@
 #endif
 
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 extern int imagefs_flag;
 static uint32_t flags;
 #endif
@@ -305,12 +306,12 @@
 	return 0;
 }
 
-#ifdef CONFIG_ZX297520V3E_VEHICLE_DC
+#if defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 int fs_load_dtb_image(void)
 {
     char    cmd[64] = {0};
     /*1¡¢½«dtbÎļþloadµ½ÁÙʱµØÖ·*/
-#ifdef CONFIG_ZX297520V3E_VEHICLE_DC
+#if defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
     if(imagefs_flag == 1)
 		sprintf(cmd, "fsload imagefs 0x%x %s", (ulong)CONFIG_SYS_SDRAM_TEMP_BASE, DTB_IMAGE_PATH);
 	else
@@ -342,7 +343,7 @@
 
 	/*1¡¢½«m0 imgÎļþloadµ½ÁÙʱµØÖ·*/
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
     if(imagefs_flag == 1)
 		sprintf(cmd, "fsload imagefs 0x%x %s", (ulong)CONFIG_SYS_SDRAM_TEMP_BASE, M0_IMAGE_PATH);
 	else
@@ -427,7 +428,7 @@
 	{
 		/* ½«zsp imgÎļþloadµ½ÁÙʱµØÖ·*/
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)  || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
         if(imagefs_flag == 1)
 		    sprintf(cmd, "fsload imagefs 0x%x cpuphy_%02d.lzma", 
 				(ulong)CONFIG_SYS_SDRAM_TEMP_BASE, 
@@ -529,7 +530,7 @@
 	{
 		/*1¡¢½«ap imgÎļþloadµ½ÁÙʱµØÖ·*/
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
         if(imagefs_flag == 1)
 			sprintf(cmd, "fsload imagefs 0x%x /%s_%02d.lzma", 
 				(ulong)CONFIG_SYS_SDRAM_TEMP_BASE, image_name, apimagenum);
@@ -683,7 +684,7 @@
 	BOOT_PRINTF(UBOOT_NOTICE, "zsp image load begin...\n");
 	image_tmp_buf = CONFIG_SYS_SDRAM_TEMP_BASE;
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 	if(imagefs_flag == 1)
         sprintf(cmd, "fsload imagefs 0x%x %s", (ulong)image_tmp_buf, ZSP_IMAGE_PATH);
 	else
@@ -721,7 +722,7 @@
 
 	/*1¡¢½«ap imgÎļþloadµ½ÁÙʱµØÖ·*/
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 	if(imagefs_flag == 1)
 		sprintf(cmd, "fsload imagefs 0x%x /ap_%s.bin", 
 				(ulong)CONFIG_SYS_SDRAM_TEMP_BASE, image_name);
@@ -890,8 +891,8 @@
 }
 
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
-int load_flags(T_FOTA_FLAG_INFO *fotaFlagInfo)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
+int load_flags(T_FLAGS_INFO *fotaFlagInfo)
 {
 	int ret = 0;
 	int type = 0;
@@ -907,7 +908,7 @@
 	uint32_t work_area_offset = 0;
 	uint32_t backup_area_offset = 0;
 	uint32_t flag_one = 0;
-	uint32_t  fota_size = sizeof(T_FOTA_FLAG_INFO);
+	uint32_t  fota_size = sizeof(T_FLAGS_INFO);
 	nand_info_t *nand = &nand_info[nand_curr_device];
 	struct fsl_qspi *nor = &spi_nor_flash;
 
@@ -966,7 +967,7 @@
 			return 1;
 		}
 		
-		if(fotaFlagInfo->boot_flag.magic != FLAGS_MAGIC)
+		if(fotaFlagInfo->magic_start != FLAGS_MAGIC)
 		{	
 			flush_dcache_all();
 			ret = flash->read(nand,(loff_t)backup_area_offset,
@@ -978,7 +979,7 @@
 				return -1;
 			}
 			
-			if(fotaFlagInfo->boot_flag.magic != FLAGS_MAGIC)
+			if(fotaFlagInfo->magic_start != FLAGS_MAGIC)
 			{
 	            printf("flags magic err.\n");
 			    return -1;
@@ -996,7 +997,7 @@
 			BOOT_PRINTF(UBOOT_ERR, "[%s]: read the flags error!\n", part_name);
 			return -1;
 		}
-		if(fotaFlagInfo->boot_flag.magic != FLAGS_MAGIC)
+		if(fotaFlagInfo->magic_start != FLAGS_MAGIC)
 		{
             flush_dcache_all();
 			ret = nand_read(&(nor->nor[0].mtd), (loff_t)backup_area_offset, 
@@ -1008,7 +1009,7 @@
 				return -1;
 			}
 			
-			if(fotaFlagInfo->boot_flag.magic != FLAGS_MAGIC)
+			if(fotaFlagInfo->magic_start != FLAGS_MAGIC)
 			{
 	            printf("flags magic err.\n");
 			    return -1;
@@ -1033,7 +1034,7 @@
 {
 	char cmd[64] = {0};
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 	if(imagefs_flag == 1)
 	    sprintf(cmd, "fsload imagefs 0x%x %s", (ulong)CONFIG_SYS_SDRAM_TEMP_BASE, FOTAFLAG_PATH);
 	else
diff --git a/boot/common/src/uboot/drivers/mtd/partition/partition.c b/boot/common/src/uboot/drivers/mtd/partition/partition.c
index 80b0362..0da27ea 100755
--- a/boot/common/src/uboot/drivers/mtd/partition/partition.c
+++ b/boot/common/src/uboot/drivers/mtd/partition/partition.c
@@ -52,7 +52,7 @@
 extern partition_table_t * g_partition_table_dl;
 extern struct fsl_qspi spi_nor_flash;
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 extern int imagefs_flag;
 #endif
 
@@ -60,7 +60,7 @@
  *  add_partition_to_bootargs  :  Ôö¼Ó·ÖÇøÐÅÏ¢µ½ bootargs
  */
 // #ifdef CONFIG_ZX297520V3E_MDL_AB
- #if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+ #if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
  void add_partition_to_bootargs( void )
 {
 	int ret = 0;
@@ -192,20 +192,30 @@
 
 	if(imagefs_flag == 1)    
    	{
+#ifdef DM_VERITY
+        sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " system=system_a");
+		sprintf((char *)bootargs_cmd_cap + strlen(bootargs_cmd_cap), " system=system_a");
+#else
 		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " system=system_a");
 		sprintf((char *)bootargs_cmd_cap + strlen(bootargs_cmd_cap), " system=system_a ubi.mtd=caprootfs");
+#endif
 	}
 	else if(imagefs_flag == 2)   
 	{
+#ifdef DM_VERITY
+		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " system=system_b");
+		sprintf((char *)bootargs_cmd_cap + strlen(bootargs_cmd_cap), " system=system_b");
+#else
 		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " system=system_b");
 		sprintf((char *)bootargs_cmd_cap + strlen(bootargs_cmd_cap), " system=system_b ubi.mtd=caprootfs2");
+#endif
 	}	
 
 	/* save */
 	setenv("bootargs", (char *)bootargs_cmd);
 	setenv("bootargs_cap", (char *)bootargs_cmd_cap);
 }
- #else
+#else
 void add_partition_to_bootargs( void )
 {
 	int ret = 0;
diff --git a/boot/common/src/uboot/drivers/peripheral/Makefile b/boot/common/src/uboot/drivers/peripheral/Makefile
index 8ecd566..103b373 100755
--- a/boot/common/src/uboot/drivers/peripheral/Makefile
+++ b/boot/common/src/uboot/drivers/peripheral/Makefile
@@ -41,6 +41,7 @@
 COBJS-$(CONFIG_ZX297520V3E_UFI_MINI)	+= peripheral.o
 COBJS-$(CONFIG_ZX297520V3E_MDL_AB)	+= peripheral.o
 COBJS-$(CONFIG_ZX297520V3E_VEHICLE_DC)	+= peripheral.o
+COBJS-$(CONFIG_ZX297520V3E_VEHICLE_DC_REF)	+= peripheral.o
 
 COBJS	:= $(sort $(COBJS-y))
 SRCS	:= $(COBJS:.o=.c)
diff --git a/boot/common/src/uboot/drivers/peripheral/peripheral.c b/boot/common/src/uboot/drivers/peripheral/peripheral.c
index 4394c7b..3646130 100755
--- a/boot/common/src/uboot/drivers/peripheral/peripheral.c
+++ b/boot/common/src/uboot/drivers/peripheral/peripheral.c
@@ -25,6 +25,7 @@
 #include <linux/types.h>

 #include <zx234290.h>

 #include <led.h>

+#include <drvs_gpio.h>

 #include "common.h"

 //#include <gpio.h>

 

@@ -68,34 +69,32 @@
 

 /*lcd*/

 

-	/* jtagµ÷ÊÔ */

+	/* jtag调试 */

 #if 0

 	jtag_init();

 #endif

 

 //#if 0//ref need ldo8 2.85V

-#ifdef CONFIG_ZX297520V3E_VEHICLE_DC

+#if defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)

 /*set mmc io and vccQ*/	

 	zx234290_set_ldo8_voltage(VLDOD_1_800);

 	zx234290_set_ldo8_sleep_voltage(VLDOD_1_800);

 	zx234290_ldo8_enable(1);

 	

 	REG32(SD1_IO_1V8_EN) |=(1<<1);

-#endif

 //xf.li@20230412 add for enable GNSS start

-#if 1 //enable GNSS

 	REG32(ZX_TOP_CRM_BASE + 0x34) |= (0x1<<5);

 	zDrvGpio_SetFunc(GPIO15,GPIO15_CLK_OUT0);

-

-	zDrvGpio_SetFunc(GPIO86,GPIO86_GPIO86);

-	zDrvGpio_SetDirection(GPIO86,GPIO_OUT);

-	zDrvGpio_SetOutputValue(GPIO86,GPIO_HIGH);

+	/*关闭gps电源*/

+	zDrvGpio_SetFunc(GPIO86, GPIO86_GPIO86);

+	zDrvGpio_SetDirection(GPIO86, GPIO_OUT);

+	zDrvGpio_SetOutputValue(GPIO86, GPIO_LOW);

 

 	zDrvGpio_SetFunc(GPIO126,GPIO126_GPIO126);

 	zDrvGpio_SetDirection(GPIO126,GPIO_OUT);

 	zDrvGpio_SetOutputValue(GPIO126,GPIO_LOW);

-#endif

 //xf.li@20230412 add for enable GNSS end

+#endif

 	zx234502_charger_enable();

 

 	return ret ;

diff --git a/boot/common/src/uboot/include/configs/zx297520v3.h b/boot/common/src/uboot/include/configs/zx297520v3.h
index 6d12147..e218408 100755
--- a/boot/common/src/uboot/include/configs/zx297520v3.h
+++ b/boot/common/src/uboot/include/configs/zx297520v3.h
@@ -12,7 +12,7 @@
 /*================================================================= version ======== */
 #define CONFIG_PRINTF               1  /*uart downloader,this should be set to 0*/
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)  || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 #define VERSION_RELEASE             1
 #else
 #define VERSION_RELEASE             0
diff --git a/boot/common/src/uboot/include/partition_table.h b/boot/common/src/uboot/include/partition_table.h
index 1dd0ec5..6d27ca4 100755
--- a/boot/common/src/uboot/include/partition_table.h
+++ b/boot/common/src/uboot/include/partition_table.h
@@ -48,7 +48,7 @@
 #define ARM_RECOVERY_USERDATA_IMAGE      "recovery"
 #define ARM_UBOOT_IMAGE         "uboot"
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 #define ARM_ROOTFS_IMAGE      "rootfs"
 #define ARM_ROOTFS2_IMAGE      "rootfs2"
 #endif
@@ -260,7 +260,9 @@
 	image_bin_header_t image[50]; 
 } master_header_t;
 
-//#ifdef CONFIG_ZX297520V3E_MDL_AB
+#define FLAGS_PARTITION_ERROR          (0x1111) /*·ÖÇøÒì³£*/
+
+#if 0
 #if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
 /*
 flags partition
@@ -325,6 +327,7 @@
 	T_BOOT_ENV            boot_env;
 }T_FOTA_FLAG_INFO;
 #endif
+#endif
 
 #ifdef CREAT_PARTITION_TABLE
 partition_table_t g_partiton_table =