[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/loader/drivers/flash.h b/boot/common/src/loader/drivers/flash.h
index 2fe2ddb..4a8088e 100755
--- a/boot/common/src/loader/drivers/flash.h
+++ b/boot/common/src/loader/drivers/flash.h
@@ -20,6 +20,7 @@
#define _FLASH_H_
#include <linux/types.h>
+#include "pub_flags.h"
#define NOR_BOOT 0x0
#define NAND_BOOT 0x1
@@ -41,6 +42,20 @@
void (*read_oob)(uint8_t *buf, uint32_t offset, uint32_t len);
};
+typedef struct
+{
+ unsigned int magic_start; /* Êý¾ÝÓÐЧÐÔħÊõ×Ö */
+
+ T_BOOT_FOTA_FLAG boot_fota_flag;
+ T_BOOT_ENV boot_env;
+ T_UBIFS_STATUS ubifs_status;
+ unsigned int nvro_flag;
+ unsigned int crc32;
+ T_BOOT_TARGET ota_system; /* Éý¼¶Ê±ÊÇϵͳA»¹ÊÇϵͳB */
+ T_AA_PARTITION_INFO ota_partiton_info[OTA_PARTITION_NUM_MAX]; /* ÈÝÄÉ×î¶à15¸öÉý¼¶·ÖÇøµÄimage¾µÏñ´óС */
+ char reserve[52];
+ unsigned int magic_end; /* Êý¾ÝÓÐЧÐÔħÊõ×Ö */
+} T_FLAGS;
extern struct flash_type flash;
diff --git a/boot/common/src/loader/lib/board.c b/boot/common/src/loader/lib/board.c
index f6651cb..b72ce93 100755
--- a/boot/common/src/loader/lib/board.c
+++ b/boot/common/src/loader/lib/board.c
@@ -147,7 +147,7 @@
uint32_t amt_value = 0;
int32_t err_flag = 0;
T_BOOT_TARGET bootTarget;
- T_FLAGS_INFO flagsData;
+ T_FLAGS flagsData;
T_FLAGS_INFO *fotaFlag;
T_BOOT_DUALSYSTEM_TYPE dualSystemType;
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 8b0e1ae..50140b7 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
@@ -81,6 +81,7 @@
extern uint32_t g_gmac_init_flag;
extern uint32_t g_gmac_init_overtime;
extern unsigned char g_ddr_size_flag;
+extern T_IMG_SIZE img_size[IMG_NUM];
unsigned int g_uiDebugLevel = UBOOT_NOTICE;
unsigned int g_sys_kernel_sdram_size = CONFIG_SYS_SDRAM32_A9_SIZE;
@@ -492,44 +493,42 @@
return offset;
}
-int rewrite_flags(void)
+int write_flags_partition(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);
- unsigned long crc = 0;
- u32 crc_size = sizeof(T_FLAGS_INFO);
- 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 )
+ /*¶ÁÈ¡flags·ÖÇø*/
+ ret = load_flags(&fotaFlagInfo);
+ if(ret != 0)
{
- BOOT_PRINTF(UBOOT_ERR, "[%s]: can't find the partition...\n", flags_name);
+ printf("read flags partition err.\n");
return -1;
}
- /* »ñµÃ·ÖÇøÊ×µØÖ·ºÍ´óС */
- part_offset = entry->part_offset;
- flags_size = entry->part_size;
+
+ /*д»Øflags·ÖÇø*/
+ fotaFlagInfo.ota_system = 0;
+ fotaFlagInfo.sync_system = 0;
+ //memset(fotaFlagInfo.img_size, 0, sizeof(fotaFlagInfo) - 512);
+ memcpy(fotaFlagInfo.img_size, img_size, sizeof(img_size));
+
+ ret = write_flags(&fotaFlagInfo);
+ if(ret != 0)
+ {
+ printf("write flags partition err.\n");
+ return -1;
+ }
+
+ printf("already write flags partition!\n");
+ //system_reset();
+
+ return 0;
+}
+
+int rewrite_flags(void)
+{
+ int ret = 0;
+ T_FLAGS_INFO fotaFlagInfo = {0};
/*ÉèÖÃĬÈÏflags·ÖÇøÊý¾Ý*/
fotaFlagInfo.magic_start = FLAGS_MAGIC;
@@ -539,151 +538,27 @@
fotaFlagInfo.boot_fota_flag.system2.status = DUALSYSTEM_STATUS_BOOTABLE;
fotaFlagInfo.boot_env.dualsys_type = DUALSYSTEM_AB;
fotaFlagInfo.magic_end = FLAGS_MAGIC;
- /*crc32*/
- fotaFlagInfo.crc32 = 0;
- crc32init_le();
- crc = crc32_le(0,(unsigned char*)(&fotaFlagInfo),crc_size);
- fotaFlagInfo.crc32 = crc;
- /*дÈëflags·ÖÇø*/
- if(type == IF_TYPE_NAND || type == IF_TYPE_SPI_NAND)
+ /*д»Øflags·ÖÇø*/
+
+ ret = write_flags(&fotaFlagInfo);
+ if(ret != 0)
{
-
- /*È·¶¨¹¤×÷ÇøºÍ±¸·ÝÇøÆ«ÒÆµØÖ·*/
- 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("rewrite flags partition err.\n");
+ return -1;
}
- printf("flags partition data is error,already rewrite default parameters!\n");
- //system_reset();
+ printf("already rewrite flags partition!\n");
- 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();
-
- unsigned long crc = 0;
- u32 crc_size = sizeof(T_FLAGS_INFO);
-
- /* ѰÕÒ·ÖÇø */
- 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);
@@ -699,210 +574,33 @@
fotaFlagInfo.boot_fota_flag.boot_to = DUAL_SYSTEM2;
fotaFlagInfo.boot_fota_flag.system = system_status;
fotaFlagInfo.boot_fota_flag.fota_status = 1;
- /*crc32*/
- fotaFlagInfo.crc32 = 0;
- crc32init_le();
- crc = crc32_le(0,(unsigned char*)(&fotaFlagInfo),crc_size);
- fotaFlagInfo.crc32 = crc;
- if(type == IF_TYPE_NAND || type == IF_TYPE_SPI_NAND)
+ ret = write_flags(&fotaFlagInfo);
+ if(ret != 0)
{
-
- /*È·¶¨¹¤×÷ÇøºÍ±¸·ÝÇøÆ«ÒÆµØÖ·*/
- 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);
+ printf("writeback flags partition err.\n");
+ return -1;
+ }
- 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;
fotaFlagInfo.boot_fota_flag.fota_status = 1;
- /*crc32*/
- fotaFlagInfo.crc32 = 0;
- crc32init_le();
- crc = crc32_le(0,(unsigned char*)(&fotaFlagInfo),crc_size);
- fotaFlagInfo.crc32 = crc;
- if(type == IF_TYPE_NAND || type == IF_TYPE_SPI_NAND)
+ ret = write_flags(&fotaFlagInfo);
+ if(ret != 0)
{
- /*È·¶¨¹¤×÷ÇøºÍ±¸·ÝÇøÆ«ÒÆµØÖ·*/
- 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;
- }
+ printf("writeback flags partition err.\n");
+ 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;
}
@@ -935,6 +633,7 @@
static int read_imagefs_flag(void)
{
int ret = 0;
+ char name[IMG_NAME_LEN];
/* ¶ÁÈ¡flags·ÖÇø */
T_FLAGS_INFO fotaFlagInfo;
ret = load_flags(&fotaFlagInfo);
@@ -943,6 +642,12 @@
printf("read flags partition err.\n");
return -1;
}
+
+ memset(name, 0xff, IMG_NAME_LEN);
+ if(!memcmp(fotaFlagInfo.img_size[0].name, name, IMG_NAME_LEN)){
+ printf("update the image size...\n");
+ write_flags(&fotaFlagInfo);
+ }
if(fotaFlagInfo.boot_fota_flag.boot_to == DUAL_SYSTEM)
{
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 23bf246..bc89988 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
@@ -81,6 +81,7 @@
extern uint32_t g_gmac_init_flag;
extern uint32_t g_gmac_init_overtime;
extern unsigned char g_ddr_size_flag;
+extern T_IMG_SIZE img_size[IMG_NUM];
unsigned int g_uiDebugLevel = UBOOT_NOTICE;
unsigned int g_sys_kernel_sdram_size = CONFIG_SYS_SDRAM32_A9_SIZE;
@@ -493,44 +494,42 @@
return offset;
}
-int rewrite_flags(void)
+int write_flags_partition(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);
- unsigned long crc = 0;
- u32 crc_size = sizeof(T_FLAGS_INFO);
- 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 )
+ /*¶ÁÈ¡flags·ÖÇø*/
+ ret = load_flags(&fotaFlagInfo);
+ if(ret != 0)
{
- BOOT_PRINTF(UBOOT_ERR, "[%s]: can't find the partition...\n", flags_name);
+ printf("read flags partition err.\n");
return -1;
}
- /* »ñµÃ·ÖÇøÊ×µØÖ·ºÍ´óС */
- part_offset = entry->part_offset;
- flags_size = entry->part_size;
+
+ /*д»Øflags·ÖÇø*/
+ fotaFlagInfo.ota_system = 0;
+ fotaFlagInfo.sync_system = 0;
+ //memset(fotaFlagInfo.img_size, 0, sizeof(fotaFlagInfo) - 512);
+ memcpy(fotaFlagInfo.img_size, img_size, sizeof(img_size));
+
+ ret = write_flags(&fotaFlagInfo);
+ if(ret != 0)
+ {
+ printf("write flags partition err.\n");
+ return -1;
+ }
+
+ printf("already write flags partition!\n");
+ //system_reset();
+
+ return 0;
+}
+
+int rewrite_flags(void)
+{
+ int ret = 0;
+ T_FLAGS_INFO fotaFlagInfo = {0};
/*ÉèÖÃĬÈÏflags·ÖÇøÊý¾Ý*/
fotaFlagInfo.magic_start = FLAGS_MAGIC;
@@ -540,151 +539,27 @@
fotaFlagInfo.boot_fota_flag.system2.status = DUALSYSTEM_STATUS_BOOTABLE;
fotaFlagInfo.boot_env.dualsys_type = DUALSYSTEM_AB;
fotaFlagInfo.magic_end = FLAGS_MAGIC;
- /*crc32*/
- fotaFlagInfo.crc32 = 0;
- crc32init_le();
- crc = crc32_le(0,(unsigned char*)(&fotaFlagInfo),crc_size);
- fotaFlagInfo.crc32 = crc;
- /*дÈëflags·ÖÇø*/
- if(type == IF_TYPE_NAND || type == IF_TYPE_SPI_NAND)
+ /*д»Øflags·ÖÇø*/
+
+ ret = write_flags(&fotaFlagInfo);
+ if(ret != 0)
{
-
- /*È·¶¨¹¤×÷ÇøºÍ±¸·ÝÇøÆ«ÒÆµØÖ·*/
- 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("rewrite flags partition err.\n");
+ return -1;
}
- printf("flags partition data is error,already rewrite default parameters!\n");
- //system_reset();
+ printf("already rewrite flags partition!\n");
- 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();
-
- unsigned long crc = 0;
- u32 crc_size = sizeof(T_FLAGS_INFO);
-
- /* ѰÕÒ·ÖÇø */
- 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);
@@ -700,210 +575,33 @@
fotaFlagInfo.boot_fota_flag.boot_to = DUAL_SYSTEM2;
fotaFlagInfo.boot_fota_flag.system = system_status;
fotaFlagInfo.boot_fota_flag.fota_status = 1;
- /*crc32*/
- fotaFlagInfo.crc32 = 0;
- crc32init_le();
- crc = crc32_le(0,(unsigned char*)(&fotaFlagInfo),crc_size);
- fotaFlagInfo.crc32 = crc;
- if(type == IF_TYPE_NAND || type == IF_TYPE_SPI_NAND)
+ ret = write_flags(&fotaFlagInfo);
+ if(ret != 0)
{
-
- /*È·¶¨¹¤×÷ÇøºÍ±¸·ÝÇøÆ«ÒÆµØÖ·*/
- 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);
+ printf("writeback flags partition err.\n");
+ return -1;
+ }
- 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;
fotaFlagInfo.boot_fota_flag.fota_status = 1;
- /*crc32*/
- fotaFlagInfo.crc32 = 0;
- crc32init_le();
- crc = crc32_le(0,(unsigned char*)(&fotaFlagInfo),crc_size);
- fotaFlagInfo.crc32 = crc;
- if(type == IF_TYPE_NAND || type == IF_TYPE_SPI_NAND)
+ ret = write_flags(&fotaFlagInfo);
+ if(ret != 0)
{
- /*È·¶¨¹¤×÷ÇøºÍ±¸·ÝÇøÆ«ÒÆµØÖ·*/
- 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;
- }
+ printf("writeback flags partition err.\n");
+ 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;
}
@@ -936,6 +634,7 @@
static int read_imagefs_flag(void)
{
int ret = 0;
+ char name[IMG_NAME_LEN];
/* ¶ÁÈ¡flags·ÖÇø */
T_FLAGS_INFO fotaFlagInfo;
ret = load_flags(&fotaFlagInfo);
@@ -944,6 +643,12 @@
printf("read flags partition err.\n");
return -1;
}
+
+ memset(name, 0xff, IMG_NAME_LEN);
+ if(!memcmp(fotaFlagInfo.img_size[0].name, name, IMG_NAME_LEN)){
+ printf("update the image size...\n");
+ write_flags(&fotaFlagInfo);
+ }
if(fotaFlagInfo.boot_fota_flag.boot_to == DUAL_SYSTEM)
{
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
index 0872ca4..10c8b7b 100755
--- 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
@@ -81,6 +81,7 @@
extern uint32_t g_gmac_init_flag;
extern uint32_t g_gmac_init_overtime;
extern unsigned char g_ddr_size_flag;
+extern T_IMG_SIZE img_size[IMG_NUM];
unsigned int g_uiDebugLevel = UBOOT_NOTICE;
unsigned int g_sys_kernel_sdram_size = CONFIG_SYS_SDRAM32_A9_SIZE;
@@ -493,44 +494,42 @@
return offset;
}
-int rewrite_flags(void)
+int write_flags_partition(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);
- unsigned long crc = 0;
- u32 crc_size = sizeof(T_FLAGS_INFO);
- 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 )
+ /*¶ÁÈ¡flags·ÖÇø*/
+ ret = load_flags(&fotaFlagInfo);
+ if(ret != 0)
{
- BOOT_PRINTF(UBOOT_ERR, "[%s]: can't find the partition...\n", flags_name);
+ printf("read flags partition err.\n");
return -1;
}
- /* »ñµÃ·ÖÇøÊ×µØÖ·ºÍ´óС */
- part_offset = entry->part_offset;
- flags_size = entry->part_size;
+
+ /*д»Øflags·ÖÇø*/
+ fotaFlagInfo.ota_system = 0;
+ fotaFlagInfo.sync_system = 0;
+ //memset(fotaFlagInfo.img_size, 0, sizeof(fotaFlagInfo) - 512);
+ memcpy(fotaFlagInfo.img_size, img_size, sizeof(img_size));
+
+ ret = write_flags(&fotaFlagInfo);
+ if(ret != 0)
+ {
+ printf("write flags partition err.\n");
+ return -1;
+ }
+
+ printf("already write flags partition!\n");
+ //system_reset();
+
+ return 0;
+}
+
+int rewrite_flags(void)
+{
+ int ret = 0;
+ T_FLAGS_INFO fotaFlagInfo = {0};
/*ÉèÖÃĬÈÏflags·ÖÇøÊý¾Ý*/
fotaFlagInfo.magic_start = FLAGS_MAGIC;
@@ -540,151 +539,27 @@
fotaFlagInfo.boot_fota_flag.system2.status = DUALSYSTEM_STATUS_BOOTABLE;
fotaFlagInfo.boot_env.dualsys_type = DUALSYSTEM_AB;
fotaFlagInfo.magic_end = FLAGS_MAGIC;
- /*crc32*/
- fotaFlagInfo.crc32 = 0;
- crc32init_le();
- crc = crc32_le(0,(unsigned char*)(&fotaFlagInfo),crc_size);
- fotaFlagInfo.crc32 = crc;
- /*дÈëflags·ÖÇø*/
- if(type == IF_TYPE_NAND || type == IF_TYPE_SPI_NAND)
+ /*д»Øflags·ÖÇø*/
+
+ ret = write_flags(&fotaFlagInfo);
+ if(ret != 0)
{
-
- /*È·¶¨¹¤×÷ÇøºÍ±¸·ÝÇøÆ«ÒÆµØÖ·*/
- 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("rewrite flags partition err.\n");
+ return -1;
}
- printf("flags partition data is error,already rewrite default parameters!\n");
- //system_reset();
+ printf("already rewrite flags partition!\n");
- 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();
-
- unsigned long crc = 0;
- u32 crc_size = sizeof(T_FLAGS_INFO);
-
- /* ѰÕÒ·ÖÇø */
- 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);
@@ -700,210 +575,33 @@
fotaFlagInfo.boot_fota_flag.boot_to = DUAL_SYSTEM2;
fotaFlagInfo.boot_fota_flag.system = system_status;
fotaFlagInfo.boot_fota_flag.fota_status = 1;
- /*crc32*/
- fotaFlagInfo.crc32 = 0;
- crc32init_le();
- crc = crc32_le(0,(unsigned char*)(&fotaFlagInfo),crc_size);
- fotaFlagInfo.crc32 = crc;
- if(type == IF_TYPE_NAND || type == IF_TYPE_SPI_NAND)
+ ret = write_flags(&fotaFlagInfo);
+ if(ret != 0)
{
-
- /*È·¶¨¹¤×÷ÇøºÍ±¸·ÝÇøÆ«ÒÆµØÖ·*/
- 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);
+ printf("writeback flags partition err.\n");
+ return -1;
+ }
- 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;
fotaFlagInfo.boot_fota_flag.fota_status = 1;
- /*crc32*/
- fotaFlagInfo.crc32 = 0;
- crc32init_le();
- crc = crc32_le(0,(unsigned char*)(&fotaFlagInfo),crc_size);
- fotaFlagInfo.crc32 = crc;
- if(type == IF_TYPE_NAND || type == IF_TYPE_SPI_NAND)
+ ret = write_flags(&fotaFlagInfo);
+ if(ret != 0)
{
- /*È·¶¨¹¤×÷ÇøºÍ±¸·ÝÇøÆ«ÒÆµØÖ·*/
- 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;
- }
+ printf("writeback flags partition err.\n");
+ 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;
}
@@ -936,6 +634,7 @@
static int read_imagefs_flag(void)
{
int ret = 0;
+ char name[IMG_NAME_LEN];
/* ¶ÁÈ¡flags·ÖÇø */
T_FLAGS_INFO fotaFlagInfo;
ret = load_flags(&fotaFlagInfo);
@@ -944,6 +643,12 @@
printf("read flags partition err.\n");
return -1;
}
+
+ memset(name, 0xff, IMG_NAME_LEN);
+ if(!memcmp(fotaFlagInfo.img_size[0].name, name, IMG_NAME_LEN)){
+ printf("update the image size...\n");
+ write_flags(&fotaFlagInfo);
+ }
if(fotaFlagInfo.boot_fota_flag.boot_to == DUAL_SYSTEM)
{
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;
}
diff --git a/boot/common/src/uboot/drivers/misc/load.c b/boot/common/src/uboot/drivers/misc/load.c
index 5c3a2b3..827201d 100755
--- a/boot/common/src/uboot/drivers/misc/load.c
+++ b/boot/common/src/uboot/drivers/misc/load.c
@@ -1228,9 +1228,11 @@
unsigned long crc = 0;
unsigned long crc_cal = 0;
u32 crc_size = sizeof(T_FLAGS_INFO);
+ char name[IMG_NAME_LEN];
flush_dcache_all();
- flash_dmabuf_disable_flag = 1;
+ //flash_dmabuf_disable_flag = 1;
+
flash = get_flash_ops();
type = read_boot_flashtype();
@@ -1246,53 +1248,57 @@
part_offset = entry->part_offset;
part_size = entry->part_size;
//while(flag);
- if(type == IF_TYPE_NAND || type == IF_TYPE_SPI_NAND)
+
+ /*È·¶¨¹¤×÷ÇøºÍ±¸·ÝÇøÆ«ÒÆµØÖ·*/
+ for (off = part_offset; off < part_offset+part_size; off += nand->erasesize)
{
- /*È·¶¨¹¤×÷ÇøºÍ±¸·ÝÇøÆ«ÒÆµØÖ·*/
- for (off = part_offset; off < part_offset+part_size; off += nand->erasesize)
+ if (!(nand_block_isbad(nand,off)))
{
- if (!(nand_block_isbad(nand,off)))
- {
- blockNum += 1;
- }
+ blockNum += 1;
+ }
+
+ if((blockNum == 1) && (flag_one == 0))
+ {
+ work_area_offset = off;
+ flag_one = 1;
+ }
- if((blockNum == 1) && (flag_one == 0))
- {
- work_area_offset = off;
- flag_one = 1;
- }
+ else if(blockNum == 2)
+ {
+ backup_area_offset = off;
+ break;
+ }
+ }
+
+ if(blockNum < 2)
+ {
+ printf("flags partition have not enough space!\n");
- else if(blockNum == 2)
- {
- backup_area_offset = off;
- break;
- }
- }
+ return -1;
+ }
+
+ ret = flash->read(nand,(loff_t)work_area_offset,
+ &fota_size,(u_char *)(fotaFlagInfo));
+ if( ret != 0 )
+ {
+ BOOT_PRINTF(UBOOT_ERR, "[%s]: read the flags error!\n", part_name);
+ return 1;
+ }
- if(blockNum < 2)
- {
- printf("flags partition have not enough space!\n");
-
- return -1;
- }
-
- ret = flash->read(nand,(loff_t)work_area_offset,
- &fota_size,(u_char *)(fotaFlagInfo));
- if( ret != 0 )
- {
- BOOT_PRINTF(UBOOT_ERR, "[%s]: read the flags error!\n", part_name);
- return 1;
- }
+ /*crc32УÑé*/
+ crc = fotaFlagInfo->crc32_1;
+ fotaFlagInfo->crc32_1 = 0;
+ crc32init_le();
+ crc_cal = crc32_le(0,(unsigned char*)fotaFlagInfo,crc_size);
+ printf("crc is 0x%x,crc_cal is 0x%x\n",crc,crc_cal);
+ //printf("work_area_offset is 0x%x,backup_area_offset is 0x%x,crc_size is 0x%x\n",work_area_offset,backup_area_offset,crc_size);
- /*crc32УÑé*/
- crc = fotaFlagInfo->crc32;
- fotaFlagInfo->crc32 = 0;
- crc32init_le();
- crc_cal = crc32_le(0,(unsigned char*)fotaFlagInfo,crc_size);
- printf("crc is 0x%x,crc_cal is 0x%x\n",crc,crc_cal);
-
- if(fotaFlagInfo->magic_start != FLAGS_MAGIC || (crc!= crc_cal && crc != 0))
+ memset(name, 0xff, IMG_NAME_LEN);
+ if(!memcmp(fotaFlagInfo->img_size[0].name, name, IMG_NAME_LEN)){
+ printf("image name is null.\n");
+ if(fotaFlagInfo->magic_start != FLAGS_MAGIC)
{
+ printf("work_area_offset magic err.\n");
flush_dcache_all();
ret = flash->read(nand,(loff_t)backup_area_offset,
&fota_size,(u_char *)(fotaFlagInfo));
@@ -1307,59 +1313,186 @@
{
printf("flags magic err.\n");
return -1;
- }
-
- /*crc32УÑé*/
- crc = fotaFlagInfo->crc32;
- fotaFlagInfo->crc32 = 0;
- crc32init_le();
- crc_cal = crc32_le(0,(unsigned char*)fotaFlagInfo,crc_size);
-
- if(crc!= crc_cal && crc != 0)
- {
- printf("flags crc err.\n");
- return -1;
- }
-
+ }
}
+
}
- else if(type == IF_TYPE_NOR)
- {
- work_area_offset = part_offset;
- backup_area_offset = part_offset + nor->nor[0].mtd.erasesize;
- ret = nand_read(&(nor->nor[0].mtd), (loff_t)work_area_offset,
- &fota_size, (u_char *)(fotaFlagInfo));
- if(ret)
+ else if(fotaFlagInfo->magic_start != FLAGS_MAGIC || (crc!= crc_cal && crc != 0))
+ {
+ flush_dcache_all();
+ printf("work_area_offset magic is 0x%x.\n",fotaFlagInfo->magic_start);
+ ret = flash->read(nand,(loff_t)backup_area_offset,
+ &fota_size,(u_char *)(fotaFlagInfo));
+ if(ret != 0)
{
- BOOT_PRINTF(UBOOT_ERR, "[%s]: read the flags error!\n", part_name);
+ printf("read flags backup partition err.\n");
+
return -1;
}
+
if(fotaFlagInfo->magic_start != FLAGS_MAGIC)
{
- flush_dcache_all();
- ret = nand_read(&(nor->nor[0].mtd), (loff_t)backup_area_offset,
- &fota_size, (u_char *)(fotaFlagInfo));
- if(ret != 0)
- {
- printf("read flags backup partition err.\n");
-
- return -1;
- }
-
- if(fotaFlagInfo->magic_start != FLAGS_MAGIC)
- {
- printf("flags magic err.\n");
- return -1;
- }
+ printf("backup_area_offset magic is 0x%x.\n",fotaFlagInfo->magic_start);
+ printf("flags magic err.\n");
+ return -1;
}
+
+ /*crc32УÑé*/
+ crc = fotaFlagInfo->crc32_1;
+ fotaFlagInfo->crc32_1 = 0;
+ crc32init_le();
+ crc_cal = crc32_le(0,(unsigned char*)fotaFlagInfo,crc_size);
+
+ if(crc!= crc_cal && crc != 0)
+ {
+ printf("flags crc err.\n");
+ return -1;
+ }
+
}
-
+
flash_dmabuf_disable_flag = 0;
flush_dcache_all();
return 0;
}
+int write_flags(T_FLAGS_INFO *fotaFlagInfo)
+{
+ 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";
+ u32 fota_size = sizeof(T_FLAGS_INFO);
+ //fota_size = page_align(fota_size);
+ unsigned long crc = 0;
+ u32 crc_size = sizeof(T_FLAGS_INFO);
+ char name[IMG_NAME_LEN];
+
+ 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;
+ nand_erase_options_t opts;
+
+ flush_dcache_all();
+ //flash_dmabuf_disable_flag = 1;
+
+ 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;
+
+ /*crc32*/
+ memset(name, 0xff, IMG_NAME_LEN);
+ if(!memcmp(fotaFlagInfo->img_size[0].name, name, IMG_NAME_LEN)){
+ printf("the image name is null.\n");
+ fotaFlagInfo->crc32_1 = 0;
+ memset((unsigned char*)(fotaFlagInfo->img_size[0].name), 0, (crc_size - 512));
+ crc32init_le();
+ crc = crc32_le(0,(unsigned char*)fotaFlagInfo,crc_size);
+ fotaFlagInfo->crc32_1 = crc;
+ printf("flags partition crc32_1 is 0x%x\n",crc);
+
+ }else{
+ fotaFlagInfo->crc32 = 0;
+ crc32init_le();
+ crc = crc32_le(0,(unsigned char*)fotaFlagInfo,512);
+ fotaFlagInfo->crc32 = crc;
+
+ fotaFlagInfo->crc32_1 = 0;
+ crc32init_le();
+ crc = crc32_le(0,(unsigned char*)fotaFlagInfo,crc_size);
+ fotaFlagInfo->crc32_1 = crc;
+ printf("flags partition crc32 is 0x%x,crc32_1 is 0x%x\n",fotaFlagInfo->crc32,fotaFlagInfo->crc32_1);
+ }
+
+ /*дÈëflags·ÖÇø*/
+
+ /*È·¶¨¹¤×÷ÇøºÍ±¸·ÝÇøÆ«ÒÆµØÖ·*/
+ 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;
+ }
+
+ //printf("work_area_offset is 0x%x,backup_area_offset is 0x%x,crc_size is 0x%x\n",work_area_offset,backup_area_offset,crc_size);
+
+ /*²Á³ý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;
+ }
+
+ flash_dmabuf_disable_flag = 0;
+ flush_dcache_all();
+ return 0;
+}
+
#endif
/* ================================================================================
* get_fota_update_flag :
diff --git a/boot/common/src/uboot/drivers/power/zx234290.c b/boot/common/src/uboot/drivers/power/zx234290.c
index 90a52e2..e8f083f 100755
--- a/boot/common/src/uboot/drivers/power/zx234290.c
+++ b/boot/common/src/uboot/drivers/power/zx234290.c
@@ -125,6 +125,43 @@
#endif
}
+
+void zx234290_set_rtc_alarm_off(void)
+{
+ int ret = 0;
+ uchar tmp = 0;
+
+ //set alarm active bit 1 disable
+ ret = zx234290_i2c_read_reg(ZX234290_REG_ADDR_ALARM_MINUTE, &tmp);
+ tmp |= (1<<ZX234290_RTC_AlARM_ACTIVATED_LSH);
+ ret |= zx234290_i2c_write_reg(ZX234290_REG_ADDR_ALARM_MINUTE, &tmp);
+
+ ret |= zx234290_i2c_read_reg(ZX234290_REG_ADDR_ALARM_HOUR, &tmp);
+ tmp |= (1<<ZX234290_RTC_AlARM_ACTIVATED_LSH);
+ ret |= zx234290_i2c_write_reg(ZX234290_REG_ADDR_ALARM_HOUR, &tmp);
+
+ ret |= zx234290_i2c_read_reg(ZX234290_REG_ADDR_ALARM_DAY, &tmp);
+ tmp |= (1<<ZX234290_RTC_AlARM_ACTIVATED_LSH);
+ ret |= zx234290_i2c_write_reg(ZX234290_REG_ADDR_ALARM_DAY, &tmp);
+
+ ret = zx234290_i2c_read_reg(ZX234290_REG_ADDR_ALARM_WEEK, &tmp);
+ tmp |= (1<<ZX234290_RTC_AlARM_ACTIVATED_LSH);
+ ret |= zx234290_i2c_write_reg(ZX234290_REG_ADDR_ALARM_WEEK, &tmp);
+
+
+ ret |= zx234290_i2c_read_reg(ZX234290_REG_ADDR_ALARM_SECOND, &tmp);
+ tmp |= (1<<ZX234290_RTC_AlARM_ACTIVATED_LSH);
+ ret |= zx234290_i2c_write_reg(ZX234290_REG_ADDR_ALARM_SECOND, &tmp);
+
+ /*disable AIE bit && AF*/
+ ret |= zx234290_i2c_read_reg(ZX234290_REG_RTC_CONTROL2, &tmp);
+ tmp &= ~(RTC_CONTROL2_AIE|RTC_CONTROL2_AF);
+ ret |= zx234290_i2c_write_reg(ZX234290_REG_RTC_CONTROL2, &tmp);
+
+ if(ret)
+ printf( "[%s] fail ret=%d...\n", __FUNCTION__, ret);
+
+}
/*******************************************************************************
* Function: zx234290_get_boot_reason
* Description:
@@ -222,6 +259,7 @@
if (rtc_ctrl2 & RTC_CONTROL2_AF) {
s_boot_reason = RB_RTC;
+ zx234290_set_rtc_alarm_off();
} else if (rtc_ctrl2 & RTC_CONTROL2_TF) {
s_boot_reason = RB_RESET_NOMAL;
}
@@ -375,12 +413,11 @@
pmu.ps_hold_pull_off = pmu_pull_off_ps_hold;
pmu.power_off = zx234290_power_off;
ret = register_pmu_opt(&pmu);
- /*
if( ret != 0 )
{
return -EIO;
}
- */
+
ret = zx234290_get_boot_reason_prev();
ret +=zx234290_i2c_read_reg(ZX234297_REG_ADDR_SINK_CONTROL,®_val);
if(reg_val==0x7f){//means 296G C
diff --git a/boot/common/src/uboot/drivers/serial/uart.c b/boot/common/src/uboot/drivers/serial/uart.c
index c5eb337..a8d7f6b 100755
--- a/boot/common/src/uboot/drivers/serial/uart.c
+++ b/boot/common/src/uboot/drivers/serial/uart.c
@@ -172,6 +172,19 @@
#ifdef CONFIG_CTRL_X_SWTCH_UART
+/*******************************************************************************
+ * Function: check if user press ctrl +x from uboot serial
+ * Description: read console flag before start kernel
+ * Parameters: us °´¼ü·À¶¶Ê±¼ä£¬wait µÈ´ý°´¼ü×Üʱ¼ä
+ * Input:
+ *
+ * Output:
+ *
+ * Returns:
+ *
+ *
+ * Others:
+ ********************************************************************************/
extern bool g_flg_ctrl_x;
void serial_getc_cons_key_flag(unsigned long us,unsigned int wait)
{
diff --git a/boot/common/src/uboot/include/partition_table.h b/boot/common/src/uboot/include/partition_table.h
index 6d27ca4..306a64c 100755
--- a/boot/common/src/uboot/include/partition_table.h
+++ b/boot/common/src/uboot/include/partition_table.h
@@ -211,6 +211,7 @@
#define PARTITION_CRC 0x12345678
#define PARTITION_SIZE 0X1000 /* ·ÖÇø±íµÄ´óС */
+#define IMG_NUM 5
typedef struct partition_entry {
unsigned char part_name[16];
diff --git a/boot/common/src/uboot/include/zx234290.h b/boot/common/src/uboot/include/zx234290.h
index 2c0853f..d0dc5a7 100755
--- a/boot/common/src/uboot/include/zx234290.h
+++ b/boot/common/src/uboot/include/zx234290.h
@@ -60,6 +60,15 @@
#define ZX234297_REG_ADDR_SINK_CONTROL 0X29
#define ZX234290_REG_RTC_CONTROL2 0x31
+
+/*RTC ALARM Enable*/
+#define ZX234290_REG_ADDR_ALARM_MINUTE 0x39
+#define ZX234290_REG_ADDR_ALARM_HOUR 0x3A
+#define ZX234290_REG_ADDR_ALARM_DAY 0x3B
+#define ZX234290_REG_ADDR_ALARM_WEEK 0x3C
+#define ZX234290_REG_ADDR_ALARM_SECOND 0x3D
+#define ZX234290_RTC_AlARM_ACTIVATED_LSH (7)
+
#define RTC_CONTROL2_TIE (1 << 0)
#define RTC_CONTROL2_AIE (1 << 1)
#define RTC_CONTROL2_TF (1 << 2)