Skip to content

Commit

Permalink
firehose: Add logs to indicate the progress of flashing
Browse files Browse the repository at this point in the history
Add logs to show the partition label curently being flashed and
progress as a percentage of completion.

Signed-off-by: Viswanath Kraleti <[email protected]>
  • Loading branch information
quic-vkraleti committed Jun 12, 2024
1 parent cbd4618 commit a089dce
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions firehose.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit a089dce

Please sign in to comment.