Mount failed after clean mount & umount test

Jarkko Lavinen jarkko.lavinen at nokia.com
Wed Jan 25 06:57:21 EST 2006


Hello Kyungmin

Your problem might be the same OOB free region problem I met a month 
ago.

(Before EBH) JFFS2 tried to write 8-byte cleanmarker node into the first free region
at OOB. If you had less than 8 byes, you could cut the length into 4 bytes. Then
cleanmarker contained just JFFS2 magic and nodetype.

OneNAND has free byte regions of 2 and 3 bytes.  One cannot fit the
magic and nodetype together into either of them alone.

Currently the 3 byte regions seem also unusable since writing into them 
has a side effect of changing spare area HW ECC bytes from 0xFF to something 
else. As a result jffs2_check_oob_empty() will fail, since there are non 
0xFF bytes outside the cleanmarker area.

I am myself using only 2 byte free regions where one can write without
changingh any other bytes and jffs2_check_oob_empty() works.  I have 
to also use separate patch for wbuf.c to make it able to write and read 
cleanmarker from multiple 2 byte fragments.

I am using at onenand_oob_64:
        .oobfree	= {
  		{14, 2}, {30, 2}, {46, 2}, {62, 2},
        }

Alternatively one could teach MTD to understand HW ECC bytes and
separate which ECC bytes are for main area and which for spare area.


Below is also a oob write verify which I used to make sure the clean
marker/EBH is written correctly.

Jarkko

---

Index: drivers/mtd/onenand/onenand_base.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/onenand/onenand_base.c,v
retrieving revision 1.15
diff -u -b -B -p -r1.15 onenand_base.c
--- drivers/mtd/onenand/onenand_base.c	20 Jan 2006 15:29:28 -0000	1.15
+++ drivers/mtd/onenand/onenand_base.c	23 Jan 2006 11:20:19 -0000
@@ -761,6 +761,36 @@ out:
 
 #ifdef CONFIG_MTD_ONENAND_VERIFY_WRITE
 /**
+ * onenand_verify_oob - [GENERIC] verify the oob contents after a write
+ * @param mtd		MTD device structure
+ * @param buf		the databuffer to verify
+ * @param to		offset to read from
+ * @param len		number of bytes to read and compare
+ *
+ */
+static int onenand_verify_oob(struct mtd_info *mtd, const u_char *buf, loff_t to, int len)
+{
+	struct onenand_chip *this = mtd->priv;
+	char *readp = this->page_buf;
+	int column = to & (mtd->oobsize - 1);
+	int status, i;
+
+	this->command(mtd, ONENAND_CMD_READOOB, to, mtd->oobsize);
+	onenand_update_bufferram(mtd, to, 0);
+	status = this->wait(mtd, FL_READING);
+	if (status)
+		return status;
+		
+	this->read_bufferram(mtd, ONENAND_SPARERAM, readp, column, len);
+	
+	for(i = 0; i < len; i++)
+		if (buf[i] != 0xFF && buf[i] != readp[i])
+			return -EBADMSG;
+	
+	return 0;
+}
+
+/**
  * onenand_verify_page - [GENERIC] verify the chip contents after a write
  * @param mtd		MTD device structure
  * @param buf		the databuffer to verify
@@ -792,6 +822,7 @@ static int onenand_verify_page(struct mt
 }
 #else
 #define onenand_verify_page(...)	(0)
+#define onenand_verify_oob(...)         (0)
 #endif
 
 #define NOTALIGNED(x)	((x & (mtd->oobblock - 1)) != 0)
@@ -911,7 +942,7 @@ static int onenand_write_oob(struct mtd_
 	size_t *retlen, const u_char *buf)
 {
 	struct onenand_chip *this = mtd->priv;
-	int column, status;
+	int column, ret = 0;
 	int written = 0;
 
 	DEBUG(MTD_DEBUG_LEVEL3, "onenand_write_oob: to = 0x%08x, len = %i\n", (unsigned int) to, (int) len);
@@ -943,9 +974,17 @@ static int onenand_write_oob(struct mtd_
 
 		onenand_update_bufferram(mtd, to, 0);
 
-		status = this->wait(mtd, FL_WRITING);
-		if (status)
+		ret = this->wait(mtd, FL_WRITING);
+		if (ret) {
+			DEBUG(MTD_DEBUG_LEVEL0, "onenand_write_oob: write filaed %d\n", ret);
 			goto out;
+		}
+
+		ret = onenand_verify_oob(mtd, buf, to, thislen);
+		if (ret) {
+			DEBUG(MTD_DEBUG_LEVEL0, "onenand_write_oob: verify failed %d\n", ret);
+			goto out;
+		}
 
 		written += thislen;
 
@@ -962,7 +1001,7 @@ out:
 
 	*retlen = written;
 
-	return 0;
+	return ret;
 }
 
 /**





More information about the linux-mtd mailing list