[Feature][T106_eSDK]update from T106-V2.01.01.02P56U06.AP.15.11_CAP.15.11.01 to T106-V2.01.01.02P56U09.AP.17.02_CAP.17.02.02 -- Uboot

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: I0d82c355a0fe633dc3ce2770f3091d496abfa89b
diff --git a/Uboot/boot/common/src/loader/lib/board.c b/Uboot/boot/common/src/loader/lib/board.c
index b72ce93..3ddc41f 100755
--- a/Uboot/boot/common/src/loader/lib/board.c
+++ b/Uboot/boot/common/src/loader/lib/board.c
@@ -146,6 +146,7 @@
 	int32_t add;
 	uint32_t amt_value = 0;
 	int32_t err_flag = 0;
+	int32_t switch_flag = 0;
     T_BOOT_TARGET bootTarget;
 	T_FLAGS flagsData;
 	T_FLAGS_INFO *fotaFlag;
@@ -267,44 +268,127 @@
         if (fotaFlag->boot_fota_flag.system.status == DUALSYSTEM_STATUS_UNBOOTABLE)
         {
             printf("dual_system status is unbootable!");
-		    goto error;
+			//goto error;
+			if(fotaFlag->boot_fota_flag.system2.status == DUALSYSTEM_STATUS_UNBOOTABLE)
+			{
+				printf("system status is both unbootable,restart system1!");
+				err_flag = 1;
+				/*ĬÈÏflags·ÖÇøÊý¾Ý*/
+				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
+			{
+				writel(DUALSYSTEM_STATUS_UNBOOTABLE, BOOT_FLAG_ADDR);
+				printf("restart system2!");
+				switch_flag = 1;
+			}
+		    
 		}
-		ret = read_uboot_image((uint8_t *)UBOOT_IMAGE, &uboot_entry_point);    
-		if( ret != 0)
-        {
-            printf("read uboot1 image error, goto uboot2!");
-			writel(DUALSYSTEM_STATUS_UNBOOTABLE, BOOT_FLAG_ADDR);		
-			ret = read_uboot_image((uint8_t *)UBOOT2_IMAGE, &uboot_entry_point);		
+
+		if(1 == switch_flag)
+		{
+			ret = read_uboot_image((uint8_t *)UBOOT2_IMAGE, &uboot_entry_point);    
 			if( ret != 0)
 	        {
-	            printf("read uboot2 iamge error!");
-				goto error;	
+	            printf("read uboot2 image error, goto uboot!");
+				writel(DUALSYSTEM_STATUS_UNBOOTABLE, BOOT_FLAG_ADDR);		
+				ret = read_uboot_image((uint8_t *)UBOOT_IMAGE, &uboot_entry_point);		
+				if( ret != 0)
+		        {
+		            printf("read uboot image error!");
+					goto error;	
+				}
 			}
+			else	
+			    printf("goto uboot2!");		
 		}
-		else	
-		    printf("goto uboot!");
+		else
+		{
+			ret = read_uboot_image((uint8_t *)UBOOT_IMAGE, &uboot_entry_point);    
+			if( ret != 0)
+	        {
+	            printf("read uboot1 image error, goto uboot2!");
+				writel(DUALSYSTEM_STATUS_UNBOOTABLE, BOOT_FLAG_ADDR);		
+				ret = read_uboot_image((uint8_t *)UBOOT2_IMAGE, &uboot_entry_point);		
+				if( ret != 0)
+		        {
+		            printf("read uboot2 image error!");
+					goto error;	
+				}
+			}
+			else	
+			    printf("goto uboot!");
+		}
+		
 	}
     else if(bootTarget == DUAL_SYSTEM2)
     {
         if (fotaFlag->boot_fota_flag.system2.status == DUALSYSTEM_STATUS_UNBOOTABLE)
         {
             printf("dual_system2 status is unbootable!");
-		    goto error;
-		}
-		ret = read_uboot_image((uint8_t *)UBOOT2_IMAGE, &uboot_entry_point);		
-		if( ret != 0)
-        {
-            printf("read uboot2 iamge error, goto uboot!");
-			writel(DUALSYSTEM_STATUS_UNBOOTABLE, BOOT_FLAG_ADDR);	
-			ret = read_uboot_image((uint8_t *)UBOOT_IMAGE, &uboot_entry_point);		
-			if( ret != 0)
-	        {
-	            printf("read uboot iamge error!");
-				goto error;	
+		    //goto error;
+			if(fotaFlag->boot_fota_flag.system.status == DUALSYSTEM_STATUS_UNBOOTABLE)
+			{
+				printf("system status is both unbootable,restart system2!");
+				err_flag = 1;
+				/*ĬÈÏflags·ÖÇøÊý¾Ý*/
+				flagsData.magic_start = FLAGS_MAGIC;
+				flagsData.boot_fota_flag.boot_to = DUAL_SYSTEM2;
+				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
+			{
+				writel(DUALSYSTEM_STATUS_UNBOOTABLE, BOOT_FLAG_ADDR);
+				printf("restart system1!");
+				switch_flag = 1;
 			}
 		}
+		
+		if(1 == switch_flag)
+		{
+			ret = read_uboot_image((uint8_t *)UBOOT_IMAGE, &uboot_entry_point);    
+			if( ret != 0)
+	        {
+	            printf("read uboot image error, goto uboot2!");
+				writel(DUALSYSTEM_STATUS_UNBOOTABLE, BOOT_FLAG_ADDR);		
+				ret = read_uboot_image((uint8_t *)UBOOT2_IMAGE, &uboot_entry_point);		
+				if( ret != 0)
+		        {
+		            printf("read uboot2 image error!");
+					goto error;	
+				}
+			}
+			else	
+			    printf("goto uboot!");		
+		}
 		else
-		    printf("goto uboot2!");
+		{
+			ret = read_uboot_image((uint8_t *)UBOOT2_IMAGE, &uboot_entry_point);		
+			if( ret != 0)
+	        {
+	            printf("read uboot2 image error, goto uboot!");
+				writel(DUALSYSTEM_STATUS_UNBOOTABLE, BOOT_FLAG_ADDR);	
+				ret = read_uboot_image((uint8_t *)UBOOT_IMAGE, &uboot_entry_point);		
+				if( ret != 0)
+		        {
+		            printf("read uboot image error!");
+					goto error;	
+				}
+			}
+			else
+			    printf("goto uboot2!");
+		}
+		
 	}
 	else
 	{
diff --git a/Uboot/boot/common/src/uboot/arch/arm/lib/Makefile b/Uboot/boot/common/src/uboot/arch/arm/lib/Makefile
index b5625a6..c35e97e 100755
--- a/Uboot/boot/common/src/uboot/arch/arm/lib/Makefile
+++ b/Uboot/boot/common/src/uboot/arch/arm/lib/Makefile
@@ -49,9 +49,9 @@
 SOBJS-$(CONFIG_USE_ARCH_MEMCPY) += memcpy.o
 endif
 #xf.li@2023.04.14 modify for ZXW-25 start
-LYNQ_CONFIG_VERSION = "T106-W-V2.01.01.02P56U06.AP.15.05_CAP.15.05"
+LYNQ_CONFIG_VERSION = "T106-V2.01.01.02P56U09.AP.17.02_CAP.17.02.02"
 CFLAGS += -DLYNQ_VERSION=\"$(LYNQ_CONFIG_VERSION)\"
-LYNQ_CONFIG_COMMITID = "c33b177c8b861ee957b6c8b0dea003278a3671d6"
+LYNQ_CONFIG_COMMITID = "9aea88bb79cfb2fae9ddab87f8307126d618aec2"
 CFLAGS += -DLYNQ_COMMITID=\"$(LYNQ_CONFIG_COMMITID)\"
 #xf.li@2023.04.14 modify for ZXW-25 end
 SRCS	:= $(GLSOBJS:.o=.S) $(GLCOBJS:.o=.c) \
diff --git a/Uboot/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_mdl_ab.c b/Uboot/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_mdl_ab.c
index bf9a900..78f48a4 100755
--- a/Uboot/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_mdl_ab.c
+++ b/Uboot/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_mdl_ab.c
@@ -635,6 +635,7 @@
 		ret = rewrite_flags();
 		if(ret != 0)
 			return -1;
+		system_reset();
 		return 0;
 #endif
 	}
diff --git a/Uboot/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_vehicle_dc.c b/Uboot/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_vehicle_dc.c
index 2f9dde8..d538891 100755
--- a/Uboot/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_vehicle_dc.c
+++ b/Uboot/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_vehicle_dc.c
@@ -636,6 +636,7 @@
 		ret = rewrite_flags();
 		if(ret != 0)
 			return -1;
+		system_reset();
 		return 0;
 #endif
 	}
diff --git a/Uboot/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_vehicle_dc_ref.c b/Uboot/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_vehicle_dc_ref.c
index 7703ad0..8e767d2 100755
--- a/Uboot/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_vehicle_dc_ref.c
+++ b/Uboot/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_vehicle_dc_ref.c
@@ -638,6 +638,7 @@
 		ret = rewrite_flags();
 		if(ret != 0)
 			return -1;
+		system_reset();
 		return 0;
 #endif
 	}
diff --git a/Uboot/boot/common/src/uboot/downloader/cmd_compat_write.c b/Uboot/boot/common/src/uboot/downloader/cmd_compat_write.c
index 4d5e339..4d6ae9d 100755
--- a/Uboot/boot/common/src/uboot/downloader/cmd_compat_write.c
+++ b/Uboot/boot/common/src/uboot/downloader/cmd_compat_write.c
@@ -34,9 +34,10 @@
 /****************************************************************************
 *							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}};
+//T_IMG_SIZE img_size[IMG_NUM] = {{"uboot",0,0},{"imagefs",0,0},{"rootfs",0,0},{"caprootfs",0,0},{"oem",0,0}};
+T_IMG_SIZE img_size[IMG_NUM_MAX];
+int img_num = 0;
 int flags_partiton_write = 0;
-
 extern int g_iftype;
 extern partition_table_t * g_partition_table_dl;
 /*******************************************************************************
@@ -56,11 +57,14 @@
 {
     partition_entry_t *part = NULL;
     char *par = NULL;
+	char *par_tmp = NULL;
     char ack[64]={0};
 	unsigned int offset = 0;
 	unsigned int size = 0;
 	unsigned int ret = 0;
 	unsigned int i = 0;
+	unsigned int len = 0;
+	unsigned int found = 0;
 	flags_partiton_write = 1;
 	
 	if(argc<4)
@@ -80,23 +84,55 @@
 	}
 
 	/*record image size*/
-	for(i=0; i<IMG_NUM; i++)
+	len = strlen(par);
+/* Started by AICoder, pid:q5743g3f62rd9291419e086de0327502c5d710ce */
+	par_tmp = (char *)malloc(len + 1);
+	if (par[len - 1] == '2') {
+		strncpy(par_tmp, par, len - 1);
+		par_tmp[len - 1] = '\0';
+	} else {
+		strcpy(par_tmp, par);
+	}
+/* Ended by AICoder, pid:q5743g3f62rd9291419e086de0327502c5d710ce */
+	
+/* Started by AICoder, pid:ye4dcm700en8c6e14cdf0ac390813e36dc075765 */
+	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(strcmp((char *)img_size[i].name, par_tmp) == 0 && strlen((char *)img_size[i].name) == strlen(par_tmp))
+	    {
+	        found = 1;
+	        if(strcmp(par_tmp,par) == 0)
+	        {
+	            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);
+	        }
+	        
+	        break;
+	    }
 	}  
+	if (!found)
+	{   
+	    strcpy(img_size[img_num].name,par_tmp);
+	    if(strcmp(par_tmp,par) == 0)
+	    {
+	        img_size[img_num].size_a = size;
+	        printf("partition is %s,size_a is 0x%x.\n",par,size);
+	    }
+	    else
+	    {
+	        img_size[img_num].size_b = size;
+	        printf("partition is %s,size_b is 0x%x.\n",par,size);
+	    }
+	    
+	    img_num += 1;
+	}
+	free(par_tmp);
+/* Ended by AICoder, pid:ye4dcm700en8c6e14cdf0ac390813e36dc075765 */
 	
 #if defined (CONFIG_ZX297520V3E_VEHICLE_DC) || defined (CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 	if(g_nor_flag == 1)
diff --git a/Uboot/boot/common/src/uboot/include/partition_table.h b/Uboot/boot/common/src/uboot/include/partition_table.h
index 306a64c..febd365 100755
--- a/Uboot/boot/common/src/uboot/include/partition_table.h
+++ b/Uboot/boot/common/src/uboot/include/partition_table.h
@@ -211,7 +211,7 @@
 #define PARTITION_CRC               0x12345678
 #define PARTITION_SIZE              0X1000                  /* ·ÖÇø±íµÄ´óС */
 
-#define IMG_NUM  5
+#define IMG_NUM  15
 
 typedef struct partition_entry {
     unsigned char	part_name[16];