dfu: Display the information about partition 23/313223/1
authorJaehoon Chung <jh80.chung@samsung.com>
Thu, 20 Jun 2024 06:53:46 +0000 (15:53 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Thu, 20 Jun 2024 07:00:03 +0000 (16:00 +0900)
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: Ia8a7e6b3800726a9d496224940adcfa831e0f50e
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
src/dfu.c
src/dfu.h

index d365b8ad0392a78c1e611e5a5f94c39c1168fbc9..25dd0de7944d8e51b4bad63be2b81a41a76219d3 100644 (file)
--- 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);
 
index 7daf8286096870b351309ce5cb32df52ccd1894e..c0ed19be806c0ec88cfa628e07322384df7dfad7 100644 (file)
--- 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);