From a089dce83aba1aabc05d38982c321934534e695d Mon Sep 17 00:00:00 2001 From: Viswanath Kraleti Date: Wed, 12 Jun 2024 10:19:29 +0530 Subject: [PATCH] firehose: Add logs to indicate the progress of flashing Add logs to show the partition label curently being flashed and progress as a percentage of completion. Signed-off-by: Viswanath Kraleti --- firehose.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/firehose.c b/firehose.c index 01ded57..5178ac7 100644 --- a/firehose.c +++ b/firehose.c @@ -317,6 +317,7 @@ static int firehose_erase(struct qdl_device *qdl, struct program *program) xml_setpropf(node, "num_partition_sectors", "%d", program->num_sectors); xml_setpropf(node, "start_sector", "%s", program->start_sector); + fprintf(stderr, "[PROGRAM] Please wait, flashing \"%s\" now...\n", program->label); ret = firehose_write(qdl, doc); if (ret < 0) { fprintf(stderr, "[PROGRAM] failed to write program command\n"); @@ -401,6 +402,9 @@ static int firehose_program(struct qdl_device *qdl, struct program *program, int lseek(fd, (off_t) program->file_offset * program->sector_size, SEEK_SET); left = num_sectors; while (left > 0) { + fprintf(stderr, "[PROGRAM] %d sectors remaining out of %d (%.2f%%)\r", + left, num_sectors, + (float) (num_sectors - left) / num_sectors * 100.0); chunk_size = MIN(max_payload_size / program->sector_size, left); n = read(fd, buf, chunk_size * program->sector_size); @@ -420,6 +424,7 @@ static int firehose_program(struct qdl_device *qdl, struct program *program, int left -= chunk_size; } + fprintf(stderr, "\n"); t = time(NULL) - t0; ret = firehose_read(qdl, 30000, firehose_generic_parser, NULL);