aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiaolei Li <xiaolei.li@mediatek.com>2018-04-10 15:36:57 +0800
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2018-04-10 15:39:01 +0200
commitba145d80e239fdac6414b347568c62bc2f6cb9a2 (patch)
tree1e2d4f438028f36e6cc1fe489cad12d79d5461b0
parent165f2cd9f5d63fb3b3200d2ad202cf3e4f820fc4 (diff)
misc-utils: flash_erase: Fix Jffs2 type flash erase problem
Currently, Jffs2 clean marker is not written actually, because the oob write length is set to 0 when do mtd_write(). So, get OOB available size at first, and set the correct clean marker length, then program clean marker to free OOB area. Fixes: d7e86124d55b ("mtd-utils: Support jffs2 flash-erase for large OOB (>32b)") Signed-off-by: Xiaolei Li <xiaolei.li@mediatek.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--misc-utils/flash_erase.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/misc-utils/flash_erase.c b/misc-utils/flash_erase.c
index 0c9449f..e7a00ae 100644
--- a/misc-utils/flash_erase.c
+++ b/misc-utils/flash_erase.c
@@ -92,7 +92,7 @@ int main(int argc, char *argv[])
{
libmtd_t mtd_desc;
struct mtd_dev_info mtd;
- int fd;
+ int fd, cmlen = 8;
unsigned long long start;
unsigned int eb, eb_start, eb_cnt;
bool isNAND;
@@ -190,10 +190,11 @@ int main(int argc, char *argv[])
if (jffs2) {
cleanmarker.magic = cpu_to_je16 (JFFS2_MAGIC_BITMASK);
cleanmarker.nodetype = cpu_to_je16 (JFFS2_NODETYPE_CLEANMARKER);
- if (!isNAND)
+ if (!isNAND) {
cleanmarker.totlen = cpu_to_je32(sizeof(cleanmarker));
- else {
+ } else {
cleanmarker.totlen = cpu_to_je32(8);
+ cmlen = min(mtd.oobavail, 8);
}
cleanmarker.hdr_crc = cpu_to_je32(mtd_crc32(0, &cleanmarker, sizeof(cleanmarker) - 4));
}
@@ -242,7 +243,7 @@ int main(int argc, char *argv[])
/* write cleanmarker */
if (isNAND) {
- if (mtd_write(mtd_desc, &mtd, fd, eb, 0, NULL, 0, &cleanmarker, 0,
+ if (mtd_write(mtd_desc, &mtd, fd, eb, 0, NULL, 0, &cleanmarker, cmlen,
MTD_OPS_AUTO_OOB) != 0) {
sys_errmsg("%s: MTD writeoob failure", mtd_device);
continue;