[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-arm-kernel
Subject:    [PROBLEM] Failed to write to flash
From:       Hiroki Kaminaga <kaminaga () sm ! sony ! co ! jp>
Date:       2005-09-27 5:01:54
Message-ID: 20050927.140154.115916116.kaminaga () sm ! sony ! co ! jp
[Download RAW message or body]

Hi,

I am using OMAP OSK 5912, and writing to flash sometimes do not work.
I am using kernel 2.6.13.2 + patch-2.6.13-omap1 + verify patch.
Also known to fail with 2.6.11 + patch-2.6.11-omap1.

What verify patch does is:
read the data which is just written, and do memcmp.

# at drivers/mtd/mtdblock.c:erase_write(), 
# at   ret = MTD_WRITE (mtd, pos, len, &retlen, buf);
# eventhough ret is 0, verify patch detects write failure...

Anybody with OSK give it a try?


Here is what I did on target:

/ # cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00020000 00020000 "bootloader"
mtd1: 00020000 00020000 "params"
mtd2: 00200000 00020000 "kernel"
mtd3: 01dc0000 00020000 "filesystem"
/ # dd if=/dev/zero of=/dev/mtdblock3 bs=1024 count=10240
mtdblock: verify of region [0x600000, 0x20000] on "filesystem" failed(comparison failed)
mtdblock: verify of region [0x620000, 0x20000] on "filesystem" failed(comparison failed)
mtdblock: verify of region [0x680000, 0x20000] on "filesystem" failed(comparison failed)
mtdblock: verify of region [0x6a0000, 0x20000] on "filesystem" failed(comparison failed)
mtdblock: verify of region [0x700000, 0x20000] on "filesystem" failed(comparison failed)
mtdblock: verify of region [0x720000, 0x20000] on "filesystem" failed(comparison failed)
mtdblock: verify of region [0x780000, 0x20000] on "filesystem" failed(comparison failed)
mtdblock: verify of region [0x7a0000, 0x20000] on "filesystem" failed(comparison failed)
mtdblock: verify of region [0x800000, 0x20000] on "filesystem" failed(comparison failed)
mtdblock: verify of region [0x880000, 0x20000] on "filesystem" failed(comparison failed)
mtdblock: verify of region [0x8a0000, 0x20000] on "filesystem" failed(comparison failed)
mtdblock: verify of region [0x8a0000, 0x20000] on "filesystem" failed(comparison failed)
mtdblock: verify of region [0x900000, 0x20000] on "filesystem" failed(comparison failed)
mtdblock: verify of region [0x920000, 0x20000] on "filesystem" failed(comparison failed)
mtdblock: verify of region [0x980000, 0x20000] on "filesystem" failed(comparison failed)
mtdblock: verify of region [0x9a0000, 0x20000] on "filesystem" failed(comparison failed)
10240+0 records in
10240+0 records out
/ # 


Regards,

HK.
--
["verify.patch" (Text/Plain)]

--- orig/drivers/mtd/mtdblock.c
+++ mod/drivers/mtd/mtdblock.c
@@ -52,6 +52,9 @@
 	wait_queue_head_t wait_q;
 	size_t retlen;
 	int ret;
+#if 1 //verify
+	char *rdbuf;
+#endif
 
 	/*
 	 * First, let's erase the flash block.
@@ -84,11 +87,35 @@
 	 * Next, writhe data to flash.
 	 */
 
+#if 1 //verify
+retry:
+	rdbuf = kmalloc(len, GFP_KERNEL);
+	if (!rdbuf) {
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(100);
+		goto retry;
+	}
+#endif
 	ret = MTD_WRITE (mtd, pos, len, &retlen, buf);
 	if (ret)
 		return ret;
 	if (retlen != len)
 		return -EIO;
+#if 1 //verify
+	ret = MTD_READ (mtd, pos, len, &retlen, rdbuf);
+	if (ret == 0 && retlen == len) {
+		if (memcmp(buf, rdbuf, len)) 
+			printk (KERN_INFO "mtdblock: verify of region [0x%lx, 0x%x] "
+				     "on \"%s\" failed(comparison failed)\n",
+				pos, len, mtd->name);
+	} else {
+		printk (KERN_INFO "mtdblock: verify of region [0x%lx, 0x%x] "
+			     "on \"%s\" failed(read failed)\n",
+			pos, len, mtd->name);
+	}
+
+	kfree(rdbuf);
+#endif
 	return 0;
 }
 


-------------------------------------------------------------------
List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm-kernel
FAQ:        http://www.arm.linux.org.uk/mailinglists/faq.php
Etiquette:  http://www.arm.linux.org.uk/mailinglists/etiquette.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic