Message ID | CAKj80Vd-DPPfSmZCeXd4OV9nqETYW7RNw-02fd33Yh+xQ2ucvA@mail.gmail.com |
---|---|
State | New |
Headers | show |
Series | mtd-utils flash_erase progress | expand |
在 2023/7/31 22:36, Eric Kenny 写道: > There seems to be a problem with flash_erase in that it does not > update progress. I believe this patch fixes it: > > diff --git a/misc-utils/flash_erase.c b/misc-utils/flash_erase.c > index 49a880f..8cdefaf 100644 > --- a/misc-utils/flash_erase.c > +++ b/misc-utils/flash_erase.c > @@ -53,8 +53,10 @@ int target_endian = __BYTE_ORDER; > > static void show_progress(off_t start, int eb, int eb_start, int > eb_cnt, int step) > { > - bareverbose(!quiet, "\rErasing %d Kibyte @ %llx -- %2i %% complete ", > - step / 1024, (unsigned long long)start, ((eb - > eb_start) * 100) / eb_cnt); > + printf("\rErasing %d Kibyte @ %"PRIxoff_t" -- %2.0f %% complete ", > + mtd->eb_size / 1024, > + (unsigned long long)start + (eb * mtd->eb_size), > + ((float)(eb - eb_start)*100 / eb_cnt)); > fflush(stdout); > } > The flash_erase tool will display progress in default, unless user adds '-q' or '--silent'. BTW, I can't apply the patch: git apply mtd-utils-flash_erase-progress.patch error: corrupt patch at line 159
On Tue, 2023-08-01 at 10:31 +0800, Zhihao Cheng wrote: > > The flash_erase tool will display progress in default, unless user > adds > '-q' or '--silent'. > > BTW, I can't apply the patch: > git apply mtd-utils-flash_erase-progress.patch > error: corrupt patch at line 159 > Apologies. What I would like to propose is that when erasing the full chip with mtd_erase_multi, flash_erase should not pretend that it is going to give progress updates. It makes it appear that it isn't functioning correctly. Suggested patch: diff --git a/misc-utils/flash_erase.c b/misc-utils/flash_erase.c index 49a880f..192d1b6 100644 --- a/misc-utils/flash_erase.c +++ b/misc-utils/flash_erase.c @@ -236,7 +236,6 @@ int main(int argc, char *argv[]) erase_chip = false; if (erase_chip) { - show_progress(0, eb_start, eb_start, eb_cnt, mtd.size); if (unlock) { if (mtd_unlock_multi(&mtd, fd, eb_start, eb_cnt) != 0) { @@ -254,9 +253,6 @@ int main(int argc, char *argv[]) goto erase_each_sector; } - show_progress(0, eb_start + eb_cnt, eb_start, - eb_cnt, mtd.size); - if (!jffs2) goto out;
diff --git a/misc-utils/flash_erase.c b/misc-utils/flash_erase.c index 49a880f..8cdefaf 100644 --- a/misc-utils/flash_erase.c +++ b/misc-utils/flash_erase.c @@ -53,8 +53,10 @@ int target_endian = __BYTE_ORDER; static void show_progress(off_t start, int eb, int eb_start, int eb_cnt, int step) { - bareverbose(!quiet, "\rErasing %d Kibyte @ %llx -- %2i %% complete ", - step / 1024, (unsigned long long)start, ((eb - eb_start) * 100) / eb_cnt); + printf("\rErasing %d Kibyte @ %"PRIxoff_t" -- %2.0f %% complete ", + mtd->eb_size / 1024, + (unsigned long long)start + (eb * mtd->eb_size), + ((float)(eb - eb_start)*100 / eb_cnt)); fflush(stdout);