[PATCH for mtd-utils] flash_erase: check the nand type
Huang Shijie
b32955 at freescale.com
Wed Oct 23 23:06:06 PDT 2013
Now, the MTD_NANDFLASH stands for SLC nand, and the MTD_MLCNANDFLASH
stands for the MLC nand.
This patch checks the right nand type for the MLC and SLC nand.
And if it is a MLC nand, we do not write cleanmarker for it, only print
out a message to warn the user.
Signed-off-by: Huang Shijie <b32955 at freescale.com>
---
flash_erase.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/flash_erase.c b/flash_erase.c
index 1421cf9..dd75334 100644
--- a/flash_erase.c
+++ b/flash_erase.c
@@ -184,7 +184,8 @@ int main(int argc, char *argv[])
eb_start = start / mtd.eb_size;
- isNAND = mtd.type == MTD_NANDFLASH ? 1 : 0;
+ isNAND = (mtd.type == MTD_NANDFLASH || mtd.type == MTD_MLCNANDFLASH)
+ ? 1 : 0;
if (jffs2) {
cleanmarker.magic = cpu_to_je16 (JFFS2_MAGIC_BITMASK);
@@ -272,6 +273,12 @@ int main(int argc, char *argv[])
/* write cleanmarker */
if (isNAND) {
+ if (mtd.type == MTD_MLCNANDFLASH) {
+ sys_errmsg("%s: we can't write the cleanmarker "
+ "for the MLC nand.", mtd_device);
+ continue;
+ }
+
if (mtd_write_oob(mtd_desc, &mtd, fd, (uint64_t)offset + clmpos, clmlen, &cleanmarker) != 0) {
sys_errmsg("%s: MTD writeoob failure", mtd_device);
continue;
--
1.7.2.rc3
More information about the linux-mtd
mailing list