[PATCH] mtd-utils: flash_erase: Adjust jffs2 cleanmarker size for min_io_size

tkuw584924 at gmail.com tkuw584924 at gmail.com
Wed Mar 15 01:33:25 PDT 2023


From: Takahiro Kuwano <Takahiro.Kuwano at infineon.com>

JFFS2 supports buffer mode for ECC'd NOR Flash and the size of cleanmarker
is rounded up to mtd->writesize. The flash_erase utility should do the
same when it writes JFFS2 cleanmarker.

Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano at infineon.com>
---
 include/common.h         | 1 +
 misc-utils/flash_erase.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/common.h b/include/common.h
index 31b6cd1..4b9b661 100644
--- a/include/common.h
+++ b/include/common.h
@@ -46,6 +46,7 @@ extern "C" {
 #define MAX(a, b) ((a) > (b) ? (a) : (b))
 #endif
 #define min(a, b) MIN(a, b) /* glue for linux kernel source */
+#define max(a, b) MAX(a, b)
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
 
 #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
diff --git a/misc-utils/flash_erase.c b/misc-utils/flash_erase.c
index 49a880f..6ff4b93 100644
--- a/misc-utils/flash_erase.c
+++ b/misc-utils/flash_erase.c
@@ -212,7 +212,7 @@ int main(int argc, char *argv[])
 		cleanmarker.magic = cpu_to_je16 (JFFS2_MAGIC_BITMASK);
 		cleanmarker.nodetype = cpu_to_je16 (JFFS2_NODETYPE_CLEANMARKER);
 		if (!isNAND) {
-			cleanmarker.totlen = cpu_to_je32(sizeof(cleanmarker));
+			cleanmarker.totlen = cpu_to_je32(max(sizeof(cleanmarker), mtd.min_io_size));
 		} else {
 			cleanmarker.totlen = cpu_to_je32(8);
 			cmlen = min(mtd.oobavail, 8);
-- 
2.34.1




More information about the linux-mtd mailing list