public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] mtd-utils: Support jffs2 flash-erase for large OOB (>32b)
@ 2015-08-06 18:38 Manikandan Ramachandran
  2016-09-06 15:22 ` Graham Moore
  0 siblings, 1 reply; 4+ messages in thread
From: Manikandan Ramachandran @ 2015-08-06 18:38 UTC (permalink / raw)
  To: linux-mtd

"flash_erase" fails on nand flash with JFFS2 that has OOB size greater than
32 bytes. "flash_erase" uses "MEMGETOOSEL" to determine OOB size. This ioctl
call is obsolete and returns error if OOB size is more than 32 bytes.

This patch fixes this issue by using "mtd_write" to update clean-marker
instead of mtd_oob_write. This fix is based on the discussion:
http://lists.infradead.org/pipermail/linux-mtd/2011-September/037958.html.

>From 0d12dd9eb3053d26e6a3085faf14713d29fcb4ca Mon Sep 17 00:00:00 2001
From: Manikandan <crmanik@gmail.com>
Date: Thu, 6 Aug 2015 11:21:46 -0700
Subject: [PATCH] flash_erase Support for large OOB

---
 flash_erase.c | 38 ++++----------------------------------
 1 file changed, 4 insertions(+), 34 deletions(-)

diff --git a/flash_erase.c b/flash_erase.c
index 933373a..b567173 100644
--- a/flash_erase.c
+++ b/flash_erase.c
@@ -93,7 +93,7 @@ int main(int argc, char *argv[])
 {
 	libmtd_t mtd_desc;
 	struct mtd_dev_info mtd;
-	int fd, clmpos = 0, clmlen = 8;
+	int fd;
 	unsigned long long start;
 	unsigned int eb, eb_start, eb_cnt;
 	bool isNAND;
@@ -196,37 +196,6 @@ int main(int argc, char *argv[])
 		if (!isNAND)
 			cleanmarker.totlen = cpu_to_je32(sizeof(cleanmarker));
 		else {
-			struct nand_oobinfo oobinfo;
-
-			if (ioctl(fd, MEMGETOOBSEL, &oobinfo) != 0)
-				return sys_errmsg("%s: unable to get NAND oobinfo", mtd_device);
-
-			/* Check for autoplacement */
-			if (oobinfo.useecc == MTD_NANDECC_AUTOPLACE) {
-				/* Get the position of the free bytes */
-				if (!oobinfo.oobfree[0][1])
-					return errmsg(" Eeep. Autoplacement selected and no empty space in oob");
-				clmpos = oobinfo.oobfree[0][0];
-				clmlen = oobinfo.oobfree[0][1];
-				if (clmlen > 8)
-					clmlen = 8;
-			} else {
-				/* Legacy mode */
-				switch (mtd.oob_size) {
-					case 8:
-						clmpos = 6;
-						clmlen = 2;
-						break;
-					case 16:
-						clmpos = 8;
-						clmlen = 8;
-						break;
-					case 64:
-						clmpos = 16;
-						clmlen = 8;
-						break;
-				}
-			}
 			cleanmarker.totlen = cpu_to_je32(8);
 		}
 		cleanmarker.hdr_crc = cpu_to_je32(mtd_crc32(0, &cleanmarker, sizeof(cleanmarker) - 4));
@@ -276,7 +245,8 @@ int main(int argc, char *argv[])
 
 		/* write cleanmarker */
 		if (isNAND) {
-			if (mtd_write_oob(mtd_desc, &mtd, fd, (uint64_t)offset + clmpos, clmlen, &cleanmarker) != 0) {
+			if (mtd_write(mtd_desc, &mtd, fd, eb, 0, NULL, 0, &cleanmarker, 0,
+					MTD_OPS_AUTO_OOB) != 0) {
 				sys_errmsg("%s: MTD writeoob failure", mtd_device);
 				continue;
 			}
@@ -286,7 +256,7 @@ int main(int argc, char *argv[])
 				continue;
 			}
 		}
-		verbose(!quiet, " Cleanmarker written at %"PRIxoff_t, offset);
+		verbose(!quiet, " Cleanmarker Updated.");
 	}
 	show_progress(&mtd, offset, eb, eb_start, eb_cnt);
 	bareverbose(!quiet, "\n");
-- 
2.2.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd-utils: Support jffs2 flash-erase for large OOB (>32b)
  2015-08-06 18:38 [PATCH] mtd-utils: Support jffs2 flash-erase for large OOB (>32b) Manikandan Ramachandran
@ 2016-09-06 15:22 ` Graham Moore
  2016-09-06 16:17   ` Richard Weinberger
  0 siblings, 1 reply; 4+ messages in thread
From: Graham Moore @ 2016-09-06 15:22 UTC (permalink / raw)
  To: Manikandan Ramachandran, linux-mtd

On 08/06/2015 01:38 PM, Manikandan Ramachandran wrote:
> "flash_erase" fails on nand flash with JFFS2 that has OOB size greater than
> 32 bytes. "flash_erase" uses "MEMGETOOSEL" to determine OOB size. This ioctl
> call is obsolete and returns error if OOB size is more than 32 bytes.
>
> This patch fixes this issue by using "mtd_write" to update clean-marker
> instead of mtd_oob_write. This fix is based on the discussion:
> http://lists.infradead.org/pipermail/linux-mtd/2011-September/037958.html.
>

Hi Manikandan,

I'd like to use this patch in our Angstrom/Yocto builds, but our company 
policy doesn't allow patches that aren't signed off.

I wonder if you could re-post this with your sign-off?  I'd really 
appreciate it.

Thanks!
Graham Moore

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd-utils: Support jffs2 flash-erase for large OOB (>32b)
  2016-09-06 15:22 ` Graham Moore
@ 2016-09-06 16:17   ` Richard Weinberger
  2016-09-06 18:24     ` Graham Moore
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Weinberger @ 2016-09-06 16:17 UTC (permalink / raw)
  To: Graham Moore
  Cc: Manikandan Ramachandran, linux-mtd@lists.infradead.org,
	David Oberhollenzer

On Tue, Sep 6, 2016 at 5:22 PM, Graham Moore
<grmoore@opensource.altera.com> wrote:
> On 08/06/2015 01:38 PM, Manikandan Ramachandran wrote:
>>
>> "flash_erase" fails on nand flash with JFFS2 that has OOB size greater
>> than
>> 32 bytes. "flash_erase" uses "MEMGETOOSEL" to determine OOB size. This
>> ioctl
>> call is obsolete and returns error if OOB size is more than 32 bytes.
>>
>> This patch fixes this issue by using "mtd_write" to update clean-marker
>> instead of mtd_oob_write. This fix is based on the discussion:
>> http://lists.infradead.org/pipermail/linux-mtd/2011-September/037958.html.
>>
>
> Hi Manikandan,
>
> I'd like to use this patch in our Angstrom/Yocto builds, but our company
> policy doesn't allow patches that aren't signed off.
>
> I wonder if you could re-post this with your sign-off?  I'd really
> appreciate it.

Not needed, I can do that myself.
Let's get this reviewed and merged. :-)

-- 
Thanks,
//richard

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd-utils: Support jffs2 flash-erase for large OOB (>32b)
  2016-09-06 16:17   ` Richard Weinberger
@ 2016-09-06 18:24     ` Graham Moore
  0 siblings, 0 replies; 4+ messages in thread
From: Graham Moore @ 2016-09-06 18:24 UTC (permalink / raw)
  To: Richard Weinberger
  Cc: Manikandan Ramachandran, linux-mtd@lists.infradead.org,
	David Oberhollenzer

On 09/06/2016 11:17 AM, Richard Weinberger wrote:
> On Tue, Sep 6, 2016 at 5:22 PM, Graham Moore
> <grmoore@opensource.altera.com> wrote:
>> On 08/06/2015 01:38 PM, Manikandan Ramachandran wrote:
[...]
>>
>> I wonder if you could re-post this with your sign-off?  I'd really
>> appreciate it.
>
> Not needed, I can do that myself.
> Let's get this reviewed and merged. :-)
>

Great, thanks!
Graham

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-09-06 18:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-06 18:38 [PATCH] mtd-utils: Support jffs2 flash-erase for large OOB (>32b) Manikandan Ramachandran
2016-09-06 15:22 ` Graham Moore
2016-09-06 16:17   ` Richard Weinberger
2016-09-06 18:24     ` Graham Moore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox