ECC in Nand_write_page
Thomas Gleixner
tglx at linutronix.de
Fri Jul 12 02:11:32 EDT 2002
On Thursday, 11. July 2002 12:19, Steve Tsai wrote:
> The board I used will display the message, "nand_write_ecc: Failed ECC
> write", so I try to trace the function nand_write_ecc, I found it can
> not write the ECC code into OOB sometime because the ECC in OOB are not
> set as 0xff. There are two conditions to cause the problem, one
> condition is the erase does not success, another condition is that the
> page was written before. Nand_write_page could write partial page to
> the flash. Does it cause the ECC in OOB was written and ECC can not be
> written next time. For example, nand_write_page write 100 byte the first
> time and if it want to write 412 bytes to the same page next time, it
> will fail. Does anyone have this problem?
Do you use latest CVS code ?
Which filesystem do you use ?
There's only JFFS2, which can handle the nand problem correct.
Read http://www.linux-mtd.infradead.org/tech/nand.html !
1. If an erase fails, the JFFS2 does not use this block.
2. JFFS2 writes only full pages
3. ECC is definitely not written, if you write 100 bytes
/* Calculate and write the ECC if we have enough data */
if ((col < mtd->eccsize) && (last >= mtd->eccsize)) {
nand_calculate_ecc (&this->data_buf[0], &(ecc_code[0]));
for (i = 0; i < 3; i++)
this->data_buf[(mtd->oobblock + oob_config.ecc_pos[i])] = ecc_code[i];
if (oob_config.eccvalid_pos != -1)
this->data_buf[mtd->oobblock + oob_config.eccvalid_pos] = 0xf0;
}
/* Calculate and write the second ECC if we have enough data */
if ((mtd->oobblock == 512) && (last == mtd->oobblock)) {
nand_calculate_ecc (&this->data_buf[256], &(ecc_code[3]));
for (i = 3; i < 6; i++)
this->data_buf[(mtd->oobblock + oob_config.ecc_pos[i])] = ecc_code[i];
if (oob_config.eccvalid_pos != -1)
this->data_buf[mtd->oobblock + oob_config.eccvalid_pos] &= 0x0f;
}
--
Thomas
___________________________________________
linutronix - competence in embedded & realtime linux
http://www.linutronix.de
mail: tglx at linutronix.de
More information about the linux-mtd
mailing list