summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/mtd
diff options
context:
space:
mode:
authorChunrong Guo <b40290@freescale.com>2012-12-06 00:27:37 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-12-11 15:54:26 +0000
commitc8e3fe46df84e782cc1becc4c5a8cd954ef85f34 (patch)
treecc8854afb54f8451fee7d80fd1bad0a2a45e3101 /meta/recipes-devtools/mtd
parent4f891901bcf7be95cebca1a7296e7ea656adee74 (diff)
downloadopenembedded-core-c8e3fe46df84e782cc1becc4c5a8cd954ef85f34.tar.gz
openembedded-core-c8e3fe46df84e782cc1becc4c5a8cd954ef85f34.tar.bz2
openembedded-core-c8e3fe46df84e782cc1becc4c5a8cd954ef85f34.zip
mtd-utils:fix corrupt cleanmarker with flash_erase -j command
*Flash_erase -j should fill discrete freeoob areas with required bytes of JFFS2 cleanmarker in jffs2_check_nand_cleanmarker(). Not just fill the first freeoob area. Signed-off-by: Chunrong Guo <b40290@freescale.com> Signed-off-by: Saul Wold <sgw@linux.intel.com>
Diffstat (limited to 'meta/recipes-devtools/mtd')
-rw-r--r--meta/recipes-devtools/mtd/mtd-utils-1.5.0/mtd-utils-fix-corrupt-cleanmarker-with-flash_erase--j-command.patch133
-rw-r--r--meta/recipes-devtools/mtd/mtd-utils_1.5.0.bb5
2 files changed, 136 insertions, 2 deletions
diff --git a/meta/recipes-devtools/mtd/mtd-utils-1.5.0/mtd-utils-fix-corrupt-cleanmarker-with-flash_erase--j-command.patch b/meta/recipes-devtools/mtd/mtd-utils-1.5.0/mtd-utils-fix-corrupt-cleanmarker-with-flash_erase--j-command.patch
new file mode 100644
index 0000000000..a66087e301
--- /dev/null
+++ b/meta/recipes-devtools/mtd/mtd-utils-1.5.0/mtd-utils-fix-corrupt-cleanmarker-with-flash_erase--j-command.patch
@@ -0,0 +1,133 @@
+Upstream-Status: Pending
+From patchwork Mon Aug 8 08:16:43 2011
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: mtd-utils: fix corrupt cleanmarker with flash_erase -j command
+Date: Sun, 07 Aug 2011 22:16:43 -0000
+From: b35362@freescale.com
+X-Patchwork-Id: 108873
+Message-Id: <1312791403-13473-1-git-send-email-b35362@freescale.com>
+To: <dwmw2@infradead.org>
+Cc: Liu Shuo <b35362@freescale.com>, Artem.Bityutskiy@nokia.com,
+ Li Yang <leoli@freescale.com>, linux-mtd@lists.infradead.org
+
+From: Liu Shuo <b35362@freescale.com>
+
+Flash_erase -j should fill discrete freeoob areas with required bytes
+of JFFS2 cleanmarker in jffs2_check_nand_cleanmarker(). Not just fill
+the first freeoob area.
+
+The below is the result without this workaround:
+
+JFFS2: Erase block at 0x00000000 is not formatted. It will be erased
+JFFS2: Erase block at 0x00004000 is not formatted. It will be erased
+JFFS2: Erase block at 0x00008000 is not formatted. It will be erased
+JFFS2: Erase block at 0x0000c000 is not formatted. It will be erased
+JFFS2: Erase block at 0x00010000 is not formatted. It will be erased
+JFFS2: Erase block at 0x00014000 is not formatted. It will be erased
+JFFS2: Erase block at 0x00018000 is not formatted. It will be erased
+JFFS2: Erase block at 0x0001c000 is not formatted. It will be erased
+JFFS2: Erase block at 0x00020000 is not formatted. It will be erased
+JFFS2: Erase block at 0x00024000 is not formatted. It will be erased
+JFFS2: Erase block at 0x00028000 is not formatted. It will be erased
+...
+
+Signed-off-by: Liu Shuo <b35362@freescale.com>
+Signed-off-by: Li Yang <leoli@freescale.com>
+
+---
+v2 : get length of availble freeoob bytes from oobinfo information,
+ not use the ioctl ECCGETLAYOUT which is being deprecated.
+
+ flash_erase.c | 46 +++++++++++++++++++++++++++++++++++++++-------
+ 1 files changed, 39 insertions(+), 7 deletions(-)
+
+diff --git a/flash_erase.c b/flash_erase.c
+index fe2eaca..3e94495 100644
+--- a/flash_erase.c
++++ b/flash_erase.c
+@@ -98,6 +98,7 @@ int main(int argc, char *argv[])
+ int isNAND;
+ int error = 0;
+ uint64_t offset = 0;
++ void *oob_data = NULL;
+
+ /*
+ * Process user arguments
+@@ -197,15 +198,43 @@ int main(int argc, char *argv[])
+ if (ioctl(fd, MEMGETOOBSEL, &oobinfo) != 0)
+ return sys_errmsg("%s: unable to get NAND oobinfo", mtd_device);
+
++ cleanmarker.totlen = cpu_to_je32(8);
+ /* Check for autoplacement */
+ if (oobinfo.useecc == MTD_NANDECC_AUTOPLACE) {
+- /* Get the position of the free bytes */
+- if (!oobinfo.oobfree[0][1])
++ struct nand_ecclayout_user ecclayout;
++ int i, oobavail;
++
++ for (i = 0, oobavail = 0; oobinfo.oobfree[i][1]; i++)
++ oobavail += oobinfo.oobfree[i][1];
++
++ if (!oobavail)
+ return errmsg(" Eeep. Autoplacement selected and no empty space in oob");
++
++ /* Get the position of the free bytes */
+ clmpos = oobinfo.oobfree[0][0];
+- clmlen = oobinfo.oobfree[0][1];
+- if (clmlen > 8)
+- clmlen = 8;
++ clmlen = MIN(oobavail, 8);
++
++ if (oobinfo.oobfree[0][1] < 8 && oobavail >= 8) {
++ int left, n, last = 0;
++ void *cm;
++
++ oob_data = malloc(mtd.oob_size);
++ if (!oob_data)
++ return -ENOMEM;
++
++ memset(oob_data, 0xff, mtd.oob_size);
++ cm = &cleanmarker;
++ for (i = 0, left = clmlen; left ; i++) {
++ n = MIN(left, oobinfo.oobfree[i][1]);
++ memcpy(oob_data + oobinfo.oobfree[i][0],
++ cm, n);
++ left -= n;
++ cm += n;
++ last = oobinfo.oobfree[i][0] + n;
++ }
++
++ clmlen = last - clmpos;
++ }
+ } else {
+ /* Legacy mode */
+ switch (mtd.oob_size) {
+@@ -223,7 +252,6 @@ int main(int argc, char *argv[])
+ break;
+ }
+ }
+- cleanmarker.totlen = cpu_to_je32(8);
+ }
+ cleanmarker.hdr_crc = cpu_to_je32(mtd_crc32(0, &cleanmarker, sizeof(cleanmarker) - 4));
+ }
+@@ -272,7 +300,8 @@ int main(int argc, char *argv[])
+
+ /* write cleanmarker */
+ if (isNAND) {
+- if (mtd_write_oob(mtd_desc, &mtd, fd, offset + clmpos, clmlen, &cleanmarker) != 0) {
++ void *data = oob_data ? oob_data + clmpos : &cleanmarker;
++ if (mtd_write_oob(mtd_desc, &mtd, fd, offset + clmpos, clmlen, data) != 0) {
+ sys_errmsg("%s: MTD writeoob failure", mtd_device);
+ continue;
+ }
+@@ -291,5 +320,8 @@ int main(int argc, char *argv[])
+ show_progress(&mtd, offset, eb, eb_start, eb_cnt);
+ bareverbose(!quiet, "\n");
+
++ if (oob_data)
++ free(oob_data);
++
+ return 0;
+ }
diff --git a/meta/recipes-devtools/mtd/mtd-utils_1.5.0.bb b/meta/recipes-devtools/mtd/mtd-utils_1.5.0.bb
index bdfb0228c8..12ad9d4746 100644
--- a/meta/recipes-devtools/mtd/mtd-utils_1.5.0.bb
+++ b/meta/recipes-devtools/mtd/mtd-utils_1.5.0.bb
@@ -8,11 +8,12 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
SRCREV = "ca39eb1d98e736109c64ff9c1aa2a6ecca222d8f"
SRC_URI = "git://git.infradead.org/mtd-utils.git;protocol=git \
- file://add-exclusion-to-mkfs-jffs2-git-2.patch"
+ file://add-exclusion-to-mkfs-jffs2-git-2.patch \
+ file://mtd-utils-fix-corrupt-cleanmarker-with-flash_erase--j-command.patch "
S = "${WORKDIR}/git/"
-PR = "r1"
+PR = "r2"
EXTRA_OEMAKE = "'CC=${CC}' 'RANLIB=${RANLIB}' 'AR=${AR}' 'CFLAGS=${CFLAGS} -I${S}/include -DWITHOUT_XATTR' 'BUILDDIR=${S}'"