aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2014-10-16 20:52:22 +0000
committerRafał Miłecki <zajec5@gmail.com>2014-10-16 20:52:22 +0000
commitbb8bf9f3fa92129a02fe83c95044e08f390eed4d (patch)
tree15ad1f491d0ee3826b1f5a1e69a0146d64611f29
parentb63b1a2ef48d26fe5f1d065548d168995c69080b (diff)
downloadupstream-bb8bf9f3fa92129a02fe83c95044e08f390eed4d.tar.gz
upstream-bb8bf9f3fa92129a02fe83c95044e08f390eed4d.tar.bz2
upstream-bb8bf9f3fa92129a02fe83c95044e08f390eed4d.zip
bcm53xx: hack UBI to erase all dirty blocks left by CFE
UBI requires PEBs to be formatted (with a valid UBI header) or empty (0xFF), however CFE doesn't clear blocks after flashing the image. To workaround this problem, teach UBI to recognize EOF mark in a similar way JFFS2 handles that in OpenWrt. Signed-off-by: Rafał Miłecki <zajec5@gmail.com> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@42940 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r--target/linux/bcm53xx/patches-3.14/500-UBI-Detect-EOF-mark-and-erase-all-remaining-blocks.patch39
1 files changed, 39 insertions, 0 deletions
diff --git a/target/linux/bcm53xx/patches-3.14/500-UBI-Detect-EOF-mark-and-erase-all-remaining-blocks.patch b/target/linux/bcm53xx/patches-3.14/500-UBI-Detect-EOF-mark-and-erase-all-remaining-blocks.patch
new file mode 100644
index 0000000000..50a89cb6fa
--- /dev/null
+++ b/target/linux/bcm53xx/patches-3.14/500-UBI-Detect-EOF-mark-and-erase-all-remaining-blocks.patch
@@ -0,0 +1,39 @@
+From f41f8b42db092e505382f7120994de21590dff48 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
+Date: Thu, 16 Oct 2014 20:52:16 +0200
+Subject: [PATCH] UBI: Detect EOF mark and erase all remaining blocks
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
+---
+ drivers/mtd/ubi/io.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
+index d361349..f9bba3c 100644
+--- a/drivers/mtd/ubi/io.c
++++ b/drivers/mtd/ubi/io.c
+@@ -727,6 +727,7 @@ bad:
+ * o %UBI_IO_FF if only 0xFF bytes were read (the PEB is supposedly empty)
+ * o a negative error code in case of failure.
+ */
++static bool erase_all_next = false;
+ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
+ struct ubi_ec_hdr *ec_hdr, int verbose)
+ {
+@@ -753,6 +754,10 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
+ }
+
+ magic = be32_to_cpu(ec_hdr->magic);
++ if (magic == 0xdeadc0de)
++ erase_all_next = true;
++ if (erase_all_next)
++ return read_err ? UBI_IO_FF_BITFLIPS : UBI_IO_FF;
+ if (magic != UBI_EC_HDR_MAGIC) {
+ if (mtd_is_eccerr(read_err))
+ return UBI_IO_BAD_HDR_EBADMSG;
+--
+1.8.4.5
+