[Feature][T8TSK-60][FOTA]FOTA library adds OEMAPP, OEMAPP2 full package for both partitions, and sub-package upgrade(NewGSW)
Change-Id: Iaf2313fdaed8a31e6fb9f0755f25af8253fbfd8e
diff --git a/src/lynq/lib/liblynq-fota/include/iot_rock.h b/src/lynq/lib/liblynq-fota/include/iot_rock.h
index 3fe2427..aa7236d 100755
--- a/src/lynq/lib/liblynq-fota/include/iot_rock.h
+++ b/src/lynq/lib/liblynq-fota/include/iot_rock.h
@@ -26,16 +26,20 @@
#define PATCH_MD1IMG (4)
#define PATCH_MD1DSP (5)
#define PATCH_VBMETA (6)
-#define PATCH_BL33 (7)
-#define FULL_SYSTEM (8)
-#define FULL_BOOT (9)
-#define FULL_TEE (10)
-#define FULL_MD1IMG (11)
-#define FULL_MD1DSP (12)
-#define FULL_VBMETA (13)
-#define FULL_BL33 (14)
+#define PATCH_OEMAPP (7)
+#define PATCH_OEMAPP2 (8)
+#define PATCH_BL33 (9)
+#define FULL_SYSTEM (10)
+#define FULL_BOOT (11)
+#define FULL_TEE (12)
+#define FULL_MD1IMG (13)
+#define FULL_MD1DSP (14)
+#define FULL_VBMETA (15)
+#define FULL_OEMAPP (16)
+#define FULL_OEMAPP2 (17)
+#define FULL_BL33 (18)
-#define MAX_OTA_ROLE (14)
+#define MAX_OTA_ROLE (18)
@@ -70,6 +74,8 @@
unsigned int md1img; //md1img 差分包大小
unsigned int md1dsp; //md1dsp 差分包大小
unsigned int vbmeta; //vbmeta 差分包大小
+ unsigned int oemapp;
+ unsigned int oemapp2;
unsigned int bl33; //bl33 差分包大小
unsigned int full_sys; //system 整包大小
unsigned int full_boot; //boot
@@ -77,7 +83,9 @@
unsigned int full_md1img; // 整包大小
unsigned int full_md1dsp; //md1dsp 整包大小
unsigned int full_vbmeta; //vbmeta 整包大小
- unsigned int full_bl33; //bl33 整包大小
+ unsigned int full_oemapp;
+ unsigned int full_oemapp2;
+ unsigned int full_bl33; //bl33 整包大小
} DELTA_HEAD;
typedef struct {
@@ -113,7 +121,7 @@
//#define DELTA_HEARD_SIZE (4*5)
-#define DELTA_HEARD_SIZE (4*7 + 4*7)
+#define DELTA_HEARD_SIZE (4*9 + 4*9)
#define DELTA_FULL_HEARD_SIZE 8
diff --git a/src/lynq/lib/liblynq-fota/rock_ua/rock_ua.c b/src/lynq/lib/liblynq-fota/rock_ua/rock_ua.c
index d31a0d9..718255c 100755
--- a/src/lynq/lib/liblynq-fota/rock_ua/rock_ua.c
+++ b/src/lynq/lib/liblynq-fota/rock_ua/rock_ua.c
@@ -57,6 +57,12 @@
#define DEV_VBMETA_A "/dev/disk/by-partlabel/vbmeta_a"
#define DEV_VBMETA_B "/dev/disk/by-partlabel/vbmeta_b"
+#define DEV_OEMAPP_A "/dev/disk/by-partlabel/oemapp_a"
+#define DEV_OEMAPP_B "/dev/disk/by-partlabel/oemapp_b"
+
+#define DEV_OEMAPP2_A "/dev/disk/by-partlabel/oemapp2_a"
+#define DEV_OEMAPP2_B "/dev/disk/by-partlabel/oemapp2_b"
+
#define DEV_BL2 "/dev/disk/by-partlabel/bl2"
#define DEV_BL33 "/dev/disk/by-partlabel/bl33"
@@ -93,7 +99,7 @@
-int fd_system_a,fd_system_b,fd_boot_a,fd_boot_b,fd_tee_a,fd_tee_b,fd_bl2,fd_bl33,fd_delta,fd_curr,fd_log,fd_update_status,fd_md1img_a,fd_md1img_b,fd_fota_status,fd_md1dsp_a,fd_md1dsp_b,fd_vbmeta_a,fd_vbmeta_b;
+int fd_system_a,fd_system_b,fd_boot_a,fd_boot_b,fd_tee_a,fd_tee_b,fd_bl2,fd_bl33,fd_delta,fd_curr,fd_log,fd_update_status,fd_md1img_a,fd_md1img_b,fd_fota_status,fd_md1dsp_a,fd_md1dsp_b,fd_vbmeta_a,fd_vbmeta_b,fd_oemapp_a,fd_oemapp_b,fd_oemapp2_a,fd_oemapp2_b;
int fd_write,fd_read;
static unsigned int delta_offset = 0;
@@ -613,8 +619,8 @@
read(fd_delta, (unsigned char*)&da_head, sizeof(da_head));
- rock_trace(&ctx, "da_head.sys:%d,da_head.boot:%d,da_head.tee:%d,da_head.md1img=%d,da_head.md1dsp=%d,da_head.vbmeta=%d,da_head.bl33=%d\n", da_head.sys, da_head.boot,da_head.tee,da_head.md1img,da_head.md1dsp,da_head.vbmeta,da_head.bl33);
- rock_trace(&ctx, "da_head.fullsys:%d,da_head.fullboot:%d,da_head.fulltee:%d,da_head.fullmd1img=%d,da_head.fullmd1dsp=%d,da_head.fullvbmeta=%d,da_head.fullbl33=%d\n", da_head.full_sys, da_head.full_boot,da_head.full_tee, da_head.full_md1img,da_head.full_md1dsp,da_head.full_vbmeta,da_head.full_bl33);
+ rock_trace(&ctx, "da_head.sys:%d,da_head.boot:%d,da_head.tee:%d,da_head.md1img=%d,da_head.md1dsp=%d,da_head.vbmeta=%d,da_head.oemapp=%d,da_head.oemapp2=%d,da_head.bl33=%d\n", da_head.sys, da_head.boot,da_head.tee,da_head.md1img,da_head.md1dsp,da_head.vbmeta,da_head.oemapp,da_head.oemapp2,da_head.bl33);
+ rock_trace(&ctx, "da_head.fullsys:%d,da_head.fullboot:%d,da_head.fulltee:%d,da_head.fullmd1img=%d,da_head.fullmd1dsp=%d,da_head.fullvbmeta=%d,da_head.full_oemapp=%d,da_head.full_oemapp2=%d,da_head.fullbl33=%d\n", da_head.full_sys, da_head.full_boot,da_head.full_tee, da_head.full_md1img,da_head.full_md1dsp,da_head.full_vbmeta,da_head.full_oemapp,da_head.full_oemapp2,da_head.full_bl33);
if (da_head.sys>0) {
@@ -635,6 +641,12 @@
if (da_head.vbmeta>0) {
fota_status.update_status[PATCH_VBMETA - 1].need_update = 1;
}
+ if (da_head.oemapp>0) {
+ fota_status.update_status[PATCH_OEMAPP - 1].need_update = 1;
+ }
+ if (da_head.oemapp2>0) {
+ fota_status.update_status[PATCH_OEMAPP2 - 1].need_update = 1;
+ }
if (da_head.bl33>0) {
fota_status.update_status[PATCH_BL33 - 1].need_update = 1;
}
@@ -660,10 +672,16 @@
if (da_head.full_vbmeta>0) {
fota_status.update_status[FULL_VBMETA - 1].need_update = 1;
}
+ if (da_head.full_oemapp>0) {
+ fota_status.update_status[FULL_OEMAPP - 1].need_update = 1;
+ }
+ if (da_head.full_oemapp2>0) {
+ fota_status.update_status[FULL_OEMAPP2 - 1].need_update = 1;
+ }
fota_status.switch_slot = WAIT;
save_fota_status();
- delta_size = da_head.sys + da_head.boot + da_head.tee + da_head.md1img + da_head.md1dsp + da_head.vbmeta + da_head.bl33;
+ delta_size = da_head.sys + da_head.boot + da_head.tee + da_head.md1img + da_head.md1dsp + da_head.vbmeta + da_head.oemapp + da_head.oemapp2 + da_head.bl33;
if ((da_head.sys>0) && (up_info.ota_run <= PATCH_SYSTEM))
@@ -1423,11 +1441,246 @@
}
+ if ((da_head.oemapp>0) && (up_info.ota_run <= PATCH_OEMAPP))
+ {
+
+ now_patch = PATCH_OEMAPP;
+ delta_offset = DELTA_HEARD_SIZE + da_head.sys + da_head.boot + da_head.tee + da_head.md1img + da_head.md1dsp + da_head.vbmeta;
+
+
+ if (up_info.ota_run == PATCH_OEMAPP)
+ {
+ ctx.first_run = 0;
+
+ }else{
+ ctx.first_run = 1;
+ }
+
+
+
+ if(current_slot==SLOT_B) {
+ system("flash_eraseall /dev/disk/by-partlabel/oemapp_a");
+ } else {
+ system("flash_eraseall /dev/disk/by-partlabel/oemapp_b");
+ }
+// if(current_slot==SLOT_B) {
+ fd_oemapp_a = mtk_device_wrap_open(DEV_OEMAPP_A,O_RDWR);
+ if (fd_oemapp_a < 0) {
+ err = errno;
+ LYERRLOG("+[UA]: Error opening metadata file: %s\n",strerror(errno));
+ lynq_fota_release_wake_lock();
+ return -err;
+ }
+// fd_curr = fd_oemapp_a;
+// }else{
+ fd_oemapp_b = mtk_device_wrap_open(DEV_OEMAPP_B,O_RDWR);
+ if (fd_oemapp_b < 0) {
+ err = errno;
+ LYERRLOG("+[UA]: Error opening metadata file: %s\n",strerror(errno));
+ lynq_fota_release_wake_lock();
+ return -err;
+ }
+// fd_curr = fd_oemapp_b;
+// }
+
+ if(current_slot==SLOT_B){
+ fd_read = fd_oemapp_b;
+ fd_write = fd_oemapp_a;
+ } else {
+ fd_read = fd_oemapp_a;
+ fd_write = fd_oemapp_b;
+ }
+
+
+ fota_status.ota_run = PATCH_OEMAPP;
+ fota_status.update_status[PATCH_OEMAPP-1].check_delta = WAIT;
+ fota_status.update_status[PATCH_OEMAPP-1].check_rom = WAIT;
+ fota_status.update_status[PATCH_OEMAPP-1].update_result= WAIT;
+
+ save_fota_status();
+
+ up_info.ota_run = PATCH_OEMAPP;
+
+ lseek(fd_update_status,0,SEEK_SET);
+ write(fd_update_status, &up_info,sizeof(up_info));
+ sync();
+
+ LYVERBLOG("+[UA]: Start upgrading oemapp.\n");
+ status = iot_patch(&ctx);
+ LYVERBLOG("+[UA]: oemapp upgrade result:%d\n",status);
+
+ up_info.ota_run = 0;
+ //fota_status.ota_run = 0;
+ fota_status.update_status[PATCH_OEMAPP-1].update_result= status;
+ fota_status.update_result= status;
+
+ if((status == 0)||(status ==1))
+ {
+
+ fota_status.update_status[PATCH_OEMAPP-1].check_delta = PASS;
+ fota_status.update_status[PATCH_OEMAPP-1].check_rom = PASS;
+
+ }else if(status == E_ROCK_INVALID_DELTA) {
+ fota_status.update_status[PATCH_OEMAPP-1].check_delta = ERROR;
+ fota_status.update_status[PATCH_OEMAPP-1].check_rom = WAIT;
+ }else if((status == E_ROCK_DELTA_MISMATCH)||(status == E_ROCK_DELTA_CHUNK_MISMATCH)) {
+ fota_status.update_status[PATCH_OEMAPP-1].check_delta = PASS;
+ fota_status.update_status[PATCH_OEMAPP-1].check_rom = ERROR;
+
+ }else{
+
+ //fota_status.update_status[PATCH_OEMAPP -1].check_delta = PASS;
+ //fota_status.update_status[PATCH_OEMAPP -1].check_rom = WAIT;
+ }
+
+ save_fota_status();
+
+
+ if ((status != 0) &&(status != 1))
+ {
+ up_info.fota_flag[0] = 'e';
+ up_info.fota_flag[1] = 'n';
+ up_info.fota_flag[2] = 'd';
+ up_info.update_result = status;
+ up_info.ota_run = 0;
+ lseek(fd_update_status,0,SEEK_SET);
+ write(fd_update_status, &up_info,sizeof(up_info));
+ sync();
+ close(fd_update_status);
+ mtk_device_wrap_close(fd_read);
+ mtk_device_wrap_close(fd_write);
+ lynq_fota_release_wake_lock();
+ return status;
+ }
+ mtk_device_wrap_close(fd_read);
+ mtk_device_wrap_close(fd_write);
+
+
+ }
+
+ if ((da_head.oemapp2>0) && (up_info.ota_run <= PATCH_OEMAPP2))
+ {
+
+ now_patch = PATCH_OEMAPP2;
+ delta_offset = DELTA_HEARD_SIZE + da_head.sys + da_head.boot + da_head.tee + da_head.md1img + da_head.md1dsp + da_head.vbmeta + da_head.oemapp;
+
+
+ if (up_info.ota_run == PATCH_OEMAPP2)
+ {
+ ctx.first_run = 0;
+
+ }else{
+ ctx.first_run = 1;
+ }
+
+
+
+ if(current_slot==SLOT_B) {
+ system("flash_eraseall /dev/disk/by-partlabel/oemapp2_a");
+ } else {
+ system("flash_eraseall /dev/disk/by-partlabel/oemapp2_b");
+ }
+// if(current_slot==SLOT_B) {
+ fd_oemapp2_a = mtk_device_wrap_open(DEV_OEMAPP2_A,O_RDWR);
+ if (fd_oemapp2_a < 0) {
+ err = errno;
+ LYERRLOG("+[UA]: Error opening metadata file: %s\n",strerror(errno));
+ lynq_fota_release_wake_lock();
+ return -err;
+ }
+// fd_curr = fd_oemapp2_a;
+// }else{
+ fd_oemapp2_b = mtk_device_wrap_open(DEV_OEMAPP2_B,O_RDWR);
+ if (fd_oemapp2_b < 0) {
+ err = errno;
+ LYERRLOG("+[UA]: Error opening metadata file: %s\n",strerror(errno));
+ lynq_fota_release_wake_lock();
+ return -err;
+ }
+// fd_curr = fd_oemapp2_b;
+// }
+
+ if(current_slot==SLOT_B){
+ fd_read = fd_oemapp2_b;
+ fd_write = fd_oemapp2_a;
+ } else {
+ fd_read = fd_oemapp2_a;
+ fd_write = fd_oemapp2_b;
+ }
+
+
+ fota_status.ota_run = PATCH_OEMAPP2;
+ fota_status.update_status[PATCH_OEMAPP2-1].check_delta = WAIT;
+ fota_status.update_status[PATCH_OEMAPP2-1].check_rom = WAIT;
+ fota_status.update_status[PATCH_OEMAPP2-1].update_result= WAIT;
+
+ save_fota_status();
+
+ up_info.ota_run = PATCH_OEMAPP2;
+
+ lseek(fd_update_status,0,SEEK_SET);
+ write(fd_update_status, &up_info,sizeof(up_info));
+ sync();
+
+ LYVERBLOG("+[UA]: Start upgrading oemapp2.\n");
+ status = iot_patch(&ctx);
+ LYVERBLOG("+[UA]: oemapp2 upgrade result:%d\n",status);
+
+ up_info.ota_run = 0;
+ //fota_status.ota_run = 0;
+ fota_status.update_status[PATCH_OEMAPP2-1].update_result= status;
+ fota_status.update_result= status;
+
+ if((status == 0)||(status ==1))
+ {
+
+ fota_status.update_status[PATCH_OEMAPP2-1].check_delta = PASS;
+ fota_status.update_status[PATCH_OEMAPP2-1].check_rom = PASS;
+
+ }else if(status == E_ROCK_INVALID_DELTA) {
+ fota_status.update_status[PATCH_OEMAPP2-1].check_delta = ERROR;
+ fota_status.update_status[PATCH_OEMAPP2-1].check_rom = WAIT;
+ }else if((status == E_ROCK_DELTA_MISMATCH)||(status == E_ROCK_DELTA_CHUNK_MISMATCH)) {
+ fota_status.update_status[PATCH_OEMAPP2-1].check_delta = PASS;
+ fota_status.update_status[PATCH_OEMAPP2-1].check_rom = ERROR;
+
+ }else{
+
+ //fota_status.update_status[PATCH_OEMAPP2 -1].check_delta = PASS;
+ //fota_status.update_status[PATCH_OEMAPP2 -1].check_rom = WAIT;
+ }
+
+ save_fota_status();
+
+
+ if ((status != 0) &&(status != 1))
+ {
+ up_info.fota_flag[0] = 'e';
+ up_info.fota_flag[1] = 'n';
+ up_info.fota_flag[2] = 'd';
+ up_info.update_result = status;
+ up_info.ota_run = 0;
+ lseek(fd_update_status,0,SEEK_SET);
+ write(fd_update_status, &up_info,sizeof(up_info));
+ sync();
+ close(fd_update_status);
+ mtk_device_wrap_close(fd_read);
+ mtk_device_wrap_close(fd_write);
+ lynq_fota_release_wake_lock();
+ return status;
+ }
+ mtk_device_wrap_close(fd_read);
+ mtk_device_wrap_close(fd_write);
+
+
+ }
+
if ((da_head.bl33>0) && (up_info.ota_run <= PATCH_BL33))
{
now_patch = PATCH_BL33;
- delta_offset = DELTA_HEARD_SIZE + da_head.sys + da_head.boot + da_head.tee + da_head.md1img + da_head.md1dsp + da_head.vbmeta;
+ delta_offset = DELTA_HEARD_SIZE + da_head.sys + da_head.boot + da_head.tee + da_head.md1img + da_head.md1dsp + da_head.vbmeta + da_head.oemapp + da_head.oemapp2;
+
if (up_info.ota_run == PATCH_BL33)
{
@@ -1448,13 +1701,13 @@
}
fd_curr = fd_bl33;
- fota_status.ota_run = PATCH_BL33;
+ fota_status.ota_run = PATCH_BL33;
fota_status.update_status[PATCH_BL33-1].check_delta = WAIT;
- fota_status.update_status[PATCH_BL33-1].check_rom = WAIT;
- fota_status.update_status[PATCH_BL33-1].update_result= WAIT;
+ fota_status.update_status[PATCH_BL33-1].check_rom = WAIT;
+ fota_status.update_status[PATCH_BL33-1].update_result= WAIT;
save_fota_status();
-
+
up_info.ota_run = PATCH_BL33;
lseek(fd_update_status,0,SEEK_SET);
@@ -1464,7 +1717,7 @@
LYVERBLOG("+[UA]: Start upgrading bl33.\n");
status = iot_patch(&ctx);
LYVERBLOG("+[UA]: bl33 upgrade result:%d\n",status);
-
+
up_info.ota_run = 0;
//fota_status.ota_run = 0;
@@ -1475,7 +1728,7 @@
fota_status.update_status[PATCH_BL33-1].check_delta = PASS;
fota_status.update_status[PATCH_BL33-1].check_rom = PASS;
-
+
}else if(status == E_ROCK_INVALID_DELTA) {
fota_status.update_status[PATCH_BL33-1].check_delta = ERROR;
fota_status.update_status[PATCH_BL33-1].check_rom = WAIT;
@@ -1484,7 +1737,7 @@
fota_status.update_status[PATCH_BL33-1].check_rom = ERROR;
}else{
-
+
//fota_status.update_status[PATCH_BL33 -1].check_delta = PASS;
//fota_status.update_status[PATCH_BL33 -1].check_rom = WAIT;
}
@@ -1493,17 +1746,16 @@
if ((status != 0) &&(status != 1))
{
-
- up_info.fota_flag[0] = 'e';
- up_info.fota_flag[1] = 'n';
- up_info.fota_flag[2] = 'd';
- up_info.update_result = status;
+ up_info.fota_flag[0] = 'e';
+ up_info.fota_flag[1] = 'n';
+ up_info.fota_flag[2] = 'd';
+ up_info.update_result = status;
up_info.ota_run = 0;
lseek(fd_update_status,0,SEEK_SET);
- write(fd_update_status, &up_info,sizeof(up_info));
- mtk_device_wrap_close(fd_curr);
- sync();
- close(fd_update_status);
+ write(fd_update_status, &up_info,sizeof(up_info));
+ mtk_device_wrap_close(fd_curr);
+ sync();
+ close(fd_update_status);
lynq_fota_release_wake_lock();
return status;
}
@@ -1517,7 +1769,7 @@
- if ((da_head.full_sys>0)|| (da_head.full_boot>0)|| (da_head.full_tee>0)||(da_head.full_md1img>0)||(da_head.full_md1dsp>0)||(da_head.full_vbmeta>0)||(da_head.full_bl33>0))
+ if ((da_head.full_sys>0)|| (da_head.full_boot>0)|| (da_head.full_tee>0)||(da_head.full_md1img>0)||(da_head.full_md1dsp>0)||(da_head.full_vbmeta>0)||(da_head.full_oemapp>0)||(da_head.full_oemapp2>0)||(da_head.full_bl33>0))
{
now_patch = 0;
@@ -2032,25 +2284,179 @@
if (status != 0)
{
-
- up_info.fota_flag[0] = 'e';
- up_info.fota_flag[1] = 'n';
- up_info.fota_flag[2] = 'd';
- up_info.update_result = status;
+ up_info.fota_flag[0] = 'e';
+ up_info.fota_flag[1] = 'n';
+ up_info.fota_flag[2] = 'd';
+ up_info.update_result = status;
up_info.ota_run = 0;
lseek(fd_update_status,0,SEEK_SET);
- write(fd_update_status, &up_info,sizeof(up_info));
- sync();
- close(fd_update_status);
+ write(fd_update_status, &up_info,sizeof(up_info));
+ sync();
+ close(fd_update_status);
lynq_fota_release_wake_lock();
return status;
}
-
-
+
+
}
-
+
+ if(da_head.full_oemapp>0) {
+
+ delta_offset = DELTA_HEARD_SIZE + delta_size + DELTA_FULL_HEARD_SIZE + da_head.full_sys + da_head.full_tee + da_head.full_boot + da_head.full_md1img + da_head.full_md1dsp + da_head.full_vbmeta;
+
+ if(current_slot==SLOT_B) {
+ system("flash_eraseall /dev/disk/by-partlabel/oemapp_a");
+ } else {
+ system("flash_eraseall /dev/disk/by-partlabel/oemapp_b");
+ }
+
+ if(current_slot==SLOT_B) {
+ fd_oemapp_a = mtk_device_wrap_open(DEV_OEMAPP_A,O_RDWR);
+ if (fd_oemapp_a < 0) {
+ err = errno;
+ LYERRLOG("+[UA]: Error opening metadata file: %s\n",strerror(errno));
+ lynq_fota_release_wake_lock();
+ return -err;
+ }
+ fd_curr = fd_oemapp_a;
+ }else{
+ fd_oemapp_b = mtk_device_wrap_open(DEV_OEMAPP_B,O_RDWR);
+ if (fd_oemapp_b < 0) {
+ err = errno;
+ LYERRLOG("+[UA]: Error opening metadata file: %s\n",strerror(errno));
+ lynq_fota_release_wake_lock();
+ return -err;
+ }
+ fd_curr = fd_oemapp_b;
+ }
+ fota_status.ota_run = FULL_OEMAPP;
+ save_fota_status();
+ retry_cnt = 0;
+ LYVERBLOG("+[UA]: Start upgrading oemapp full.\n");
+ do {
+ status = delta_copyto_nand(delta_offset,da_head.full_oemapp);
+ ROCK_SHA_FILE_COMMON(fd_delta,delta_offset,da_head.full_oemapp,digest_s);
+ ROCK_SHA_FILE(fd_curr,0,da_head.full_oemapp,digest_t);
+ retry_cnt++;
+ }while((strncmp(digest_s,digest_t,SHA_DIGEST_SIZE)!=0)&&(retry_cnt <= 3));
+ mtk_device_wrap_close(fd_curr);
+
+ LYVERBLOG("+[UA]: oemapp full retry_cnt = %d\n",retry_cnt);
+ if (retry_cnt>3) {
+ if (status == 0) {
+ status = retry_cnt;
+ }
+ if(current_slot==SLOT_B) {
+ nand_copyto_nand(DEV_OEMAPP_B,DEV_OEMAPP_A);
+ }
+ else{
+ nand_copyto_nand(DEV_OEMAPP_A,DEV_OEMAPP_B);
+ }
+ }
+
+ LYVERBLOG("+[UA]: oemapp upgrade result:%d\n",status);
+ fota_status.update_result = status;
+ fota_status.update_status[FULL_OEMAPP-1].update_result = status;
+ save_fota_status();
+
+ if (status != 0)
+ {
+ up_info.fota_flag[0] = 'e';
+ up_info.fota_flag[1] = 'n';
+ up_info.fota_flag[2] = 'd';
+ up_info.update_result = status;
+ up_info.ota_run = 0;
+ lseek(fd_update_status,0,SEEK_SET);
+ write(fd_update_status, &up_info,sizeof(up_info));
+ sync();
+ close(fd_update_status);
+ lynq_fota_release_wake_lock();
+ return status;
+ }
+
+
+ }
+
+ if(da_head.full_oemapp2>0) {
+
+ delta_offset = DELTA_HEARD_SIZE + delta_size + DELTA_FULL_HEARD_SIZE + da_head.full_sys + da_head.full_tee + da_head.full_boot + da_head.full_md1img + da_head.full_md1dsp + da_head.full_vbmeta + da_head.full_oemapp;
+
+
+ if(current_slot==SLOT_B) {
+ system("flash_eraseall /dev/disk/by-partlabel/oemapp2_a");
+ } else {
+ system("flash_eraseall /dev/disk/by-partlabel/oemapp2_b");
+ }
+
+ if(current_slot==SLOT_B) {
+ fd_oemapp2_a = mtk_device_wrap_open(DEV_OEMAPP2_A,O_RDWR);
+ if (fd_oemapp2_a < 0) {
+ err = errno;
+ LYERRLOG("+[UA]: Error opening metadata file: %s\n",strerror(errno));
+ lynq_fota_release_wake_lock();
+ return -err;
+ }
+ fd_curr = fd_oemapp2_a;
+ }else{
+ fd_oemapp2_b = mtk_device_wrap_open(DEV_OEMAPP2_B,O_RDWR);
+ if (fd_oemapp2_b < 0) {
+ err = errno;
+ LYERRLOG("+[UA]: Error opening metadata file: %s\n",strerror(errno));
+ lynq_fota_release_wake_lock();
+ return -err;
+ }
+ fd_curr = fd_oemapp2_b;
+ }
+ fota_status.ota_run = FULL_OEMAPP2;
+ save_fota_status();
+ retry_cnt = 0;
+ LYVERBLOG("+[UA]: Start upgrading oemapp2 full.\n");
+ do {
+ status = delta_copyto_nand(delta_offset,da_head.full_oemapp2);
+ ROCK_SHA_FILE_COMMON(fd_delta,delta_offset,da_head.full_oemapp2,digest_s);
+ ROCK_SHA_FILE(fd_curr,0,da_head.full_oemapp2,digest_t);
+ retry_cnt++;
+ }while((strncmp(digest_s,digest_t,SHA_DIGEST_SIZE)!=0)&&(retry_cnt <= 3));
+ mtk_device_wrap_close(fd_curr);
+
+ LYVERBLOG("+[UA]: oemapp2 full retry_cnt = %d\n",retry_cnt);
+ if (retry_cnt>3) {
+ if (status == 0) {
+ status = retry_cnt;
+ }
+ if(current_slot==SLOT_B) {
+ nand_copyto_nand(DEV_OEMAPP2_B,DEV_OEMAPP2_A);
+ }
+ else{
+ nand_copyto_nand(DEV_OEMAPP2_A,DEV_OEMAPP2_B);
+ }
+ }
+
+ LYVERBLOG("+[UA]: oemapp2 upgrade result:%d\n",status);
+ fota_status.update_result = status;
+ fota_status.update_status[FULL_OEMAPP2-1].update_result = status;
+ save_fota_status();
+
+ if (status != 0)
+ {
+ up_info.fota_flag[0] = 'e';
+ up_info.fota_flag[1] = 'n';
+ up_info.fota_flag[2] = 'd';
+ up_info.update_result = status;
+ up_info.ota_run = 0;
+ lseek(fd_update_status,0,SEEK_SET);
+ write(fd_update_status, &up_info,sizeof(up_info));
+ sync();
+ close(fd_update_status);
+ lynq_fota_release_wake_lock();
+ return status;
+ }
+
+
+ }
+
if(da_head.full_bl33>0) {
-
+
}
@@ -2060,21 +2466,21 @@
up_info.fota_flag[0] = 'B';
up_info.fota_flag[1] = '-';
- up_info.fota_flag[2] = 'A';
-
+ up_info.fota_flag[2] = 'A';
+
}else{
-
+
up_info.fota_flag[0] = 'A';
up_info.fota_flag[1] = '-';
up_info.fota_flag[2] = 'B';
-
+
}
-
+
}else{
up_info.fota_flag[0] = 'e';
up_info.fota_flag[1] = 'n';
- up_info.fota_flag[2] = 'd';
-
+ up_info.fota_flag[2] = 'd';
+
}
@@ -2361,8 +2767,8 @@
read(fd_delta, (unsigned char*)&da_head, sizeof(da_head));
- rock_trace(&ctx, "da_head.sys:%d,da_head.boot:%d,da_head.tee:%d,da_head.md1img=%d,da_head.md1dsp=%d,da_head.vbmeta=%d,da_head.bl33=%d\n", da_head.sys, da_head.boot,da_head.tee,da_head.md1img,da_head.md1dsp,da_head.vbmeta,da_head.bl33);
- rock_trace(&ctx, "da_head.fullsys:%d,da_head.fullboot:%d,da_head.fulltee:%d,da_head.fullmd1img=%d,da_head.fullmd1dsp=%d,da_head.fullvbmeta=%d,da_head.fullbl33=%d\n", da_head.full_sys, da_head.full_boot,da_head.full_tee, da_head.full_md1img,da_head.full_md1dsp,da_head.full_vbmeta,da_head.full_bl33);
+ rock_trace(&ctx, "da_head.sys:%d,da_head.boot:%d,da_head.tee:%d,da_head.md1img=%d,da_head.md1dsp=%d,da_head.vbmeta=%d,da_head.oemapp=%d,da_head.oemapp2=%d,da_head.bl33=%d\n", da_head.sys, da_head.boot,da_head.tee,da_head.md1img,da_head.md1dsp,da_head.vbmeta,da_head.oemapp,da_head.oemapp2,da_head.bl33);
+ rock_trace(&ctx, "da_head.fullsys:%d,da_head.fullboot:%d,da_head.fulltee:%d,da_head.fullmd1img=%d,da_head.fullmd1dsp=%d,da_head.fullvbmeta=%d,da_head.full_oemapp=%d,da_head.full_oemapp2=%d,da_head.fullbl33=%d\n", da_head.full_sys, da_head.full_boot,da_head.full_tee, da_head.full_md1img,da_head.full_md1dsp,da_head.full_vbmeta,da_head.full_oemapp,da_head.full_oemapp2,da_head.full_bl33);
if (da_head.sys>0) {
@@ -2383,6 +2789,12 @@
if (da_head.vbmeta>0) {
fota_status.update_status[PATCH_VBMETA - 1].need_update = 1;
}
+ if (da_head.oemapp>0) {
+ fota_status.update_status[PATCH_OEMAPP - 1].need_update = 1;
+ }
+ if (da_head.oemapp2>0) {
+ fota_status.update_status[PATCH_OEMAPP2 - 1].need_update = 1;
+ }
if (da_head.bl33>0) {
fota_status.update_status[PATCH_BL33 - 1].need_update = 1;
}
@@ -2408,10 +2820,16 @@
if (da_head.full_vbmeta>0) {
fota_status.update_status[FULL_VBMETA - 1].need_update = 1;
}
+ if (da_head.full_oemapp>0) {
+ fota_status.update_status[FULL_OEMAPP - 1].need_update = 1;
+ }
+ if (da_head.full_oemapp2>0) {
+ fota_status.update_status[FULL_OEMAPP2 - 1].need_update = 1;
+ }
fota_status.switch_slot = WAIT;
save_fota_status();
- delta_size = da_head.sys + da_head.boot + da_head.tee + da_head.md1img + da_head.md1dsp + da_head.vbmeta + da_head.bl33;
+ delta_size = da_head.sys + da_head.boot + da_head.tee + da_head.md1img + da_head.md1dsp + da_head.vbmeta + da_head.oemapp + da_head.oemapp2 + da_head.bl33;
if ((da_head.sys>0) && (up_info.ota_run <= PATCH_SYSTEM))
@@ -3171,11 +3589,246 @@
}
+ if ((da_head.oemapp>0) && (up_info.ota_run <= PATCH_OEMAPP))
+ {
+
+ now_patch = PATCH_OEMAPP;
+ delta_offset = DELTA_HEARD_SIZE + da_head.sys + da_head.boot + da_head.tee + da_head.md1img + da_head.md1dsp + da_head.vbmeta;
+
+
+ if (up_info.ota_run == PATCH_OEMAPP)
+ {
+ ctx.first_run = 0;
+
+ }else{
+ ctx.first_run = 1;
+ }
+
+
+
+ if(current_slot==SLOT_B) {
+ system("flash_eraseall /dev/disk/by-partlabel/oemapp_a");
+ } else {
+ system("flash_eraseall /dev/disk/by-partlabel/oemapp_b");
+ }
+// if(current_slot==SLOT_B) {
+ fd_oemapp_a = mtk_device_wrap_open(DEV_OEMAPP_A,O_RDWR);
+ if (fd_oemapp_a < 0) {
+ err = errno;
+ LYERRLOG("+[UA]: Error opening metadata file: %s\n",strerror(errno));
+ lynq_fota_release_wake_lock();
+ return -err;
+ }
+// fd_curr = fd_oemapp_a;
+// }else{
+ fd_oemapp_b = mtk_device_wrap_open(DEV_OEMAPP_B,O_RDWR);
+ if (fd_oemapp_b < 0) {
+ err = errno;
+ LYERRLOG("+[UA]: Error opening metadata file: %s\n",strerror(errno));
+ lynq_fota_release_wake_lock();
+ return -err;
+ }
+// fd_curr = fd_oemapp_b;
+// }
+
+ if(current_slot==SLOT_B){
+ fd_read = fd_oemapp_b;
+ fd_write = fd_oemapp_a;
+ } else {
+ fd_read = fd_oemapp_a;
+ fd_write = fd_oemapp_b;
+ }
+
+
+ fota_status.ota_run = PATCH_OEMAPP;
+ fota_status.update_status[PATCH_OEMAPP-1].check_delta = WAIT;
+ fota_status.update_status[PATCH_OEMAPP-1].check_rom = WAIT;
+ fota_status.update_status[PATCH_OEMAPP-1].update_result= WAIT;
+
+ save_fota_status();
+
+ up_info.ota_run = PATCH_OEMAPP;
+
+ lseek(fd_update_status,0,SEEK_SET);
+ write(fd_update_status, &up_info,sizeof(up_info));
+ sync();
+
+ LYVERBLOG("+[UA]: Start upgrading oemapp.\n");
+ status = iot_patch(&ctx);
+ LYVERBLOG("+[UA]: oemapp upgrade result:%d\n",status);
+
+ up_info.ota_run = 0;
+ //fota_status.ota_run = 0;
+ fota_status.update_status[PATCH_OEMAPP-1].update_result= status;
+ fota_status.update_result= status;
+
+ if((status == 0)||(status ==1))
+ {
+
+ fota_status.update_status[PATCH_OEMAPP-1].check_delta = PASS;
+ fota_status.update_status[PATCH_OEMAPP-1].check_rom = PASS;
+
+ }else if(status == E_ROCK_INVALID_DELTA) {
+ fota_status.update_status[PATCH_OEMAPP-1].check_delta = ERROR;
+ fota_status.update_status[PATCH_OEMAPP-1].check_rom = WAIT;
+ }else if((status == E_ROCK_DELTA_MISMATCH)||(status == E_ROCK_DELTA_CHUNK_MISMATCH)) {
+ fota_status.update_status[PATCH_OEMAPP-1].check_delta = PASS;
+ fota_status.update_status[PATCH_OEMAPP-1].check_rom = ERROR;
+
+ }else{
+
+ //fota_status.update_status[PATCH_OEMAPP -1].check_delta = PASS;
+ //fota_status.update_status[PATCH_OEMAPP -1].check_rom = WAIT;
+ }
+
+ save_fota_status();
+
+
+ if ((status != 0) &&(status != 1))
+ {
+
+ up_info.fota_flag[0] = 'e';
+ up_info.fota_flag[1] = 'n';
+ up_info.fota_flag[2] = 'd';
+ up_info.update_result = status;
+ up_info.ota_run = 0;
+ lseek(fd_update_status,0,SEEK_SET);
+ write(fd_update_status, &up_info,sizeof(up_info));
+ sync();
+ close(fd_update_status);
+ mtk_device_wrap_close(fd_read);
+ mtk_device_wrap_close(fd_write);
+ lynq_fota_release_wake_lock();
+ return status;
+ }
+ mtk_device_wrap_close(fd_read);
+ mtk_device_wrap_close(fd_write);
+
+
+ }
+
+ if ((da_head.oemapp2>0) && (up_info.ota_run <= PATCH_OEMAPP2))
+ {
+
+ now_patch = PATCH_OEMAPP2;
+ delta_offset = DELTA_HEARD_SIZE + da_head.sys + da_head.boot + da_head.tee + da_head.md1img + da_head.md1dsp + da_head.vbmeta + da_head.oemapp;
+
+
+ if (up_info.ota_run == PATCH_OEMAPP2)
+ {
+ ctx.first_run = 0;
+
+ }else{
+ ctx.first_run = 1;
+ }
+
+
+
+ if(current_slot==SLOT_B) {
+ system("flash_eraseall /dev/disk/by-partlabel/oemapp2_a");
+ } else {
+ system("flash_eraseall /dev/disk/by-partlabel/oemapp2_b");
+ }
+// if(current_slot==SLOT_B) {
+ fd_oemapp2_a = mtk_device_wrap_open(DEV_OEMAPP2_A,O_RDWR);
+ if (fd_oemapp2_a < 0) {
+ err = errno;
+ LYERRLOG("+[UA]: Error opening metadata file: %s\n",strerror(errno));
+ lynq_fota_release_wake_lock();
+ return -err;
+ }
+// fd_curr = fd_oemapp2_a;
+// }else{
+ fd_oemapp2_b = mtk_device_wrap_open(DEV_OEMAPP2_B,O_RDWR);
+ if (fd_oemapp2_b < 0) {
+ err = errno;
+ LYERRLOG("+[UA]: Error opening metadata file: %s\n",strerror(errno));
+ lynq_fota_release_wake_lock();
+ return -err;
+ }
+// fd_curr = fd_oemapp2_b;
+// }
+
+ if(current_slot==SLOT_B){
+ fd_read = fd_oemapp2_b;
+ fd_write = fd_oemapp2_a;
+ } else {
+ fd_read = fd_oemapp2_a;
+ fd_write = fd_oemapp2_b;
+ }
+
+
+ fota_status.ota_run = PATCH_OEMAPP2;
+ fota_status.update_status[PATCH_OEMAPP2-1].check_delta = WAIT;
+ fota_status.update_status[PATCH_OEMAPP2-1].check_rom = WAIT;
+ fota_status.update_status[PATCH_OEMAPP2-1].update_result= WAIT;
+
+ save_fota_status();
+
+ up_info.ota_run = PATCH_OEMAPP2;
+
+ lseek(fd_update_status,0,SEEK_SET);
+ write(fd_update_status, &up_info,sizeof(up_info));
+ sync();
+
+ LYVERBLOG("+[UA]: Start upgrading oemapp2.\n");
+ status = iot_patch(&ctx);
+ LYVERBLOG("+[UA]: oemapp2 upgrade result:%d\n",status);
+
+ up_info.ota_run = 0;
+ //fota_status.ota_run = 0;
+ fota_status.update_status[PATCH_OEMAPP2-1].update_result= status;
+ fota_status.update_result= status;
+
+ if((status == 0)||(status ==1))
+ {
+
+ fota_status.update_status[PATCH_OEMAPP2-1].check_delta = PASS;
+ fota_status.update_status[PATCH_OEMAPP2-1].check_rom = PASS;
+
+ }else if(status == E_ROCK_INVALID_DELTA) {
+ fota_status.update_status[PATCH_OEMAPP2-1].check_delta = ERROR;
+ fota_status.update_status[PATCH_OEMAPP2-1].check_rom = WAIT;
+ }else if((status == E_ROCK_DELTA_MISMATCH)||(status == E_ROCK_DELTA_CHUNK_MISMATCH)) {
+ fota_status.update_status[PATCH_OEMAPP2-1].check_delta = PASS;
+ fota_status.update_status[PATCH_OEMAPP2-1].check_rom = ERROR;
+
+ }else{
+
+ //fota_status.update_status[PATCH_OEMAPP2 -1].check_delta = PASS;
+ //fota_status.update_status[PATCH_OEMAPP2 -1].check_rom = WAIT;
+ }
+
+ save_fota_status();
+
+
+ if ((status != 0) &&(status != 1))
+ {
+ up_info.fota_flag[0] = 'e';
+ up_info.fota_flag[1] = 'n';
+ up_info.fota_flag[2] = 'd';
+ up_info.update_result = status;
+ up_info.ota_run = 0;
+ lseek(fd_update_status,0,SEEK_SET);
+ write(fd_update_status, &up_info,sizeof(up_info));
+ sync();
+ close(fd_update_status);
+ mtk_device_wrap_close(fd_read);
+ mtk_device_wrap_close(fd_write);
+ lynq_fota_release_wake_lock();
+ return status;
+ }
+ mtk_device_wrap_close(fd_read);
+ mtk_device_wrap_close(fd_write);
+
+
+ }
+
if ((da_head.bl33>0) && (up_info.ota_run <= PATCH_BL33))
{
now_patch = PATCH_BL33;
- delta_offset = DELTA_HEARD_SIZE + da_head.sys + da_head.boot + da_head.tee + da_head.md1img + da_head.md1dsp + da_head.vbmeta;
+ delta_offset = DELTA_HEARD_SIZE + da_head.sys + da_head.boot + da_head.tee + da_head.md1img + da_head.md1dsp + da_head.vbmeta + da_head.oemapp + da_head.oemapp2;
if (up_info.ota_run == PATCH_BL33)
{
@@ -3265,7 +3918,7 @@
- if ((da_head.full_sys>0)|| (da_head.full_boot>0)|| (da_head.full_tee>0)||(da_head.full_md1img>0)||(da_head.full_md1dsp>0)||(da_head.full_vbmeta>0)||(da_head.full_bl33>0))
+ if ((da_head.full_sys>0)|| (da_head.full_boot>0)|| (da_head.full_tee>0)||(da_head.full_md1img>0)||(da_head.full_md1dsp>0)||(da_head.full_vbmeta>0)||(da_head.full_oemapp>0)||(da_head.full_oemapp2>0)||(da_head.full_bl33>0))
{
now_patch = 0;
@@ -3721,7 +4374,7 @@
if(da_head.full_vbmeta>0) {
- delta_offset = DELTA_HEARD_SIZE + delta_size + DELTA_FULL_HEARD_SIZE + da_head.full_sys + da_head.full_boot + da_head.full_tee + da_head.full_md1img + da_head.full_md1dsp;
+ delta_offset = DELTA_HEARD_SIZE + delta_size + DELTA_FULL_HEARD_SIZE + da_head.full_sys + da_head.full_tee + da_head.full_boot + da_head.full_md1img + da_head.full_md1dsp;
if(current_slot==SLOT_B) {
system("flash_eraseall /dev/disk/by-partlabel/vbmeta_a");
@@ -3796,7 +4449,157 @@
}
+
+ if(da_head.full_oemapp>0) {
+ delta_offset = DELTA_HEARD_SIZE + delta_size + DELTA_FULL_HEARD_SIZE + da_head.full_sys + da_head.full_tee + da_head.full_boot + da_head.full_md1img + da_head.full_md1dsp + da_head.full_vbmeta;
+
+ if(current_slot==SLOT_B) {
+ system("flash_eraseall /dev/disk/by-partlabel/oemapp_a");
+ } else {
+ system("flash_eraseall /dev/disk/by-partlabel/oemapp_b");
+ }
+
+ if(current_slot==SLOT_B) {
+ fd_oemapp_a = mtk_device_wrap_open(DEV_OEMAPP_A,O_RDWR);
+ if (fd_oemapp_a < 0) {
+ err = errno;
+ LYERRLOG("+[UA]: Error opening metadata file: %s\n",strerror(errno));
+ lynq_fota_release_wake_lock();
+ return -err;
+ }
+ fd_curr = fd_oemapp_a;
+ }else{
+ fd_oemapp_b = mtk_device_wrap_open(DEV_OEMAPP_B,O_RDWR);
+ if (fd_oemapp_b < 0) {
+ err = errno;
+ LYERRLOG("+[UA]: Error opening metadata file: %s\n",strerror(errno));
+ lynq_fota_release_wake_lock();
+ return -err;
+ }
+ fd_curr = fd_oemapp_b;
+ }
+ fota_status.ota_run = FULL_OEMAPP;
+ save_fota_status();
+ retry_cnt = 0;
+ LYVERBLOG("+[UA]: Start upgrading oemapp full.\n");
+ do {
+ status = delta_copyto_nand(delta_offset,da_head.full_oemapp);
+ ROCK_SHA_FILE_COMMON(fd_delta,delta_offset,da_head.full_oemapp,digest_s);
+ ROCK_SHA_FILE(fd_curr,0,da_head.full_oemapp,digest_t);
+ retry_cnt++;
+ }while((strncmp(digest_s,digest_t,SHA_DIGEST_SIZE)!=0)&&(retry_cnt <= 3));
+ mtk_device_wrap_close(fd_curr);
+
+ LYVERBLOG("+[UA]: oemapp full retry_cnt = %d\n",retry_cnt);
+ if (retry_cnt>3) {
+ if (status == 0) {
+ status = retry_cnt;
+ }
+ if(current_slot==SLOT_B) {
+ nand_copyto_nand(DEV_OEMAPP_B,DEV_OEMAPP_A);
+ }
+ else{
+ nand_copyto_nand(DEV_OEMAPP_A,DEV_OEMAPP_B);
+ }
+ }
+
+ LYVERBLOG("+[UA]: oemapp upgrade result:%d\n",status);
+ fota_status.update_result = status;
+ fota_status.update_status[FULL_OEMAPP-1].update_result = status;
+ save_fota_status();
+
+ if (status != 0)
+ {
+ up_info.fota_flag[0] = 'e';
+ up_info.fota_flag[1] = 'n';
+ up_info.fota_flag[2] = 'd';
+ up_info.update_result = status;
+ up_info.ota_run = 0;
+ lseek(fd_update_status,0,SEEK_SET);
+ write(fd_update_status, &up_info,sizeof(up_info));
+ sync();
+ close(fd_update_status);
+ lynq_fota_release_wake_lock();
+ return status;
+ }
+
+ }
+
+ if(da_head.full_oemapp2>0) {
+
+ delta_offset = DELTA_HEARD_SIZE + delta_size + DELTA_FULL_HEARD_SIZE + da_head.full_sys + da_head.full_tee + da_head.full_boot + da_head.full_md1img + da_head.full_md1dsp + da_head.full_vbmeta + da_head.full_oemapp;
+
+
+ if(current_slot==SLOT_B) {
+ system("flash_eraseall /dev/disk/by-partlabel/oemapp2_a");
+ } else {
+ system("flash_eraseall /dev/disk/by-partlabel/oemapp2_b");
+ }
+
+ if(current_slot==SLOT_B) {
+ fd_oemapp2_a = mtk_device_wrap_open(DEV_OEMAPP2_A,O_RDWR);
+ if (fd_oemapp2_a < 0) {
+ err = errno;
+ LYERRLOG("+[UA]: Error opening metadata file: %s\n",strerror(errno));
+ lynq_fota_release_wake_lock();
+ return -err;
+ }
+ fd_curr = fd_oemapp2_a;
+ }else{
+ fd_oemapp2_b = mtk_device_wrap_open(DEV_OEMAPP2_B,O_RDWR);
+ if (fd_oemapp2_b < 0) {
+ err = errno;
+ LYERRLOG("+[UA]: Error opening metadata file: %s\n",strerror(errno));
+ lynq_fota_release_wake_lock();
+ return -err;
+ }
+ fd_curr = fd_oemapp2_b;
+ }
+ fota_status.ota_run = FULL_OEMAPP2;
+ save_fota_status();
+ retry_cnt = 0;
+ LYVERBLOG("+[UA]: Start upgrading oemapp2 full.\n");
+ do {
+ status = delta_copyto_nand(delta_offset,da_head.full_oemapp2);
+ ROCK_SHA_FILE_COMMON(fd_delta,delta_offset,da_head.full_oemapp2,digest_s);
+ ROCK_SHA_FILE(fd_curr,0,da_head.full_oemapp2,digest_t);
+ retry_cnt++;
+ }while((strncmp(digest_s,digest_t,SHA_DIGEST_SIZE)!=0)&&(retry_cnt <= 3));
+ mtk_device_wrap_close(fd_curr);
+ LYVERBLOG("+[UA]: oemapp2 full retry_cnt = %d\n",retry_cnt);
+ if (retry_cnt>3) {
+ if (status == 0) {
+ status = retry_cnt;
+ }
+ if(current_slot==SLOT_B) {
+ nand_copyto_nand(DEV_OEMAPP2_B,DEV_OEMAPP2_A);
+ }
+ else{
+ nand_copyto_nand(DEV_OEMAPP2_A,DEV_OEMAPP2_B);
+ }
+ }
+ LYVERBLOG("+[UA]: oemapp2 upgrade result:%d\n",status);
+ fota_status.update_result = status;
+ fota_status.update_status[FULL_OEMAPP2-1].update_result = status;
+ save_fota_status();
+
+ if (status != 0)
+ {
+ up_info.fota_flag[0] = 'e';
+ up_info.fota_flag[1] = 'n';
+ up_info.fota_flag[2] = 'd';
+ up_info.update_result = status;
+ up_info.ota_run = 0;
+ lseek(fd_update_status,0,SEEK_SET);
+ write(fd_update_status, &up_info,sizeof(up_info));
+ sync();
+ close(fd_update_status);
+ lynq_fota_release_wake_lock();
+ return status;
+ }
+ }
+
if(da_head.full_bl33>0) {
}