summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--patches/mtd-utils-1.5.0/0003-flash_otp_write-fix-format-string-warning.patch30
-rw-r--r--patches/mtd-utils-1.5.0/0004-flash_otp_write-fix-writing-to-NAND-in-presence-of-p.patch61
-rw-r--r--patches/mtd-utils-1.5.0/0005-flash_otp_write-fix-a-buffer-overflow-on-NAND-with-w.patch35
-rw-r--r--patches/mtd-utils-1.5.0/0006-Makefile-also-build-and-install-flash_otp_lock-and-f.patch42
-rw-r--r--patches/mtd-utils-1.5.0/series6
-rw-r--r--rules/mtd-utils.in12
-rw-r--r--rules/mtd-utils.make8
7 files changed, 193 insertions, 1 deletions
diff --git a/patches/mtd-utils-1.5.0/0003-flash_otp_write-fix-format-string-warning.patch b/patches/mtd-utils-1.5.0/0003-flash_otp_write-fix-format-string-warning.patch
new file mode 100644
index 000000000..ae49c4e4c
--- /dev/null
+++ b/patches/mtd-utils-1.5.0/0003-flash_otp_write-fix-format-string-warning.patch
@@ -0,0 +1,30 @@
+From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de>
+Date: Wed, 20 Feb 2013 17:25:30 +0100
+Subject: [PATCH] flash_otp_write: fix format string warning
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This fixes
+ flash_otp_write.c: In function 'main':
+ flash_otp_write.c:61:2: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'off_t' [-Wformat]
+
+Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
+Forwarded: id:1361378469-18631-1-git-send-email-u.kleine-koenig@pengutronix.de
+---
+ flash_otp_write.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/flash_otp_write.c b/flash_otp_write.c
+index d407ebb..41cf1c5 100644
+--- a/flash_otp_write.c
++++ b/flash_otp_write.c
+@@ -58,7 +58,7 @@ int main(int argc,char *argv[])
+ return errno;
+ }
+
+- printf("Writing OTP user data on %s at offset 0x%lx\n", argv[2], offset);
++ printf("Writing OTP user data on %s at offset 0x%lx\n", argv[2], (unsigned long)offset);
+
+ if (mtdInfo.type == MTD_NANDFLASH)
+ len = mtdInfo.writesize;
diff --git a/patches/mtd-utils-1.5.0/0004-flash_otp_write-fix-writing-to-NAND-in-presence-of-p.patch b/patches/mtd-utils-1.5.0/0004-flash_otp_write-fix-writing-to-NAND-in-presence-of-p.patch
new file mode 100644
index 000000000..f6c2aac05
--- /dev/null
+++ b/patches/mtd-utils-1.5.0/0004-flash_otp_write-fix-writing-to-NAND-in-presence-of-p.patch
@@ -0,0 +1,61 @@
+From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de>
+Date: Wed, 27 Feb 2013 17:49:06 +0100
+Subject: [PATCH] flash_otp_write: fix writing to NAND in presence of partial
+ reads
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+When doing something like:
+
+ { printf "\xff"; printf "\xfe"; } | flash_otp_write -u /dev/mtd0 0
+
+flash_otp_write might see only a single byte when reading from stdin for
+the first tim. In this case (and without this patch) it pads to
+$writesize with '\xff's and writes that out. In the next iteration it
+reads the 2nd byte, pads and writes again. So the 2nd byte is written to
+offset $writesize instead of 1.
+
+Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
+Forwarded: id:1362044529-511-1-git-send-email-u.kleine-koenig@pengutronix.de
+---
+ flash_otp_write.c | 19 ++++++++++++++++++-
+ 1 file changed, 18 insertions(+), 1 deletion(-)
+
+diff --git a/flash_otp_write.c b/flash_otp_write.c
+index 41cf1c5..0aa872e 100644
+--- a/flash_otp_write.c
++++ b/flash_otp_write.c
+@@ -15,6 +15,23 @@
+
+ #include <mtd/mtd-user.h>
+
++ssize_t xread(int fd, void *buf, size_t count)
++{
++ ssize_t ret, done = 0;
++
++retry:
++ ret = read(fd, buf + done, count - done);
++ if (ret < 0)
++ return ret;
++
++ done += ret;
++
++ if (ret == 0 /* EOF */ || done == count)
++ return done;
++ else
++ goto retry;
++}
++
+ int main(int argc,char *argv[])
+ {
+ int fd, val, ret, size, wrote, len;
+@@ -66,7 +83,7 @@ int main(int argc,char *argv[])
+ len = 256;
+
+ wrote = 0;
+- while ((size = read(0, buf, len))) {
++ while ((size = xread(0, buf, len))) {
+ if (size < 0) {
+ perror("read()");
+ return errno;
diff --git a/patches/mtd-utils-1.5.0/0005-flash_otp_write-fix-a-buffer-overflow-on-NAND-with-w.patch b/patches/mtd-utils-1.5.0/0005-flash_otp_write-fix-a-buffer-overflow-on-NAND-with-w.patch
new file mode 100644
index 000000000..d1102c04d
--- /dev/null
+++ b/patches/mtd-utils-1.5.0/0005-flash_otp_write-fix-a-buffer-overflow-on-NAND-with-w.patch
@@ -0,0 +1,35 @@
+From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de>
+Date: Thu, 28 Feb 2013 10:28:29 +0100
+Subject: [PATCH] flash_otp_write: fix a buffer overflow on NAND with write
+ size > 2048
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+I'm not aware of any chip having a write size bigger than 2048 today.
+Still checking for that instead of a sleeping problem to bite us maybe
+in a few years is easy.
+
+Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
+Forwarded: id:1362044546-559-1-git-send-email-u.kleine-koenig@pengutronix.de
+---
+ flash_otp_write.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/flash_otp_write.c b/flash_otp_write.c
+index 0aa872e..5114e6b 100644
+--- a/flash_otp_write.c
++++ b/flash_otp_write.c
+@@ -82,6 +82,12 @@ int main(int argc,char *argv[])
+ else
+ len = 256;
+
++ if (len > sizeof(buf)) {
++ printf("huh, writesize (%d) bigger than buffer (%zu)\n",
++ len, sizeof(buf));
++ return ENOMEM;
++ }
++
+ wrote = 0;
+ while ((size = xread(0, buf, len))) {
+ if (size < 0) {
diff --git a/patches/mtd-utils-1.5.0/0006-Makefile-also-build-and-install-flash_otp_lock-and-f.patch b/patches/mtd-utils-1.5.0/0006-Makefile-also-build-and-install-flash_otp_lock-and-f.patch
new file mode 100644
index 000000000..972729039
--- /dev/null
+++ b/patches/mtd-utils-1.5.0/0006-Makefile-also-build-and-install-flash_otp_lock-and-f.patch
@@ -0,0 +1,42 @@
+From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de>
+Date: Wed, 20 Feb 2013 17:29:12 +0100
+Subject: [PATCH] Makefile: also build and install flash_otp_lock and
+ flash_otp_write
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
+Forwarded: id:1361378491-18687-1-git-send-email-u.kleine-koenig@pengutronix.de
+---
+ .gitignore | 2 ++
+ Makefile | 3 ++-
+ 2 files changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/.gitignore b/.gitignore
+index d4771fb..83ca938 100644
+--- a/.gitignore
++++ b/.gitignore
+@@ -25,6 +25,8 @@
+ /flash_lock
+ /flash_otp_dump
+ /flash_otp_info
++/flash_otp_lock
++/flash_otp_write
+ /flash_unlock
+ /flashcp
+ /ftl_check
+diff --git a/Makefile b/Makefile
+index 190db58..3f9c24f 100644
+--- a/Makefile
++++ b/Makefile
+@@ -19,7 +19,8 @@ TESTS = tests
+ MTD_BINS = \
+ ftl_format flash_erase nanddump doc_loadbios \
+ ftl_check mkfs.jffs2 flash_lock flash_unlock \
+- flash_otp_info flash_otp_dump mtd_debug flashcp nandwrite nandtest \
++ flash_otp_info flash_otp_dump flash_otp_lock flash_otp_write \
++ mtd_debug flashcp nandwrite nandtest \
+ jffs2dump \
+ nftldump nftl_format docfdisk \
+ rfddump rfdformat \
diff --git a/patches/mtd-utils-1.5.0/series b/patches/mtd-utils-1.5.0/series
index 38ac3d1e2..573920239 100644
--- a/patches/mtd-utils-1.5.0/series
+++ b/patches/mtd-utils-1.5.0/series
@@ -2,4 +2,8 @@
#tag:base --start-number 1
0001-make-ubifs-optional.patch
0002-Make-liblzo-optional-for-ubifs-tools.patch
-# c7b83aac3f84d721cecd9e53605999f9 - git-ptx-patches magic
+0003-flash_otp_write-fix-format-string-warning.patch
+0004-flash_otp_write-fix-writing-to-NAND-in-presence-of-p.patch
+0005-flash_otp_write-fix-a-buffer-overflow-on-NAND-with-w.patch
+0006-Makefile-also-build-and-install-flash_otp_lock-and-f.patch
+# e4c91e5314fff3767797bd4aab24a7e3 - git-ptx-patches magic
diff --git a/rules/mtd-utils.in b/rules/mtd-utils.in
index 45ab8e7ec..d1c46bdc3 100644
--- a/rules/mtd-utils.in
+++ b/rules/mtd-utils.in
@@ -68,6 +68,18 @@ config MTD_UTILS_FLASH_OTP_INFO
help
Print info about one-time programmable data.
+config MTD_UTILS_FLASH_OTP_LOCK
+ bool
+ prompt "flash_otp_lock"
+ help
+ Lock one-time programmable data.
+
+config MTD_UTILS_FLASH_OTP_WRITE
+ bool
+ prompt "flash_otp_write"
+ help
+ Write one-time programmable data.
+
config MTD_UTILS_FLASH_UNLOCK
bool
prompt "flash_unlock"
diff --git a/rules/mtd-utils.make b/rules/mtd-utils.make
index d20050e92..75be7db2f 100644
--- a/rules/mtd-utils.make
+++ b/rules/mtd-utils.make
@@ -91,6 +91,14 @@ ifdef PTXCONF_MTD_UTILS_FLASH_OTP_INFO
@$(call install_copy, mtd-utils, 0, 0, 0755, -, \
/usr/sbin/flash_otp_info)
endif
+ifdef PTXCONF_MTD_UTILS_FLASH_OTP_LOCK
+ @$(call install_copy, mtd-utils, 0, 0, 0755, -, \
+ /usr/sbin/flash_otp_lock)
+endif
+ifdef PTXCONF_MTD_UTILS_FLASH_OTP_WRITE
+ @$(call install_copy, mtd-utils, 0, 0, 0755, -, \
+ /usr/sbin/flash_otp_write)
+endif
ifdef PTXCONF_MTD_UTILS_FLASH_UNLOCK
@$(call install_copy, mtd-utils, 0, 0, 0755, -, \
/usr/sbin/flash_unlock)