[PATCH 2/2] ubiformat: Leave space for fastmap anchor

Sascha Hauer s.hauer at pengutronix.de
Wed Oct 22 00:48:31 PDT 2014


The fastmap code needs a free eraseblock in the first 64 erasblocks
to write a fastmap anchor. Since ubiformat continuously writes the
image to the flash the fastmap code won't find a free block and
fastmap will be disabled. With this patch ubiformat skips flashing
a block at the beginning thus allowing the fastmap code to write
an anchor.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 ubi-utils/ubiformat.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/ubi-utils/ubiformat.c b/ubi-utils/ubiformat.c
index 2269cdf..df43df3 100644
--- a/ubi-utils/ubiformat.c
+++ b/ubi-utils/ubiformat.c
@@ -518,6 +518,7 @@ static int flash_image(libmtd_t libmtd, const struct mtd_dev_info *mtd,
 		       const struct ubigen_info *ui, struct ubi_scan_info *si)
 {
 	int fd, img_ebs, eb, written_ebs = 0, divisor, skip_data_read = 0;
+	int fastmap_anchor_done = 0;
 	off_t st_size;
 
 	fd = open_file(&st_size);
@@ -544,6 +545,15 @@ static int flash_image(libmtd_t libmtd, const struct mtd_dev_info *mtd,
 		int err;
 		char buf[mtd->eb_size];
 
+		if (!fastmap_anchor_done) {
+			err = write_eraseblock(libmtd, mtd, ui, si, eb, NULL, 0);
+			if (err < 0)
+				goto out_close;
+			if (err == 0)
+				fastmap_anchor_done = 1;
+			continue;
+		}
+
 		if (!args.quiet && !args.verbose) {
 			printf("\r" PROGRAM_NAME ": flashing eraseblock %d -- %2lld %% complete  ",
 			       eb, (long long)(eb + 1) * 100 / divisor);
-- 
2.1.1




More information about the linux-mtd mailing list