diff options
author | Stefan Christ <s.christ@phytec.de> | 2015-01-27 14:14:59 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-01-28 10:14:07 +0100 |
commit | 420e4cb641f6459cf329950312b42e21dbfb2d7c (patch) | |
tree | cb296d74d575397abae4c6d8d4538e600dab2ce4 /arch | |
parent | 51eb7ddd5a1826d32d8b5a21cd6d612e8ef1fc1f (diff) | |
download | barebox-420e4cb641f6459cf329950312b42e21dbfb2d7c.tar.gz barebox-420e4cb641f6459cf329950312b42e21dbfb2d7c.tar.xz |
ARM: i.MX6: Fix bad block marker in imx6-bbu-nand handler
The i.MX6 NAND update handler sets all bytes of OOB data to 0x00 in pages that
contain the FCB structure currently. So the first and second byte which is
used as the manufacturers bad block marker is in the 'bad block' state. A scan
for factory bad blocks will detect these blocks as bad while they are still ok.
The barebox issues a scan for factory bad blocks to rebuild the bad block table
if the NAND is brand new or the last four blocks of flash are erased.
To fix this problem set the first two bytes of OOB data to 0xFF explicitly.
There is a potential chance that the bbu handler will mark a real bad block as
factory good. That's not a problem for the ROM Loader, because the FCB is
protected by a checksum and the hamming_13_8 encoding. Additionally the current
implementation of the bbu handler does not check the bad block table or the
factory bad block marker before writing the FCB at the first page of the first
and second block.
Signed-off-by: Stefan Christ <s.christ@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-imx/imx6-bbu-nand.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/arch/arm/mach-imx/imx6-bbu-nand.c b/arch/arm/mach-imx/imx6-bbu-nand.c index 1b46e514e9..2a54979fcb 100644 --- a/arch/arm/mach-imx/imx6-bbu-nand.c +++ b/arch/arm/mach-imx/imx6-bbu-nand.c @@ -437,6 +437,16 @@ static int imx6_bbu_nand_update(struct bbu_handler *handler, struct bbu_data *da fcb_create(fcb, mtd); encode_hamming_13_8(fcb, ecc, 512); + + /* + * Set the first and second byte of OOB data to 0xFF, not 0x00. These + * bytes are used as the Manufacturers Bad Block Marker (MBBM). Since + * the FCB is mostly written to the first page in a block, a scan for + * factory bad blocks will detect these blocks as bad, e.g. when + * function nand_scan_bbt() is executed to build a new bad block table. + */ + memset(fcb_raw_page + mtd->writesize, 0xFF, 2); + ret = raw_write_page(mtd, fcb_raw_page, 0); if (ret) goto out; |