[Feature][ZXW-241]merge P56U01 version

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

Change-Id: I7985538dde6951dd824c36149bf9a1e3ca23c734
diff --git a/boot/common/src/uboot/downloader/cmd_compat_write.c b/boot/common/src/uboot/downloader/cmd_compat_write.c
index f4db84f..6b4c462 100755
--- a/boot/common/src/uboot/downloader/cmd_compat_write.c
+++ b/boot/common/src/uboot/downloader/cmd_compat_write.c
@@ -29,9 +29,14 @@
 #include "downloader_serial.h"
 #include "errno.h"
 #include <boot_mode.h>
+#include "pub_flags.h"
+
 /****************************************************************************
 *							Global Function Prototypes
 ****************************************************************************/
+T_IMG_SIZE img_size[IMG_NUM] = {{"uboot",0,0},{"imagefs",0,0},{"rootfs",0,0},{"caprootfs",0,0},{"oem",0,0}};
+int flags_partiton_write = 0;
+
 extern int g_iftype;
 extern partition_table_t * g_partition_table_dl;
 /*******************************************************************************
@@ -55,6 +60,8 @@
 	unsigned int offset = 0;
 	unsigned int size = 0;
 	unsigned int ret = 0;
+	unsigned int i = 0;
+	flags_partiton_write = 1;
 	
 	if(argc<4)
     {
@@ -71,6 +78,25 @@
         downloader_serial_write(ack, strlen(ack)+1);
 	    return -1;
 	}
+
+	/*record image size*/
+	for(i=0; i<IMG_NUM; i++)
+	{
+		if(memcmp((char *)img_size[i].name , par, strlen(img_size[i].name)) == 0){
+			if(!memcmp(par,"oemdata",7))
+				break;
+			if(strlen(img_size[i].name) == strlen(par))
+			{
+				img_size[i].size_a = size;
+				printf("partition is %s,size_a is 0x%x.\n",par,size);
+			}
+			else
+			{
+				img_size[i].size_b = size;
+				printf("partition is %s,size_b is 0x%x.\n",par,size);
+			}
+		}
+	}  
 	
 #if defined (CONFIG_ZX297520V3E_VEHICLE_DC) || defined (CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 	if(g_nor_flag == 1)
diff --git a/boot/common/src/uboot/downloader/cmd_cp_reset.c b/boot/common/src/uboot/downloader/cmd_cp_reset.c
old mode 100644
new mode 100755
index fc75ad8..a521b9b
--- a/boot/common/src/uboot/downloader/cmd_cp_reset.c
+++ b/boot/common/src/uboot/downloader/cmd_cp_reset.c
@@ -35,6 +35,7 @@
 
 extern int downloader_serial_write(const char * buffer,unsigned int len);
 extern char *tsp_console_buffer;
+extern int flags_partiton_write;
 
 /*******************************************************************************
  * Function:do_reboot
@@ -53,7 +54,14 @@
 {
     char *ack = tsp_console_buffer;
     uint32_t reg_start = 0;
-		
+	
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)	
+	/*ÅжÏÊÇ·ñ»ØÐ´flags·ÖÇø*/
+	if(1 == flags_partiton_write){
+        write_flags_partition();
+	}
+#endif	
+
     if(argc < 1)
     {
         return cmd_usage(cmdtp);
diff --git a/boot/common/src/uboot/downloader/cmd_set.c b/boot/common/src/uboot/downloader/cmd_set.c
index 8831694..93950b1 100755
--- a/boot/common/src/uboot/downloader/cmd_set.c
+++ b/boot/common/src/uboot/downloader/cmd_set.c
@@ -33,7 +33,7 @@
 #include "boot_mode.h"

 

 

-#define ZLOAD_PARTITION_SIZE	0x3000

+#define ZLOAD_PARTITION_SIZE	0x10000

 

 

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

@@ -47,7 +47,7 @@
 

 extern char *tsp_console_buffer;

 extern struct fsl_qspi spi_nor_flash;

-

+extern int g_iftype;

 

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

  * Function:do_set

@@ -408,22 +408,37 @@
         return cmd_usage(cmdtp);

     }

 	sign = argv[1];	

-	type = read_boot_flashtype();

 

-	if(type == IF_TYPE_NAND || type == IF_TYPE_SPI_NAND)

+	if(g_nor_flag == 1)

 	{

-        ret = set_nand_dlflag(sign);

-	}

-	else if(type == IF_TYPE_NOR)

-	{

+	    g_iftype = IF_TYPE_NOR;

+		nand_init();

 		ret = set_nor_dlflag(sign);

+		/*Çл»³õʼ»¯spi_nand*/

+		g_iftype = IF_TYPE_SPI_NAND;

+		nand_init();

+

+	}

+	else

+	{

+	    type = read_boot_flashtype();

+

+		if(type == IF_TYPE_NAND || type == IF_TYPE_SPI_NAND)

+		{

+	        ret = set_nand_dlflag(sign);

+		}

+		else if(type == IF_TYPE_NOR)

+		{

+			ret = set_nor_dlflag(sign);

+		}

+		

 	}

 

 	if(ret != 0)

 	{

 		return -1;

 	}

-		

+	

 	return 0;

 

 }