diff -Naur linux-2.6.37-psp04.04.00.01/drivers/mtd/nand/omap2.c linux-2.6.37-psp04.04.00.01_new//drivers/mtd/nand/omap2.c --- linux-2.6.37-psp04.04.00.01/drivers/mtd/nand/omap2.c 2013-09-28 19:40:38.961108874 +0530 +++ linux-2.6.37-psp04.04.00.01_new//drivers/mtd/nand/omap2.c 2013-09-28 17:16:33.404925102 +0530 @@ -839,10 +839,25 @@ /* read respective ecc from oob area */ chip->cmdfunc(mtd, NAND_CMD_RNDOUT, oob_pos, page); +#if 0 if (info->ecc_opt == OMAP_ECC_BCH8_CODE_HW) chip->read_buf(mtd, oob, 13); else chip->read_buf(mtd, oob, eccbytes); +#endif +//To fix ubifs errors +/* +ti81xx: nand: fix 8-bit bch ecc scheme while reading a page +GPMC requires 13 bytes of ECC for every 512 bytes to implement +8-bit BCH scheme in the hardware. But ROM code uses 14 bytes of +ECC for every 512 bytes. So, to align our Uboot and Kernel with +the ROM code (so that the ECC layout is common throughout), +we implement 14 bytes of ECC for every 512 bytes of data and set +the 14th byte to 0 (since the GPMC requires only 13 bytes). +This patch accounts for considering 14 bytes of ECC for every +512 bytes of data (instead of 13 bytes), while reading a page. +*/ + chip->read_buf(mtd, oob, eccbytes); /* read syndrome */ chip->ecc.calculate(mtd, p, &ecc_calc[i]); @@ -858,8 +873,8 @@ for (i = 0 ; eccsteps; eccsteps--, i += eccbytes, p += eccsize) { int stat; - - if (!(chip->ops.len & 0x7ff)) { +/* Remove hard coding of 2k page size and make it generic */ +// if (!(chip->ops.len & 0x7ff)) { stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); @@ -867,7 +882,7 @@ mtd->ecc_stats.failed++; else mtd->ecc_stats.corrected += stat; - } +// } } return 0; } @@ -985,9 +1000,21 @@ bit_pos = err_loc[j] % 8; byte_pos = (BCH8_ECC_MAX - err_loc[j] - 1) / 8; - if (err_loc[j] < BCH8_ECC_MAX) - dat[byte_pos] ^= - 1 << bit_pos; +// if (err_loc[j] < BCH8_ECC_MAX) +// dat[byte_pos] ^= +// 1 << bit_pos; + if (err_loc[j] < BCH8_ECC_MAX) { + /* + * Check bit flip error reported in data + * area, if yes correct bit flip, else + * bit flip in OOB area. + */ + if (byte_pos < 512) + dat[byte_pos] ^= 1 << bit_pos; + else + read_ecc[byte_pos - 512] ^= + 1 << bit_pos; + } /* else, not interested to correct ecc */ } diff -Naur linux-2.6.37-psp04.04.00.01/fs/ubifs/sb.c linux-2.6.37-psp04.04.00.01_new//fs/ubifs/sb.c --- linux-2.6.37-psp04.04.00.01/fs/ubifs/sb.c 2013-09-28 19:38:58.889106747 +0530 +++ linux-2.6.37-psp04.04.00.01_new//fs/ubifs/sb.c 2013-09-28 17:07:41.488913796 +0530 @@ -714,9 +714,15 @@ goto out; lnum = ubifs_next_log_lnum(c, lnum); } - +// fix a bug in empty space fixup /* Fixup the current log head */ - err = fixup_leb(c, c->lhead_lnum, c->lhead_offs); +// err = fixup_leb(c, c->lhead_lnum, c->lhead_offs); + /* + * Fixup the log head which contains the only a CS node at the + * beginning. + */ + err = fixup_leb(c, c->lhead_lnum, + ALIGN(UBIFS_CS_NODE_SZ, c->min_io_size)); if (err) goto out;