mtd-utils flash_erase progress

Zhihao Cheng chengzhihao1 at huawei.com
Mon Jul 31 19:31:26 PDT 2023


在 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



More information about the linux-mtd mailing list