diff --git a/common/ubiformat.c b/common/ubiformat.c index aaa1f5d..0f05f09 100644 --- a/common/ubiformat.c +++ b/common/ubiformat.c @@ -190,6 +190,7 @@ int fd, img_ebs, eb, written_ebs = 0, ret = -1, eb_cnt; off_t st_size; char *buf = NULL; + uint64_t lastprint = 0; eb_cnt = mtd_num_pebs(mtd); @@ -229,8 +230,12 @@ long long ec; if (!args->quiet && !args->verbose) { - printf("\rubiformat: flashing eraseblock %d -- %2u %% complete ", - eb, (eb + 1) * 100 / eb_cnt); + if (is_timeout(lastprint, 300 * MSECOND) || + eb == eb_cnt - 1) { + printf("\rubiformat: flashing eraseblock %d -- %2u %% complete ", + eb, (eb + 1) * 100 / eb_cnt); + lastprint = get_time_ns(); + } } if (si->ec[eb] == EB_BAD) @@ -325,6 +330,7 @@ struct ubi_vtbl_record *vtbl; int eb1 = -1, eb2 = -1; long long ec1 = -1, ec2 = -1; + uint64_t lastprint = 0; eb_cnt = mtd_num_pebs(mtd); @@ -340,8 +346,12 @@ long long ec; if (!args->quiet && !args->verbose) { - printf("\rubiformat: formatting eraseblock %d -- %2u %% complete ", - eb, (eb + 1 - start_eb) * 100 / (eb_cnt - start_eb)); + if (is_timeout(lastprint, 300 * MSECOND) || + eb == eb_cnt - 1) { + printf("\rubiformat: formatting eraseblock %d -- %2u %% complete ", + eb, (eb + 1 - start_eb) * 100 / (eb_cnt - start_eb)); + lastprint = get_time_ns(); + } } if (si->ec[eb] == EB_BAD) diff --git a/lib/libscan.c b/lib/libscan.c index 74a24b5..c4139e6 100644 --- a/lib/libscan.c +++ b/lib/libscan.c @@ -39,6 +39,7 @@ int eb, v = (verbose == 2), pr = (verbose == 1), eb_cnt; struct ubi_scan_info *si; unsigned long long sum = 0; + uint64_t lastprint = 0; eb_cnt = mtd_div_by_eb(mtd->size, mtd); @@ -66,8 +67,12 @@ if (v) normsg_cont("scanning eraseblock %d", eb); if (pr) { - printf("\r" PROGRAM_NAME ": scanning eraseblock %d -- %2u %% complete ", - eb, (eb + 1) * 100 / eb_cnt); + if (is_timeout(lastprint, 300 * MSECOND) || + eb == eb_cnt - 1) { + printf("\r" PROGRAM_NAME ": scanning eraseblock %d -- %2u %% complete ", + eb, (eb + 1) * 100 / eb_cnt); + lastprint = get_time_ns(); + } } ret = mtd_peb_is_bad(mtd, eb);