Fix Uboot can't find boot/rootfs image then don't setup
This commit is contained in:
parent
e427d1dad6
commit
2739631b44
|
@ -303,11 +303,8 @@ static int run_ota_upgrade(POTA_PARAMS pInfo)
|
|||
|
||||
memset(&upgInfo, 0, sizeof(OTA_PARAMS));
|
||||
|
||||
SET_STA_FLAG(pInfo->otaStatus, FLAG_EXEC_OTA);
|
||||
upgInfo.bootfileSize = ota_read_boot_image();
|
||||
|
||||
upgInfo.bootfileSize = ota_read_boot_image();
|
||||
ota_calc_boot_image_chksum(upgInfo.bootfileSize, upgInfo.bootChksum);
|
||||
|
||||
if(upgInfo.bootfileSize != pInfo->bootfileSize)
|
||||
{
|
||||
printf("Upgrade boot image maybe error:\n\t%s --> %s\n\t%u-%u\n",
|
||||
|
@ -318,7 +315,9 @@ static int run_ota_upgrade(POTA_PARAMS pInfo)
|
|||
ota_save_params(pInfo);
|
||||
return -ERR_BAD_BOOT_CHKSUM;
|
||||
}
|
||||
else if(strcmp(upgInfo.bootChksum, pInfo->bootChksum) != 0)
|
||||
|
||||
ota_calc_boot_image_chksum(upgInfo.bootfileSize, upgInfo.bootChksum);
|
||||
if(strcmp(upgInfo.bootChksum, pInfo->bootChksum) != 0)
|
||||
{
|
||||
printf("Upgrade boot image maybe error:\n\t%s --> %s\n\t%u-%u\n",
|
||||
upgInfo.bootChksum, pInfo->bootChksum,
|
||||
|
@ -327,18 +326,9 @@ static int run_ota_upgrade(POTA_PARAMS pInfo)
|
|||
SET_STA_ERR(pInfo->otaStatus, ERR_BAD_BOOT_FILESIZE);
|
||||
ota_save_params(pInfo);
|
||||
return -ERR_BAD_BOOT_FILESIZE;
|
||||
}
|
||||
}
|
||||
|
||||
if(ota_upgrade_boot_image() != 0)
|
||||
{
|
||||
printf("Write boot image error\n");
|
||||
SET_STA_ERR(pInfo->otaStatus, ERR_WRITE_BOOTIMG);
|
||||
ota_save_params(pInfo);
|
||||
return -ERR_WRITE_BOOTIMG;
|
||||
}
|
||||
|
||||
upgInfo.rootfsfileSize = ota_read_rootfs_image();
|
||||
ota_calc_rootfs_image_chksum(upgInfo.rootfsfileSize, upgInfo.rootfsChksum);
|
||||
upgInfo.rootfsfileSize = ota_read_rootfs_image();
|
||||
|
||||
if(upgInfo.rootfsfileSize != pInfo->rootfsfileSize)
|
||||
{
|
||||
|
@ -350,7 +340,9 @@ static int run_ota_upgrade(POTA_PARAMS pInfo)
|
|||
ota_save_params(pInfo);
|
||||
return -ERR_BAD_ROOTFS_FILESIZE;
|
||||
}
|
||||
else if(strcmp(upgInfo.rootfsChksum, pInfo->rootfsChksum) != 0)
|
||||
|
||||
ota_calc_rootfs_image_chksum(upgInfo.rootfsfileSize, upgInfo.rootfsChksum);
|
||||
if(strcmp(upgInfo.rootfsChksum, pInfo->rootfsChksum) != 0)
|
||||
{
|
||||
printf("Upgrade rootfs image maybe error:\n\t%s --> %s\n\t%u-%u\n",
|
||||
upgInfo.rootfsChksum, pInfo->rootfsChksum,
|
||||
|
@ -361,6 +353,16 @@ static int run_ota_upgrade(POTA_PARAMS pInfo)
|
|||
return -ERR_BAD_ROOTFS_CHKSUM;
|
||||
}
|
||||
|
||||
SET_STA_FLAG(pInfo->otaStatus, FLAG_EXEC_OTA);
|
||||
|
||||
if(ota_upgrade_boot_image() != 0)
|
||||
{
|
||||
printf("Write boot image error\n");
|
||||
SET_STA_ERR(pInfo->otaStatus, ERR_WRITE_BOOTIMG);
|
||||
ota_save_params(pInfo);
|
||||
return -ERR_WRITE_BOOTIMG;
|
||||
}
|
||||
|
||||
if(ota_upgrade_rootfs_image() != 0)
|
||||
{
|
||||
printf("Write rootfs image error\n");
|
||||
|
@ -418,7 +420,9 @@ static int verify_ota_upgrade(POTA_PARAMS pInfo)
|
|||
return ERR_OK;
|
||||
}
|
||||
|
||||
static int run_ota_task(void)
|
||||
static int
|
||||
|
||||
run_ota_task(void)
|
||||
{
|
||||
OTA_PARAMS otaInfo;
|
||||
|
||||
|
@ -441,7 +445,17 @@ static int run_ota_task(void)
|
|||
if(run_ota_upgrade(&otaInfo) != ERR_OK)
|
||||
{
|
||||
int val = GET_STA_CNT(otaInfo.otaStatus) + 1;
|
||||
SET_STA_CNT(otaInfo.otaStatus, val);
|
||||
|
||||
if(val > 3)
|
||||
{
|
||||
SET_STA_CNT(otaInfo.otaStatus, 0);
|
||||
SET_STA_CMD(otaInfo.otaStatus, CMD_RUN_BOOT);
|
||||
SET_STA_FLAG(otaInfo.otaStatus, FLAG_NORMAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
SET_STA_CNT(otaInfo.otaStatus, val);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -651,7 +665,7 @@ int do_ota_cmd(cmd_tbl_t* cmdtp, int flag, int argc,
|
|||
int do_ota_setup(cmd_tbl_t* cmdtp, int flag, int argc,
|
||||
char* const argv[])
|
||||
{
|
||||
return run_ota_task();
|
||||
return run_ota_task();
|
||||
}
|
||||
|
||||
U_BOOT_CMD(ota_setup, 1, 0, do_ota_setup,
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue