diff --git a/lichee/brandy/u-boot-2014.07/board/sunxi/common/netease_ota.c b/lichee/brandy/u-boot-2014.07/board/sunxi/common/netease_ota.c index cb52b80f4..8b3875695 100644 --- a/lichee/brandy/u-boot-2014.07/board/sunxi/common/netease_ota.c +++ b/lichee/brandy/u-boot-2014.07/board/sunxi/common/netease_ota.c @@ -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, diff --git a/target/allwinner/mandolin-common/bin/u-boot-sun8iw15p1.bin b/target/allwinner/mandolin-common/bin/u-boot-sun8iw15p1.bin index fdd5892c4..92eed82fb 100755 Binary files a/target/allwinner/mandolin-common/bin/u-boot-sun8iw15p1.bin and b/target/allwinner/mandolin-common/bin/u-boot-sun8iw15p1.bin differ