[PATCH v2 1/3] cmd: mtd: add logs when bad blocks are encountered

Quentin Schulz quentin.schulz at cherry.de
Mon Jan 12 14:35:28 CET 2026


Hi Peter,

On 1/12/26 10:09 AM, Peter Suti wrote:
> [You don't often get email from peter.suti at streamunlimited.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> 

We generally do not like having commits with empty commit logs. What 
made you want to write this patch? Why should we take this in?

> Signed-off-by: Peter Suti <peter.suti at streamunlimited.com>
> ---
>   cmd/mtd.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/cmd/mtd.c b/cmd/mtd.c
> index 7f25144098b..32733e8f11f 100644
> --- a/cmd/mtd.c
> +++ b/cmd/mtd.c
> @@ -559,8 +559,10 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc,
> 
>          /* Search for the first good block after the given offset */
>          off = start_off;
> -       while (mtd_block_isbad(mtd, off))
> +       while (mtd_block_isbad(mtd, off)) {
> +               printf("Bad block: failed to read at offset 0x%llx, skipping.\n", off);

I'm not verse in flashes... do we know if a block is a bad block by 
reading it?

Because the code you're looking at can be reached by mtd read, mtd write 
or mtd dump, so maybe we shouldn't say "read" in the error message?

Finally, is this something we should be printing in the command? What 
about the other users (env/mtd.c, dfu, the onenand command). Should we 
rather print (using the logger even maybe?) in the MTD core? Also, 
should we print even if this is not critical? I assume skipping bad 
blocks isn't always an issue?

Cheers,
Quentin


More information about the U-Boot mailing list