
On Thu, 6 Oct 2022 18:03:17 +0200 Michael Nazzareno Trimarchi michael@amarulasolutions.com wrote:
[External email]
On Thu, Oct 6, 2022 at 5:52 PM Mikhail Kshevetskiy mikhail.kshevetskiy@iopsys.eu wrote:
On Thu, 6 Oct 2022 08:56:08 +0200 Michael Nazzareno Trimarchi michael@amarulasolutions.com wrote:
[External email]
Hi
On Thu, Oct 6, 2022 at 5:15 AM mikhail.kshevetskiy@iopsys.eu wrote:
From: Mikhail Kshevetskiy mikhail.kshevetskiy@iopsys.eu
'mtd erase' command should not erase bad blocks. To force bad block erasing there is 'mtd erase.dontskipbad' command (this command sets 'scrub' flag to true in the erase_info structure). Unfortunately nand layer ignore scrub flag and try to erases bad blocks unconditionally. This is wrong.
Add checks to allow bad block erasing only if scrub flag is set.
Signed-off-by: Mikhail Kshevetskiy mikhail.kshevetskiy@iopsys.eu
drivers/mtd/nand/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/core.c b/drivers/mtd/nand/core.c index 99c29670c7..a4fb7602c9 100644 --- a/drivers/mtd/nand/core.c +++ b/drivers/mtd/nand/core.c @@ -174,7 +174,10 @@ int nanddev_mtd_erase(struct mtd_info *mtd, struct erase_info *einfo) nanddev_offs_to_pos(nand, einfo->addr + einfo->len - 1, &last); while (nanddev_pos_cmp(&pos, &last) <= 0) { schedule();
ret = nanddev_erase(nand, &pos);
if (!einfo->scrub && nanddev_isbad(nand, &pos))
The nandev_erase already check it here:
if (nanddev_isbad(nand, pos) || nanddev_isreserved(nand, pos)) {
no it does not work. see nanddev_erase() code
Let me re-formulate it. What execution path are you taking into account?
The nand are erased using the cmd/nand interface and the erase command there calls nand_erase_opts that take in account it.
spi-nand flash
cmd/mtd.c -> do_mtd_erase() -> .... -> nanddev_mtd_erase() -> nanddev_erase()
Michael
The nand is erased using the
if block is bad or reserverved, than warning is printed, than block is erased.
ret = -EIO;
else
ret = nanddev_erase(nand, &pos);
erase opt should already take in account scrub.
Please extend the problem
Michael
if (ret) { einfo->fail_addr = nanddev_pos_to_offs(nand,
&pos);
-- 2.35.1
-- Michael Nazzareno Trimarchi Co-Founder & Chief Executive Officer M. +39 347 913 2170 michael@amarulasolutions.com __________________________________
Amarula Solutions BV Joop Geesinkweg 125, 1114 AB, Amsterdam, NL T. +31 (0)85 111 9172 info@amarulasolutions.com https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.amarula...
-- Michael Nazzareno Trimarchi Co-Founder & Chief Executive Officer M. +39 347 913 2170 michael@amarulasolutions.com __________________________________
Amarula Solutions BV Joop Geesinkweg 125, 1114 AB, Amsterdam, NL T. +31 (0)85 111 9172 info@amarulasolutions.com https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.amarula...