OneNAND: Update OOB free table

Kyungmin Park kyungmin.park at samsung.com
Thu Dec 7 19:11:06 EST 2006


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
diff -u -p -r1.2 onenand_base.c
--- drivers/mtd/onenand/onenand_base.c	12 Oct 2006 06:59:27 -0000	1.2
+++ drivers/mtd/onenand/onenand_base.c	7 Dec 2006 23:51:01 -0000
@@ -924,6 +924,7 @@ static int onenand_do_write_oob(struct m
 	struct 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<timo.teras at solidboot.com> 
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.

Signed-off-by: Timo Teras <timo.teras at solidboot.com>
---
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.




More information about the linux-mtd mailing list