summaryrefslogtreecommitdiffstats
path: root/meta
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:37 +0000
commit74b2e40d89cb79cb58a8135bd095720c74c44681 (patch)
treec1991df9cbd6797503b0537716630a1e86c6153f /meta
parent138669057d382a4e5924933614f539431fb2ddf1 (diff)
downloadpoky-74b2e40d89cb79cb58a8135bd095720c74c44681.tar.gz
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. (From OE-Core rev: c8e3fe46df84e782cc1becc4c5a8cd954ef85f34) Signed-off-by: Chunrong Guo <b40290@freescale.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-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 @@
1Upstream-Status: Pending
2From patchwork Mon Aug 8 08:16:43 2011
3Content-Type: text/plain; charset="utf-8"
4MIME-Version: 1.0
5Content-Transfer-Encoding: 7bit
6Subject: mtd-utils: fix corrupt cleanmarker with flash_erase -j command
7Date: Sun, 07 Aug 2011 22:16:43 -0000
8From: b35362@freescale.com
9X-Patchwork-Id: 108873
10Message-Id: <1312791403-13473-1-git-send-email-b35362@freescale.com>
11To: <dwmw2@infradead.org>
12Cc: Liu Shuo <b35362@freescale.com>, Artem.Bityutskiy@nokia.com,
13 Li Yang <leoli@freescale.com>, linux-mtd@lists.infradead.org
14
15From: Liu Shuo <b35362@freescale.com>
16
17Flash_erase -j should fill discrete freeoob areas with required bytes
18of JFFS2 cleanmarker in jffs2_check_nand_cleanmarker(). Not just fill
19the first freeoob area.
20
21The below is the result without this workaround:
22
23JFFS2: Erase block at 0x00000000 is not formatted. It will be erased
24JFFS2: Erase block at 0x00004000 is not formatted. It will be erased
25JFFS2: Erase block at 0x00008000 is not formatted. It will be erased
26JFFS2: Erase block at 0x0000c000 is not formatted. It will be erased
27JFFS2: Erase block at 0x00010000 is not formatted. It will be erased
28JFFS2: Erase block at 0x00014000 is not formatted. It will be erased
29JFFS2: Erase block at 0x00018000 is not formatted. It will be erased
30JFFS2: Erase block at 0x0001c000 is not formatted. It will be erased
31JFFS2: Erase block at 0x00020000 is not formatted. It will be erased
32JFFS2: Erase block at 0x00024000 is not formatted. It will be erased
33JFFS2: Erase block at 0x00028000 is not formatted. It will be erased
34...
35
36Signed-off-by: Liu Shuo <b35362@freescale.com>
37Signed-off-by: Li Yang <leoli@freescale.com>
38
39---
40v2 : get length of availble freeoob bytes from oobinfo information,
41 not use the ioctl ECCGETLAYOUT which is being deprecated.
42
43 flash_erase.c | 46 +++++++++++++++++++++++++++++++++++++++-------
44 1 files changed, 39 insertions(+), 7 deletions(-)
45
46diff --git a/flash_erase.c b/flash_erase.c
47index fe2eaca..3e94495 100644
48--- a/flash_erase.c
49+++ b/flash_erase.c
50@@ -98,6 +98,7 @@ int main(int argc, char *argv[])
51 int isNAND;
52 int error = 0;
53 uint64_t offset = 0;
54+ void *oob_data = NULL;
55
56 /*
57 * Process user arguments
58@@ -197,15 +198,43 @@ int main(int argc, char *argv[])
59 if (ioctl(fd, MEMGETOOBSEL, &oobinfo) != 0)
60 return sys_errmsg("%s: unable to get NAND oobinfo", mtd_device);
61
62+ cleanmarker.totlen = cpu_to_je32(8);
63 /* Check for autoplacement */
64 if (oobinfo.useecc == MTD_NANDECC_AUTOPLACE) {
65- /* Get the position of the free bytes */
66- if (!oobinfo.oobfree[0][1])
67+ struct nand_ecclayout_user ecclayout;
68+ int i, oobavail;
69+
70+ for (i = 0, oobavail = 0; oobinfo.oobfree[i][1]; i++)
71+ oobavail += oobinfo.oobfree[i][1];
72+
73+ if (!oobavail)
74 return errmsg(" Eeep. Autoplacement selected and no empty space in oob");
75+
76+ /* Get the position of the free bytes */
77 clmpos = oobinfo.oobfree[0][0];
78- clmlen = oobinfo.oobfree[0][1];
79- if (clmlen > 8)
80- clmlen = 8;
81+ clmlen = MIN(oobavail, 8);
82+
83+ if (oobinfo.oobfree[0][1] < 8 && oobavail >= 8) {
84+ int left, n, last = 0;
85+ void *cm;
86+
87+ oob_data = malloc(mtd.oob_size);
88+ if (!oob_data)
89+ return -ENOMEM;
90+
91+ memset(oob_data, 0xff, mtd.oob_size);
92+ cm = &cleanmarker;
93+ for (i = 0, left = clmlen; left ; i++) {
94+ n = MIN(left, oobinfo.oobfree[i][1]);
95+ memcpy(oob_data + oobinfo.oobfree[i][0],
96+ cm, n);
97+ left -= n;
98+ cm += n;
99+ last = oobinfo.oobfree[i][0] + n;
100+ }
101+
102+ clmlen = last - clmpos;
103+ }
104 } else {
105 /* Legacy mode */
106 switch (mtd.oob_size) {
107@@ -223,7 +252,6 @@ int main(int argc, char *argv[])
108 break;
109 }
110 }
111- cleanmarker.totlen = cpu_to_je32(8);
112 }
113 cleanmarker.hdr_crc = cpu_to_je32(mtd_crc32(0, &cleanmarker, sizeof(cleanmarker) - 4));
114 }
115@@ -272,7 +300,8 @@ int main(int argc, char *argv[])
116
117 /* write cleanmarker */
118 if (isNAND) {
119- if (mtd_write_oob(mtd_desc, &mtd, fd, offset + clmpos, clmlen, &cleanmarker) != 0) {
120+ void *data = oob_data ? oob_data + clmpos : &cleanmarker;
121+ if (mtd_write_oob(mtd_desc, &mtd, fd, offset + clmpos, clmlen, data) != 0) {
122 sys_errmsg("%s: MTD writeoob failure", mtd_device);
123 continue;
124 }
125@@ -291,5 +320,8 @@ int main(int argc, char *argv[])
126 show_progress(&mtd, offset, eb, eb_start, eb_cnt);
127 bareverbose(!quiet, "\n");
128
129+ if (oob_data)
130+ free(oob_data);
131+
132 return 0;
133 }
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 \
8 8
9SRCREV = "ca39eb1d98e736109c64ff9c1aa2a6ecca222d8f" 9SRCREV = "ca39eb1d98e736109c64ff9c1aa2a6ecca222d8f"
10SRC_URI = "git://git.infradead.org/mtd-utils.git;protocol=git \ 10SRC_URI = "git://git.infradead.org/mtd-utils.git;protocol=git \
11 file://add-exclusion-to-mkfs-jffs2-git-2.patch" 11 file://add-exclusion-to-mkfs-jffs2-git-2.patch \
12 file://mtd-utils-fix-corrupt-cleanmarker-with-flash_erase--j-command.patch "
12 13
13S = "${WORKDIR}/git/" 14S = "${WORKDIR}/git/"
14 15
15PR = "r1" 16PR = "r2"
16 17
17EXTRA_OEMAKE = "'CC=${CC}' 'RANLIB=${RANLIB}' 'AR=${AR}' 'CFLAGS=${CFLAGS} -I${S}/include -DWITHOUT_XATTR' 'BUILDDIR=${S}'" 18EXTRA_OEMAKE = "'CC=${CC}' 'RANLIB=${RANLIB}' 'AR=${AR}' 'CFLAGS=${CFLAGS} -I${S}/include -DWITHOUT_XATTR' 'BUILDDIR=${S}'"
18 19