On Fri, Apr 10, 2009 at 10:06 PM, Michael Trimarchi <trimar...@gandalf.sssup.it> wrote: > Dmitry Kurochkin wrote: >> >> Hello. >> >> I have found the problem. The error was because we check if the >> current block is bad or the next one is bad. And skip the current >> block even if only the next one is bad. This way we skip good block >> before a bad one. >> >> Attached is a patch to fix it. Besides I have removed 4 bad block >> count limit. Instead I check if we read till the end of nand. Or at >> least this is what this code supposed to do: >> >> if (start_block512 >> 2 > BAD_BLOCK_OFFSET) >> /* end of NAND */ >> return -1; >> >> I am not sure this is the best and/or correct way to do the stop check. >> >> A similar check for bad block ahead the current one was added to >> u-boot in commit 4ec60973cf2e028de905f6ea1f81ef99ca60d834 by Michael: >> >> Change the skip bad block. Avoid false positives by only checking >> the beginning of a block and check the second page >> > > It's mine, but I don't know why Andy don't patch qi too.
U-Boot code is similar to qi but has some differences. In U-boot nand_read_ll works with bytes while in Qi it works with 512-bytes block. In U-Boot we check if a NAND block (64*2048) is bad. While in qi the bad check is done for each page (2048). So checking one page ahead the current one work in U-Boot since the check itself is done only in the beginning of a block. But in qi checking one page ahead leads to a false bad for page before bad. My guess is that Qi check was wrongly copied from U-Boot. Now I am pretty confident in my fix except for the stop condition part. And tests confirm that. It would be nice if someone review the patch and commit it. Regards, Dmitry > Michael >> >> Qi code does the same thing. But it seems to be wrong at least in my case. >> >> Regards, >> Dmitry >> > >