[U-Boot] [PATCH] cmd: mtd: solve bad block support in erase command

Tom Rini trini at konsulko.com
Sat Jan 25 18:08:29 CET 2020


On Fri, Sep 20, 2019 at 09:20:12AM +0200, Patrick Delaunay wrote:

> This patch modify the loop in mtd erase command to erase one by one
> the blocks in the requested area.
> 
> It solves issue on "mtd erase" command on nand with existing bad block,
> the command is interrupted on the first bad block with the trace:
> 	"Skipping bad block at 0xffffffffffffffff"
> 
> In MTD driver (nand/raw), when a bad block is present on the MTD
> device, the erase_op.fail_addr is not updated and we have the initial
> value MTD_FAIL_ADDR_UNKNOWN = (ULL)-1.
> 
> This case seems normal in nand_base.c:nand_erase_nand(),
> we have the 2 exit cases during the loop:
> 
> 1/ we have a bad block (nand_block_checkbad)
> 	instr->state = MTD_ERASE_FAILED
> 	loop interrupted (goto erase_exit)
> 
> 2/ if block erase failed (status & NAND_STATUS_FAIL)
> 	instr->state = MTD_ERASE_FAILED;
> 	instr->fail_addr =
> 				((loff_t)page << chip->page_shift);
> 	loop interrupted (goto erase_exit)
> 
> So erase_op.fail_addr can't be used if bad blocks were present
> in the erased area; we need to use mtd_erase only one block to detect
> and skip these existing bad blocks (as it is done in nand_util.c).
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay at st.com>
> Reviewed-by: Miquel Raynal <miquel.raynal at bootlin.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200125/e3cdf944/attachment.sig>


More information about the U-Boot mailing list