OneNAND: Update OOB free table
Hi Timo Teras,
Yes, The OneNAND Spec. says these bytes are manged by internal ecc logic.
Acutually it means that when we write some data in this area. The ecc logic generates the ecc bytes automatically. So even though we write 3 bytes. the OneNAND is written by 5 bytes (3 data bytes, 2 space ecc bytes).
I think we consider the whole spare area. if we don't use this area. we only have 8 bytes of 64 bytes in spare area. If it makes misbehavior of JFFS2, we have alternative method turn off ecc logic when write oob area.
% original
OOB Data: ff ff 85 19 03 ff ff ff ff ff ff 30 ff ff ff ff
% after patch
OOB Data: ff ff 85 19 03 ff ff ff ff ff ff ff ff ff ff ff
Pleaes test this patch
Thank you,
Kyungmin Park
--
Index: drivers/mtd/onenand/onenand_base.c
===================================================================
RCS file: /cvsroot/linux-2.6.18-omap/drivers/mtd/onenand/onenand_base.c,v retrieving revision 1.2
mtd/onenand/onenand_base.c +7 -0
@@ -924,6 +924,7 @@ static int onenand_do_write_oob(struct mstruct onenand_chip *this = mtd->priv;int column, ret =0 ;int written =0 ; +int syscfg;DEBUG (MTD_DEBUG_LEVEL3 ,"onenand_write_oob: to = 0x%08x, len = %i\n" , (unsigned int ) to, (int ) len);
@@ -939,6 +940,10 @@ static int onenand_do_write_oob(struct m/* Grab the lock and see if the device is available */ onenand_get_device (mtd,FL_WRITING ); +/* Turn off the ECC logic for spare area */ + syscfg = this->read_word (this->base +ONENAND_REG_SYS_CFG1 ); + this->write_word (syscfg |ONENAND_SYS_CFG1_NO_ECC , this->base +ONENAND_REG_SYS_CFG1 ); +/* Loop until all data write */ while (written < len) {int thislen =min_t (int, mtd->oobsize, len - written);
@@ -979,6 +984,8 @@ static int onenand_do_write_oob(struct m } out: +/* Restore previous settings */ + this->write_word (syscfg, this->base +ONENAND_REG_SYS_CFG1 );/* Deselect and wake up anyone waiting on the device */ onenand_release_device (mtd);
------- Original Message -------
Sender : Timo Teras<[email protected]>
Date : Dec 07, 2006 19:13
Title : [PATCH] OneNAND: Update OOB free table
Do not use bytes managed by OneNAND ECC logic for Logical Sector Number data.
---
The OneNAND specification says that the three bytes at offsets 2, 18, 34 and 50 are managed by internal ecc logic. The effect is obvious as modifying these bytes, it also modifies ECC code for spare area.
Hi,
Quoted 6 lines · Kyungmin Park
Yes, The OneNAND Spec. says these bytes are manged by internal ecc logic.
Acutually it means that when we write some data in this area. The ecc logic generates the ecc bytes automatically. So even though we write 3 bytes. the OneNAND is written by 5 bytes (3 data bytes, 2 space ecc bytes).I think we consider the whole spare area. if we don't use this area. we only have 8 bytes of 64 bytes in spare area. If it makes misbehavior of JFFS2, we have alternative method turn off ecc logic when write oob area.
Yes. The original problem was that when we wrote JFFS2 clean marker, the ECC bytes changed which caused JFFS2 code to think the block unclean effectively considering all clean and empty blocks as dirty at each boot.
Quoted 9 lines
% original
OOB Data: ff ff 85 19 03 ff ff ff ff ff ff 30 ff ff ff ff
% after patch
OOB Data: ff ff 85 19 03 ff ff ff ff ff ff ff ff ff ff ff
Pleaes test this patch
I suppose this fixes the JFFS2 problem as well. 8 bytes of OOB data in a page should be enough, but having more free OOB space is always a good thing.
Cheers,
Timo
Quoted 6 lines · Kyungmin Park
I think we consider the whole spare area. if we don't use this area. we only have 8 bytes of 64 bytes in spare area. If it makes misbehavior of JFFS2, we have alternative method turn off ecc logic when write oob area.
% original
Quoted 7 lines
OOB Data: ff ff 85 19 03 ff ff ff ff ff ff 30 ff ff ff ff
% after patch
OOB Data: ff ff 85 19 03 ff ff ff ff ff ff ff ff ff ff ff
Pleaes test this patch
Tested. This breaks reading OOB area and the clean marker from there. After OOB has been written without ECC it must be read without ECC too or we start to get ECC errors.
Cheers,
Timo