[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/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;