static char result_folder[MAX_FILE_PATH];
static char temp_folder[MAX_FILE_PATH];
-
-static ua_part_info_t def_part_info[UA_PARTI_MAX] = {
- { "KERNEL", "boot.img/", "", 0 },
- { "ROOTFS", "rootfs.img/", "", 0 },
- { "SYSDATA", "system-data.img/", "", 0 },
- { "USER", "user.img/", "", 0 },
- { "MODULE", "modules.img/", "", 0 },
-};
-
-static ua_update_cfg_t def_update_cfg[UA_PARTI_MAX] = {
- { DELTA_FS, UA_KERNEL, 0, 0 },
- { DELTA_FS, UA_ROOTFS, 0, 0 },
- { DELTA_FS, UA_SYSDATA, 0, 0 },
- { DELTA_FS, UA_USER, 0, 0 },
- { DELTA_FS, UA_MODULE, 0, 0 },
-};
-
static ua_part_info_t s_part_info[UA_PARTI_MAX];
static ua_update_cfg_t s_update_cfg[UA_PARTI_MAX];
-static ua_update_data_t s_update_data[UA_PARTI_MAX] = {
- { 0, 0, 0, 0, 0, 0, NULL, NULL },
- { 0, 0, 0, 0, 0, 0, NULL, NULL },
- { 0, 0, 0, 0, 0, 0, NULL, NULL },
- { 0, 0, 0, 0, 0, 0, NULL, NULL },
- { 0, 0, 0, 0, 0, 0, NULL, NULL },
-};
-
-static int g_verify_error[] = {
- [UA_KERNEL] = UPI_KERNEL_VERIFY_ERROR,
- [UA_ROOTFS] = UPI_ROOTFS_VERIFY_ERROR,
- [UA_SYSDATA] = UPI_SYSDATA_VERIFY_ERROR,
- [UA_USER] = UPI_USER_VERIFY_ERROR,
- [UA_MODULE] = UPI_MODULE_VERIFY_ERROR,
-};
-
-static int g_update_error[] = {
- [UA_KERNEL] = UPI_KERNEL_UPDATE_ERROR,
- [UA_ROOTFS] = UPI_ROOTFS_UPDATE_ERROR,
- [UA_SYSDATA] = UPI_SYSDATA_UPDATE_ERROR,
- [UA_USER] = UPI_USER_UPDATE_ERROR,
- [UA_MODULE] = UPI_MODULE_UPDATE_ERROR,
-};
+static ua_update_data_t s_update_data[UA_PARTI_MAX];
static int s_part_num = 0;
static int s_initrd_version = 1;
static ua_delta_info_t s_delta_info;
+
unsigned int __log_level__ =
(LOG_DEBUG | LOG_FLASH | LOG_FILE | LOG_FUNCS | LOG_GUI | LOG_ENGINE | LOG_INFO);
FILE *__log_out_file__;
return SUCCESS;
}
-
/*-----------------------------------------------------------------------------
write_full_image
----------------------------------------------------------------------------*/
fota_gui_progress(&ua_dataSS, 100);
}
return ret;
-
}
/*-----------------------------------------------------------------------------
int verify_Delta_FS(int part_idx)
{
int ret = SUCCESS;
-
ua_dataSS_t ua_dataSS;
ua_part_info_t *ua_part_info = &s_part_info[part_idx];
ua_update_cfg_t *ua_update_cfg = &s_update_cfg[part_idx];
ua_dataSS.update_delta = ua_delta_info;
ua_dataSS.ua_operation = UI_OP_SCOUT;
ua_dataSS.ui_progress = fota_gui_progress;
+
if (ua_update_data->ua_delta_path != NULL) {
LOG("Verifying %s \n", ua_dataSS.parti_info->ua_parti_name);
ret = SS_FSVerifyPartition(&ua_dataSS, part_idx);
{
int ret = SUCCESS;
ua_dataSS_t ua_dataSS;
-
ua_part_info_t *ua_part_info = &s_part_info[part_idx];
ua_update_cfg_t *ua_update_cfg = &s_update_cfg[part_idx];
ua_update_data_t *ua_update_data = &s_update_data[part_idx];
ua_delta_info_t *ua_delta_info = &s_delta_info;
+
ua_dataSS.parti_info = ua_part_info;
ua_dataSS.update_cfg = ua_update_cfg;
ua_dataSS.update_data = ua_update_data;
ua_part_info_t *ua_part_info = &s_part_info[part_idx];
ua_update_cfg_t *ua_update_cfg = &s_update_cfg[part_idx];
ua_update_data_t *ua_update_data = &s_update_data[part_idx];
+
ua_delta_info_t *ua_delta_info = &s_delta_info;
ua_dataSS.parti_info = ua_part_info;
ua_dataSS.update_cfg = ua_update_cfg;
}
return ret;
}
-
#endif
+
/*-----------------------------------------------------------------------------
set_data_weight
----------------------------------------------------------------------------*/
for (i = 0; i < s_part_num; i++) {
for (k = 0; k < i; k++)
s_update_data[i].weight_offset += s_update_data[k].weight;
+
LOG("s_update_data[%d].weight_offset=%u\n", i, s_update_data[i].weight_offset);
}
return UP_START_NONE;
status = atoi(buf);
- if ((status > UP_START_NONE) && (status < UP_START_MAX))
+ if ((status > UP_START_NONE) && (status < s_part_num))
return status;
else
return UP_START_NONE;
int last_update_status = UP_START_NONE;
int update_status = UP_START_NONE;
int part_idx = UA_PARTI_MAX;
- int err_idx = UA_PARTI_MAX;
unsigned int update_type = 0;
unsigned long ui32Operation = UI_OP_SCOUT;
s_update_data[i].data_size = (unsigned int)item_size;
else
s_update_data[i].data_size = 0;
+
LOGL(LOG_DEBUG, "s_update_data[%d].data_size=%lu, ua_delta_path=%s, "
"ua_blk_name = %s, ua_subject_name=%s\n",
i,
total_data_size += s_update_data[i].data_size;
LOGL(LOG_DEBUG,
- "Check Delta : part_idx(%d), file_path(%s), total data cnt(%lu)\n",
- i, s_update_data[i].ua_delta_path,
- (long unsigned int)data_count);
+ "Check Delta : part_idx(%d), file_path(%s), total data cnt(%lu)\n",
+ i, s_update_data[i].ua_delta_path,
+ (long unsigned int)data_count);
}
}
if (ret != OK) {
cause = ret;
- err_idx = s_update_cfg[part_idx].part_idx;
- ret = g_verify_error[err_idx];
+ ret = UPI_VERIFY_ERROR;
LOG("%s verify fail", s_part_info[part_idx].ua_parti_name);
goto CleanUp;
}
if (ret != OK) {
cause = ret;
- err_idx = s_update_cfg[part_idx].part_idx;
- ret = g_update_error[err_idx];
+ ret = UPI_UPDATE_ERROR;
LOG("%s update fail", s_part_info[part_idx].ua_parti_name);
goto CleanUp;
}
}
/*-----------------------------------------------------------------------------
- get_part_idx
- ----------------------------------------------------------------------------*/
-int get_part_idx(char* part_name)
-{
- int i;
-
- for (i = UA_PARTI_START; i < UA_PARTI_MAX; i++) {
- if (strcmp(part_name, def_part_info[i].ua_parti_name) == 0)
- return i;
- }
-
- return UA_PARTI_MAX;
-}
-
-/*-----------------------------------------------------------------------------
fota_blkid_update
----------------------------------------------------------------------------*/
int fota_blkid_update(void)
char* part_name = NULL;
char* subj_name = NULL;
int update_type = EXTRA;
- int part_idx = UA_PARTI_MAX;
char *blk_name = NULL;
int blk_offset = 0;
int src_img_size = 0;
part_name = NULL;
subj_name = NULL;
update_type = EXTRA;
- part_idx = UA_PARTI_MAX;
blk_name = NULL;
blk_offset = 0;
src_img_size = 0;
switch (field_num) {
case 0:
part_name = strdup(field);
- part_idx = get_part_idx(field);
break;
case 1:
subj_name = strdup(field);
field = strtok_r(NULL, "\t", &ctx2);
}
LOG("\n");
+
if (!part_name)
return -1;
if (update_type != EXTRA
s_part_info[line_num].ua_blk_offset = blk_offset;
s_update_cfg[line_num].update_type = update_type;
- s_update_cfg[line_num].part_idx = part_idx;
s_update_cfg[line_num].soure_img_size = src_img_size;
s_update_cfg[line_num].target_img_size = trg_img_size;
s_update_cfg[line_num].soure_sha1 = src_img_sha1;
if (ret > 0) {
s_part_num = ret;
} else {
- LOG("Update Configuration fail. Use default.\n");
- memcpy(s_part_info, def_part_info, sizeof(s_part_info));
- memcpy(s_update_cfg, def_update_cfg, sizeof(s_update_cfg));
- s_part_num = UA_PARTI_MAX;
+ LOG("Update Configuration fail.\n");
+ ret = UPI_CONFIG_ERROR;
+ goto Results;
}
/* load block device number at run-time */
/* GUI initialized */
case UPI_VERSION_ERROR:
case UPI_DELTACOUNT_ERROR:
-
- case UPI_BOOT_VERIFY_ERROR:
- case UPI_SBOOT_VERIFY_ERROR:
- case UPI_FIXNV2_VERIFY_ERROR:
- case UPI_PARAM_VERIFY_ERROR:
- case UPI_ROOTFS_VERIFY_ERROR:
- case UPI_KERNEL_VERIFY_ERROR:
- case UPI_MODULE_VERIFY_ERROR:
- case UPI_MODEM_VERIFY_ERROR:
- case UPI_DSP_VERIFY_ERROR:
- case UPI_WCNMODEM_VERIFY_ERROR:
- case UPI_RAMDISK1_VERIFY_ERROR:
- case UPI_SYSDATA_VERIFY_ERROR:
- case UPI_USER_VERIFY_ERROR:
-
- case UPI_BOOT_UPDATE_ERROR:
- case UPI_SBOOT_UPDATE_ERROR:
- case UPI_FIXNV2_UPDATE_ERROR:
- case UPI_PARAM_UPDATE_ERROR:
- case UPI_ROOTFS_UPDATE_ERROR:
- case UPI_KERNEL_UPDATE_ERROR:
- case UPI_MODULE_UPDATE_ERROR:
- case UPI_MODEM_UPDATE_ERROR:
- case UPI_DSP_UPDATE_ERROR:
- case UPI_WCNMODEM_UPDATE_ERROR:
- case UPI_RAMDISK1_UPDATE_ERROR:
- case UPI_SYSDATA_UPDATE_ERROR:
- case UPI_USER_UPDATE_ERROR:
-
+ case UPI_VERIFY_ERROR:
+ case UPI_UPDATE_ERROR:
sleep(1);
fota_gui_update_end();
fota_path_deinit();
#define FAIL 1
#define RESTORING 2
+#define UPI_CONFIG_ERROR 0xFD9A
+
#define UPI_DELTA_PATH_ERROR 0xFDAA
#define UPI_DELTA_PATH_LENGTH_ERROR 0xFDAB
#define UPI_GUI_INIT_ERROR 0xFDBA
#define UPI_VERSION_ERROR 0xFDBB
-#define UPI_BOOT_VERIFY_ERROR 0xFDC1
-#define UPI_SBOOT_VERIFY_ERROR 0xFDC2
-#define UPI_FIXNV2_VERIFY_ERROR 0xFDC3
-#define UPI_PARAM_VERIFY_ERROR 0xFDC6
-#define UPI_ROOTFS_VERIFY_ERROR 0xFDC7
-#define UPI_KERNEL_VERIFY_ERROR 0xFDC9
-#define UPI_MODULE_VERIFY_ERROR 0xFDCA
-#define UPI_MODEM_VERIFY_ERROR 0xFDCB
-#define UPI_DSP_VERIFY_ERROR 0xFDCC
-#define UPI_WCNMODEM_VERIFY_ERROR 0xFDCD
-#define UPI_RAMDISK1_VERIFY_ERROR 0xFDCE
-#define UPI_SYSDATA_VERIFY_ERROR 0xFDCF
-#define UPI_USER_VERIFY_ERROR 0xFDD0
-
-#define UPI_BOOT_UPDATE_ERROR 0xFDD1
-#define UPI_SBOOT_UPDATE_ERROR 0xFDD2
-#define UPI_FIXNV2_UPDATE_ERROR 0xFDD3
-#define UPI_PARAM_UPDATE_ERROR 0xFDD6
-#define UPI_ROOTFS_UPDATE_ERROR 0xFDD7
-#define UPI_KERNEL_UPDATE_ERROR 0xFDD9
-#define UPI_MODULE_UPDATE_ERROR 0xFDDA
-#define UPI_MODEM_UPDATE_ERROR 0xFDDB
-#define UPI_DSP_UPDATE_ERROR 0xFDDC
-#define UPI_WCNMODEM_UPDATE_ERROR 0xFDDD
-#define UPI_RAMDISK1_UPDATE_ERROR 0xFDDE
-#define UPI_SYSDATA_UPDATE_ERROR 0xFDDF
-#define UPI_USER_UPDATE_ERROR 0xFDE0
+#define UPI_VERIFY_ERROR 0xFDC0
+#define UPI_UPDATE_ERROR 0xFDD0
#define UPI_INVALID_PARAM_ERROR 0xFDEA
#define UPI_STATUSFLAG_ERROR 0xFDEB
#define UI_OP_SCOUT_UPDATE 0
#define UI_OP_SCOUT 1
#define UI_OP_UPDATE 3
+
+#define UA_PARTI_MAX 20
+
+#define UP_STATUS_FILE "UP.STATUS"
+#define UP_START_NONE 0
+
#define SS_RECOVERYRAMDISK
enum {
UA_OP_MODE_FG = 0,
};
typedef enum {
- UA_KERNEL = 0,
- UA_ROOTFS,
- UA_SYSDATA,
- UA_USER,
- UA_MODULE,
- UA_PARTI_MAX
-} UA_PART_IDX;
-#define UA_PARTI_START 0
-
-#define UP_STATUS_FILE "UP.STATUS"
-typedef enum {
- UP_START_NONE = 0,
- UP_START_KERNEL,
- UP_START_ROOTFS,
- UP_START_SYSDATA,
- UP_START_USER,
- UP_START_MODULE,
- UP_START_MAX
-} UP_STATUS;
-
-typedef enum {
FULL_IMG,
DELTA_IMG,
DELTA_FS,
typedef struct _ua_update_cfg_t {
unsigned int update_type;
- unsigned int part_idx;
int skip_verify;
int skip_update;
int soure_img_size;//TOTA
int (*write_data_to_blkdev)(char *, int, int, char *);
} ua_dataSS_t;
void log_deinit(void);
+
#endif
static char temp_folder[MAX_FILE_PATH];
static char log_path[MAX_FILE_PATH];
-
-static ua_part_info_t def_part_info[UA_PARTI_MAX] = {
- {"ROOTFS", "delta.rootfs", "", 0},
-
- {"BOOT", "delta.boot", "", 0},
- {"RAMDISK1", "delta.ramdisk1", "", 0}
-#ifdef SS_RECOVERYRAMDISK
- , {"RAMDISK2", "delta.ramdisk2", "/dev/mmcblk0p4", 0}
-#endif
-};
-
-
-static ua_update_cfg_t def_update_cfg[UA_PARTI_MAX] = {
- {DELTA_FS, UA_ROOTFS, 0, 0},
- {DELTA_IMG, UA_BOOT, 0, 0},
- {DELTA_IMG, UA_RAMDISK1, 0, 0}
-#ifdef SS_RECOVERYRAMDISK
- , {EXTRA, UA_RAMDISK2, 0, 0}
-#endif
-};
-
static ua_part_info_t s_part_info[UA_PARTI_MAX];
static ua_update_cfg_t s_update_cfg[UA_PARTI_MAX];
-static ua_update_data_t s_update_data[UA_PARTI_MAX] = {
- {0, 0, 0, 0, 0, 0, NULL, NULL},
- {0, 0, 0, 0, 0, 0, NULL, NULL},
- {0, 0, 0, 0, 0, 0, NULL, NULL}
-#ifdef SS_RECOVERYRAMDISK
- , {0, 0, 0, 0, 0, 0, NULL, NULL}
-#endif
-};
-
-static int g_verify_error[] = {
- UPI_ROOTFS_VERIFY_ERROR,
- UPI_BOOT_VERIFY_ERROR,
- UPI_RAMDISK1_VERIFY_ERROR,
- UPI_RAMDISK2_VERIFY_ERROR
-};
-
-static int g_update_error[] = {
- UPI_ROOTFS_UPDATE_ERROR,
- UPI_BOOT_UPDATE_ERROR,
- UPI_RAMDISK1_UPDATE_ERROR,
- UPI_RAMDISK2_UPDATE_ERROR
-};
+static ua_update_data_t s_update_data[UA_PARTI_MAX];
static int s_part_num = 0;
static ua_delta_info_t s_delta_info;
return UP_START_NONE;
status = atoi(buf);
- if ((status > UP_START_NONE) && (status < UP_START_MAX))
+ if ((status > UP_START_NONE) && (status < s_part_num))
return status;
else
return UP_START_NONE;
int last_update_status = UP_START_NONE;
int update_status = UP_START_NONE;
int part_idx = UA_PARTI_MAX;
- int err_idx = UA_PARTI_MAX;
unsigned int update_type = 0;
unsigned long ui32Operation = UI_OP_SCOUT;
if (ret != OK) {
cause = ret;
- err_idx = s_update_cfg[part_idx].part_idx;
- ret = g_verify_error[err_idx];
+ ret = UPI_VERIFY_ERROR;
LOG("%s verify fail", s_part_info[part_idx].ua_parti_name);
goto CleanUp;
}
if (ret != OK) {
cause = ret;
- err_idx = s_update_cfg[part_idx].part_idx;
- ret = g_update_error[err_idx];
+ ret = UPI_UPDATE_ERROR;
LOG("%s update fail", s_part_info[part_idx].ua_parti_name);
goto CleanUp;
}
}
if (part_idx == s_part_num)
- set_last_update_status(UP_START_MAX);
+ set_last_update_status(s_part_num);
get_time_stamp();
LOG("[%s] Update End ..............................................................\n", ts);
}
/*-----------------------------------------------------------------------------
- get_part_idx
- ----------------------------------------------------------------------------*/
-int get_part_idx(char* part_name)
-{
- int i;
-
- for (i = UA_ROOTFS; i < UA_PARTI_MAX; i++) {
- if (strcmp(part_name, def_part_info[i].ua_parti_name) == 0)
- return i;
- }
-
- return UA_PARTI_MAX;
-}
-
-/*-----------------------------------------------------------------------------
fota_blkid_update
----------------------------------------------------------------------------*/
int fota_blkid_update(void)
char* part_name = NULL;
char* subj_name = NULL;
int update_type = EXTRA;
- int part_idx = UA_PARTI_MAX;
char *blk_name = NULL;
int blk_offset = 0;
int src_img_size = 0;
part_name = NULL;
subj_name = NULL;
update_type = EXTRA;
- part_idx = UA_PARTI_MAX;
blk_name = NULL;
blk_offset = 0;
src_img_size = 0;
switch (field_num) {
case 0:
part_name = strdup(field);
- part_idx = get_part_idx(field);
break;
case 1:
subj_name = strdup(field);
s_part_info[line_num].ua_blk_offset = blk_offset;
s_update_cfg[line_num].update_type = update_type;
- s_update_cfg[line_num].part_idx = part_idx;
s_update_cfg[line_num].soure_img_size = src_img_size;
s_update_cfg[line_num].target_img_size = trg_img_size;
s_update_cfg[line_num].soure_sha1 = src_img_sha1;
if (ret > 0) {
s_part_num = ret;
} else {
- LOG("Update Configuration fail. Use default.\n");
- memcpy(s_part_info, def_part_info, sizeof(s_part_info));
- memcpy(s_update_cfg, def_update_cfg, sizeof(s_update_cfg));
- s_part_num = UA_PARTI_MAX;
+ LOG("Update Configuration fail.\n");
+ ret = UPI_CONFIG_ERROR;
+ goto Results;
}
/* load block device number at run-time */
/* GUI initialized */
case UPI_VERSION_ERROR:
case UPI_DELTACOUNT_ERROR:
-
- case UPI_ROOTFS_VERIFY_ERROR:
- case UPI_BOOT_VERIFY_ERROR:
-
- case UPI_ROOTFS_UPDATE_ERROR:
- case UPI_BOOT_UPDATE_ERROR:
-
+ case UPI_VERIFY_ERROR:
+ case UPI_UPDATE_ERROR:
sleep(1);
fota_path_deinit();
log_deinit();