[PATCH 1/2] cmd: mtd: fix read failure on default full partition read with bad blocks
Peter Suti
peter.suti at streamunlimited.com
Mon Jan 12 09:36:33 CET 2026
Hi Michael,
Thanks for the review!
On 12/20/25 09:39, Michael Nazzareno Trimarchi wrote:
>> diff --git a/cmd/mtd.c b/cmd/mtd.c
>> index 7f25144098b..1d1845bce44 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);
>> off += mtd->erasesize;
>> + }
> Would like to avoid adding more debug stuff or printing here.
Sure, I'll send it as a separate patch in V2 with the other debug
commit, then upstream can decide if it's worth taking or not.
>> + remaining = 0;
>> + ret = CMD_RET_SUCCESS;
> What is the drawback to failing here, I mean you can still verify the
> integrity. GIve a script example
> where this is needed in the commit message
This behavior is similar to the raw `nand` command which adjusts the
size of the read with adjust_size_for_badblocks().
It is explained in the cover letter.
>
>> + break;
>> + }
>> +
>> /* Skip the block if it is bad */
>> if (mtd_is_aligned_with_block_size(mtd, off) &&
>> mtd_block_isbad(mtd, off)) {
>> + printf("Bad block: failed to read at offset 0x%llx, skipping.\n", off);
>> off += mtd->erasesize;
> This is an extra print for now, you can propose it on a separated patch
>
I'll send it as a separate patch with the other debug commit.
Best regards,
Peter
More information about the U-Boot
mailing list