Problems in TI omap2-nand driver OMAP_ECC_BCH8_CODE_HW_DETECTION_SW mode

Gupta, Pekon pekon at
Fri May 16 00:14:21 PDT 2014

Hi Ted,

>From: Ted Juan [mailto:ted.juan at]
>Dear Pekon,
>Thanks great help.
>>>So, decode_bch() should handle both the checks implicitly:
>>>- checking for bit-flip errors by matching read_ecc[] and calc_ecc[]
>>>- filtering out "empty-pages" by comparing read_ecc[] with 0xff.
>In lib/bch.c, I don't quiet understand how to " filtering out empty-pages".
>It just check bit-flip error as below code.
>                        for (i = 0, sum = 0; i < (int)ecc_words; i++) {
>                                bch->ecc_buf[i] ^= bch->ecc_buf2[i];
>                                sum |= bch->ecc_buf[i];
>                        }
No, its not in lib/bch.c. Please refer..
*Scenario-1*: Blank pages without bit-flips
@@ drivers/mtd/nand/omap2.c: omap_calculate_ecc_bch()
			/* Add constant polynomial to remainder, so that
			 * ECC of blank pages results in 0x0 on reading back */
			for (i = 0; i < eccbytes; i++)
				ecc_calc[i] ^= bch8_polynomial[i];

Thus, blank pages are automatically filtered unless they don't have bit-flips.

*Case-2*: Blank pages with bit-flips within correctable range
This case is still not handled for BCH8_CODE_HW_DETECTION_SW scheme.
There was discussion on implementing it in generic framework, but due
to other complexities, it was not possible. [1] [2]
However, locally you may use patches in above threads and report your judgment.

>Another problem for am3505/am3517 product, we  use the new generation
>nand flash that cause more bit-flip.
>In the older omap nand flash driver, it seems it is no ability to
>correct OOB bit-flip.
>Does the latest driver support to correct OOB and Data bit-flip at the
>same time?
Correction for BCH8_CODE_HW_DETECTION_SW is handled purely
by software library (lib/bch.c). So if OOB correction is not implemented
in that, then it's not done.
However, why do you need to correct OOB bit-flips, you can just detect
them and ignore, because upper layer do not use OOB to store any user-data
(except for file-system metadata that too only JFFS2 and YFFS2 use it).
Refer [3] for discussion.

(This one may not work as-it-is with OMAP driver but it gives the concept
 so I posted [2] which works with at-least omap2 driver)

(on correcting OOB bit-flips)

with regards, pekon

More information about the linux-mtd mailing list