From: Jaehoon Chung Date: Thu, 20 Jun 2024 06:53:46 +0000 (+0900) Subject: dfu: Display the information about partition X-Git-Tag: accepted/tizen/8.0/unified/20240620.153545~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=29a879395028f2a70dc249dba068b5e7f540161b;p=platform%2Fcore%2Fsystem%2Finitrd-flash.git dfu: Display the information about partition It can't know where images are flashed. To clarify the flashing image, add the information of partition. - Use only A partition info [ hal.img |==================================================] (100.0%) Download Finished (A) - Use A/B partition info [ hal.img |==================================================] (100.0%) Download Finished (AB) Also, Fix the comparison with wrong strlen value. If entry_ab is 0, it's always true. Change-Id: Iacf35366993b40ff5cedc0a47b40e80350df8e08 Signed-off-by: Jaehoon Chung --- diff --git a/src/dfu.c b/src/dfu.c index d365b8a..25dd0de 100644 --- a/src/dfu.c +++ b/src/dfu.c @@ -328,7 +328,8 @@ static void print_progress(struct dfu_entry *e, uint64_t progress) } if (total_progress == ctx->total_size) - fprintf(stdout, "\nDownload Finished\n"); + fprintf(stdout, "\nDownload Finished (%s)\n", e->is_update_ab ? "AB" : "A"); + fflush(stdout); } @@ -348,7 +349,7 @@ static void print_progress_notty(struct dfu_entry *e, uint64_t progress) } if (total_progress == ctx->total_size) - fprintf(stdout, "\nDownload Finished\n"); + fprintf(stdout, "\nDownload Finished (%s)\n", e->is_update_ab ? "AB" : "A"); } static void *dfu_thread_main(void *ptr) @@ -448,7 +449,7 @@ static int find_slot_b(struct dfu_context *ctx, char *name) { char *entry_name = ctx->dfu_entry_list[i][DFU_INFO_NAME]; char *entry_ab = ctx->dfu_entry_list[i][DFU_INFO_AB]; - if (entry_ab && strncmp(entry_ab, DFU_INFO_PART_B, strlen(entry_ab)) == 0) { + if (entry_ab && strncmp(entry_ab, DFU_INFO_PART_B, strlen(DFU_INFO_PART_B)) == 0) { if (entry_name && !strncmp(entry_name, name, strlen(entry_name))) { char **entry = ctx->dfu_entry_list[i]; switch (*entry[DFU_INFO_MODE]) { @@ -562,6 +563,11 @@ static int dfu_start_entry(struct dfu_entry *e, char **entry, uint64_t size) /* Check if there is the slot B */ e->fd_b = find_slot_b(e->ctx, entry[DFU_INFO_NAME]); + + if (e->fd_b > 0) + e->is_update_ab = 1; + else + e->is_update_ab = 0; err: free(file); diff --git a/src/dfu.h b/src/dfu.h index 7daf828..c0ed19b 100644 --- a/src/dfu.h +++ b/src/dfu.h @@ -31,6 +31,7 @@ struct dfu_entry { void *buffer; /* receive buffer for flashing */ unsigned long buf_len; /* filled size of buffer */ int transfer_done; + int is_update_ab; /* If update the image about A/B slot, it should be 1 */ }; void *dfu_get_buffer(struct dfu_entry *e, unsigned long size);