mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] fix i.MX external NAND boot bad block handling
@ 2013-03-12  9:29 Sascha Hauer
  2013-03-12  9:29 ` [PATCH 1/4] ARM: i.MX: external nand boot: check for bad blocks Sascha Hauer
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Sascha Hauer @ 2013-03-12  9:29 UTC (permalink / raw)
  To: barebox

The i.MX external NAND boot code relied very much on all block
used for the bootloader are good. It has some bad block checking,
but unfortunately it tested for a bad block in each page of a
block and skipped this page instead of checking for a bad block
at the beginning of a block and skipping the whole block then.

The handling of 2k page NAND flashes has another problem with bad
blocks. We rely on a bad block table since we cannot properly keep
the BBM on flash. This also means that the external NAND boot code
cannot detect bad blocks. This series adds a barebox update handler
to generate a bad block table (well, as long as we consider a 32bit
bitmask a table ;) inside the initial 2k page.

Sascha

----------------------------------------------------------------
Sascha Hauer (4):
      ARM: i.MX: external nand boot: check for bad blocks
      ARM: head: Add some space behind the image header
      ARM: i.MX: Add bbu handler for external NAND boot
      ARM: i.MX pcm043: register external nand boot handler

 arch/arm/boards/pcm043/pcm043.c           |   6 +
 arch/arm/include/asm/barebox-arm-head.h   |  10 ++
 arch/arm/mach-imx/Kconfig                 |   6 +
 arch/arm/mach-imx/Makefile                |   1 +
 arch/arm/mach-imx/external-nand-boot.c    |  59 +++++++--
 arch/arm/mach-imx/imx-bbu-external-nand.c | 204 ++++++++++++++++++++++++++++++
 arch/arm/mach-imx/include/mach/bbu.h      |  11 ++
 arch/arm/mach-imx/include/mach/imx-nand.h |   6 +
 8 files changed, 289 insertions(+), 14 deletions(-)
 create mode 100644 arch/arm/mach-imx/imx-bbu-external-nand.c

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] ARM: i.MX: external nand boot: check for bad blocks
  2013-03-12  9:29 [PATCH] fix i.MX external NAND boot bad block handling Sascha Hauer
@ 2013-03-12  9:29 ` Sascha Hauer
  2013-03-12  9:29 ` [PATCH 2/4] ARM: head: Add some space behind the image header Sascha Hauer
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2013-03-12  9:29 UTC (permalink / raw)
  To: barebox

The i.MX external NAND boot code checks for a bad block every
page, which is wrong. Instead, check for a bad block at the
beginning of each block.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-imx/external-nand-boot.c | 39 +++++++++++++++++++++++-----------
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/arch/arm/mach-imx/external-nand-boot.c b/arch/arm/mach-imx/external-nand-boot.c
index 73c4ccd..bfefa3c 100644
--- a/arch/arm/mach-imx/external-nand-boot.c
+++ b/arch/arm/mach-imx/external-nand-boot.c
@@ -154,6 +154,14 @@ static int __maybe_unused is_pagesize_2k(void)
 #endif
 }
 
+static noinline void __bare_init imx_nandboot_get_page(void *regs,
+		u32 offs, int pagesize_2k)
+{
+	imx_nandboot_send_cmd(regs, NAND_CMD_READ0);
+	imx_nandboot_nfc_addr(regs, offs, pagesize_2k);
+	imx_nandboot_send_page(regs, NFC_OUTPUT, pagesize_2k);
+}
+
 void __bare_init imx_nand_load_image(void *dest, int size)
 {
 	u32 tmp, page, block, blocksize, pagesize;
@@ -227,26 +235,33 @@ void __bare_init imx_nand_load_image(void *dest, int size)
 
 	while (1) {
 		page = 0;
+
+		imx_nandboot_get_page(regs, block * blocksize +
+				page * pagesize, pagesize_2k);
+
+		if (pagesize_2k) {
+			if ((readw(spare0) & 0xff) != 0xff) {
+				block++;
+				continue;
+			}
+		} else {
+			if ((readw(spare0 + 4) & 0xff00) != 0xff00) {
+				block++;
+				continue;
+			}
+		}
+
 		while (page * pagesize < blocksize) {
 			debug("page: %d block: %d dest: %p src "
 					"0x%08x\n",
 					page, block, dest,
 					block * blocksize +
 					page * pagesize);
-
-			imx_nandboot_send_cmd(regs, NAND_CMD_READ0);
-			imx_nandboot_nfc_addr(regs, block * blocksize +
+			if (page)
+				imx_nandboot_get_page(regs, block * blocksize +
 					page * pagesize, pagesize_2k);
-			imx_nandboot_send_page(regs, NFC_OUTPUT, pagesize_2k);
-			page++;
 
-			if (pagesize_2k) {
-				if ((readw(spare0) & 0xff) != 0xff)
-					continue;
-			} else {
-				if ((readw(spare0 + 4) & 0xff00) != 0xff00)
-					continue;
-			}
+			page++;
 
 			__memcpy32(dest, base, pagesize);
 			dest += pagesize;
-- 
1.8.2.rc2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 2/4] ARM: head: Add some space behind the image header
  2013-03-12  9:29 [PATCH] fix i.MX external NAND boot bad block handling Sascha Hauer
  2013-03-12  9:29 ` [PATCH 1/4] ARM: i.MX: external nand boot: check for bad blocks Sascha Hauer
@ 2013-03-12  9:29 ` Sascha Hauer
  2013-03-12  9:41   ` Juergen Beisert
  2013-03-12  9:29 ` [PATCH 3/4] ARM: i.MX: Add bbu handler for external NAND boot Sascha Hauer
  2013-03-12  9:29 ` [PATCH 4/4] ARM: i.MX pcm043: register external nand boot handler Sascha Hauer
  3 siblings, 1 reply; 9+ messages in thread
From: Sascha Hauer @ 2013-03-12  9:29 UTC (permalink / raw)
  To: barebox

This adds 32bytes of space behind the image header (exception table
+ barebox magic) for board/SoC specific use. This can be used for
example to embed some extra information in a flashed image.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/include/asm/barebox-arm-head.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm/include/asm/barebox-arm-head.h b/arch/arm/include/asm/barebox-arm-head.h
index 9d9b854..225a336 100644
--- a/arch/arm/include/asm/barebox-arm-head.h
+++ b/arch/arm/include/asm/barebox-arm-head.h
@@ -33,6 +33,13 @@ static inline void arm_cpu_lowlevel_init(void)
 	set_cr(r);
 }
 
+/*
+ * 32 bytes at this is offset is reserved in the barebox head for board/SoC
+ * usage
+ */
+#define ARM_HEAD_SPARE_OFS	0x30
+#define ARM_HEAD_SPARE_MARKER	0x55555555
+
 #ifdef CONFIG_HAVE_MACH_ARM_HEAD
 #include <mach/barebox-arm-head.h>
 #else
@@ -64,6 +71,9 @@ static inline void barebox_arm_head(void)
 							 * barebox can skip relocation
 							 */
 		".word _barebox_image_size\n"		/* image size to copy */
+		".rept 8\n"
+		".word 0x55555555\n"
+		".endr\n"
 	);
 }
 #endif
-- 
1.8.2.rc2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 3/4] ARM: i.MX: Add bbu handler for external NAND boot
  2013-03-12  9:29 [PATCH] fix i.MX external NAND boot bad block handling Sascha Hauer
  2013-03-12  9:29 ` [PATCH 1/4] ARM: i.MX: external nand boot: check for bad blocks Sascha Hauer
  2013-03-12  9:29 ` [PATCH 2/4] ARM: head: Add some space behind the image header Sascha Hauer
@ 2013-03-12  9:29 ` Sascha Hauer
  2013-03-12  9:48   ` Juergen Beisert
  2013-03-12  9:29 ` [PATCH 4/4] ARM: i.MX pcm043: register external nand boot handler Sascha Hauer
  3 siblings, 1 reply; 9+ messages in thread
From: Sascha Hauer @ 2013-03-12  9:29 UTC (permalink / raw)
  To: barebox

The external NAND boot code currently does not handle bad blocks
correctly on 2k NAND flashes. This patch adds a barebox_update
handler for external NAND boot which embeds a Bad block table in
the flashed image. The boot code will skip bad blocks found in
this bad block table then.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-imx/Kconfig                 |   6 +
 arch/arm/mach-imx/Makefile                |   1 +
 arch/arm/mach-imx/external-nand-boot.c    |  22 +++-
 arch/arm/mach-imx/imx-bbu-external-nand.c | 204 ++++++++++++++++++++++++++++++
 arch/arm/mach-imx/include/mach/bbu.h      |  11 ++
 arch/arm/mach-imx/include/mach/imx-nand.h |   6 +
 6 files changed, 247 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/mach-imx/imx-bbu-external-nand.c

diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 1308f3c..7703127 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -149,6 +149,12 @@ config NAND_IMX_BOOT_512_2K
 
 endchoice
 
+config BAREBOX_UPDATE_IMX_EXTERNAL_NAND
+	bool
+	depends on ARCH_IMX_EXTERNAL_BOOT_NAND
+	depends on BAREBOX_UPDATE
+	default y
+
 comment "Freescale i.MX System-on-Chip"
 
 choice
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 4adf522..dd58c62 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -16,4 +16,5 @@ obj-$(CONFIG_COMMON_CLK) += clk-pllv1.o clk-pllv2.o clk-pllv3.o clk-pfd.o
 obj-y += devices.o imx.o esdctl.o
 obj-y += boot.o
 obj-$(CONFIG_BAREBOX_UPDATE) += imx-bbu-internal.o
+obj-$(CONFIG_BAREBOX_UPDATE_IMX_EXTERNAL_NAND) += imx-bbu-external-nand.o
 pbl-y += esdctl.o
diff --git a/arch/arm/mach-imx/external-nand-boot.c b/arch/arm/mach-imx/external-nand-boot.c
index bfefa3c..636f974 100644
--- a/arch/arm/mach-imx/external-nand-boot.c
+++ b/arch/arm/mach-imx/external-nand-boot.c
@@ -17,6 +17,7 @@
 #include <linux/mtd/nand.h>
 #include <asm/sections.h>
 #include <asm/barebox-arm.h>
+#include <asm/barebox-arm-head.h>
 #include <mach/imx-nand.h>
 #include <mach/esdctl.h>
 #include <mach/generic.h>
@@ -164,8 +165,8 @@ static noinline void __bare_init imx_nandboot_get_page(void *regs,
 
 void __bare_init imx_nand_load_image(void *dest, int size)
 {
-	u32 tmp, page, block, blocksize, pagesize;
-	int pagesize_2k = 1;
+	u32 tmp, page, block, blocksize, pagesize, badblocks;
+	int pagesize_2k = 1, bbt = 0;
 	void *regs, *base, *spare0;
 
 #if defined(CONFIG_NAND_IMX_BOOT_512)
@@ -231,6 +232,16 @@ void __bare_init imx_nand_load_image(void *dest, int size)
 			writew(NFC_V2_SPAS_SPARESIZE(16), regs + NFC_V2_SPAS);
 	}
 
+	/*
+	 * Check if this image has a bad block table embedded. See
+	 * imx_bbu_external_nand_register_handler for more information
+	 */
+	badblocks = *(uint32_t *)(base + ARM_HEAD_SPARE_OFS);
+	if (badblocks == IMX_NAND_BBT_MAGIC) {
+		bbt = 1;
+		badblocks = *(uint32_t *)(base + ARM_HEAD_SPARE_OFS + 4);
+	}
+
 	block = page = 0;
 
 	while (1) {
@@ -239,7 +250,12 @@ void __bare_init imx_nand_load_image(void *dest, int size)
 		imx_nandboot_get_page(regs, block * blocksize +
 				page * pagesize, pagesize_2k);
 
-		if (pagesize_2k) {
+		if (bbt) {
+			if (badblocks & (1 << block)) {
+				block++;
+				continue;
+			}
+		} else if (pagesize_2k) {
 			if ((readw(spare0) & 0xff) != 0xff) {
 				block++;
 				continue;
diff --git a/arch/arm/mach-imx/imx-bbu-external-nand.c b/arch/arm/mach-imx/imx-bbu-external-nand.c
new file mode 100644
index 0000000..a438b00
--- /dev/null
+++ b/arch/arm/mach-imx/imx-bbu-external-nand.c
@@ -0,0 +1,204 @@
+/*
+ * imx-bbu-external-nand.c - i.MX specific update functions for external
+ *			     nand boot
+ *
+ * Copyright (c) 2013 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <common.h>
+#include <malloc.h>
+#include <bbu.h>
+#include <filetype.h>
+#include <errno.h>
+#include <fs.h>
+#include <fcntl.h>
+#include <sizes.h>
+#include <linux/mtd/mtd-abi.h>
+#include <linux/stat.h>
+#include <ioctl.h>
+#include <mach/bbu.h>
+#include <mach/imx-nand.h>
+#include <asm/barebox-arm-head.h>
+
+static int imx_bbu_external_nand_update(struct bbu_handler *handler, struct bbu_data *data)
+{
+	struct mtd_info_user meminfo;
+	int fd;
+	struct stat s;
+	int size_available, size_need;
+	int ret;
+	uint32_t num_bb = 0, bbt = 0;
+	uint64_t offset;
+	int block = 0, len, now, blocksize;
+	void *image = data->image;
+
+	ret = stat(data->devicefile, &s);
+	if (ret)
+		return ret;
+
+	size_available = s.st_size;
+
+	fd = open(data->devicefile, O_RDWR);
+	if (fd < 0)
+		return fd;
+
+	ret = ioctl(fd, MEMGETINFO, &meminfo);
+	if (ret)
+		goto out;
+
+	blocksize = meminfo.erasesize;
+
+	size_need = data->len + 0x8000;
+
+	/*
+	 * Collect bad blocks and construct BBT
+	 */
+	while (size_need > 0) {
+		ret = ioctl(fd, MEMGETBADBLOCK, &offset);
+		if (ret < 0)
+			goto out;
+
+		if (ret) {
+			if (!offset) {
+				printf("1st block is bad. This is not supported\n");
+				ret = -EINVAL;
+				goto out;
+			}
+
+			debug("bad block at 0x%08llx\n", offset);
+			num_bb++;
+			bbt |= (1 << block);
+			offset += blocksize;
+			block++;
+			continue;
+		}
+		size_need -= blocksize;
+		size_available -= blocksize;
+		offset += blocksize;
+		block++;
+
+		if (size_available < 0) {
+			printf("device is too small\n");
+			ret = -ENOSPC;
+			goto out;
+		}
+	}
+
+	debug("total image size: 0x%08x. Space needed including bad blocks: 0x%08x\n",
+			data->len, data->len + num_bb * blocksize);
+
+	if (meminfo.writesize >= 2048) {
+		uint32_t *image_bbt = image + ARM_HEAD_SPARE_OFS;
+
+		debug(">= 2k nand detected. Creating in-image bbt\n");
+
+		if (*image_bbt != ARM_HEAD_SPARE_MARKER) {
+			if (!bbu_force(data, "Cannot find space for the BBT")) {
+				ret = -EINVAL;
+				goto out;
+			}
+		} else {
+			*image_bbt++ = IMX_NAND_BBT_MAGIC;
+			*image_bbt++ = bbt;
+		}
+	}
+
+	if (data->len + num_bb * blocksize > s.st_size) {
+		printf("needed space (0x%08x) exceeds partition space (0x%08llx)\n",
+				data->len + num_bb * blocksize, s.st_size);
+		ret = -ENOSPC;
+		goto out;
+	}
+
+	len = data->len;
+	offset = 0;
+
+	/* last chance before erasing the flash */
+	ret = bbu_confirm(data);
+	if (ret)
+		return ret;
+
+	/*
+	 * Write image to NAND skipping bad blocks
+	 */
+	while (len > 0) {
+		now = min(len, blocksize);
+
+		ret = ioctl(fd, MEMGETBADBLOCK, &offset);
+		if (ret < 0)
+			goto out;
+
+		if (ret) {
+			ret = lseek(fd, offset + blocksize, SEEK_SET);
+			if (ret < 0)
+				goto out;
+			offset += blocksize;
+			continue;
+		}
+
+		debug("writing %d bytes at 0x%08llx\n", now, offset);
+
+		ret = erase(fd, blocksize, offset);
+		if (ret)
+			goto out;
+
+		ret = write(fd, image, now);
+		if (ret < 0)
+			goto out;
+
+		len -= now;
+		image += now;
+		offset += now;
+	}
+
+	ret = 0;
+
+out:
+	close(fd);
+
+	return ret;
+}
+
+/*
+ * Register a i.MX external nand boot update handler.
+ *
+ * For 512b page NANDs this handler simply writes the image to NAND skipping
+ * bad blocks.
+ *
+ * For 2K page NANDs this handler embeds a bad block table in the flashed image.
+ * This is necessary since we rely on an on-flash BBT for these flashes, but the
+ * regular mtd BBT is too complex to be handled in the 2k the i.MX is able to
+ * initially load from NAND. The BBT consists of a single 32bit value in which
+ * each bit represents a single block. With 2k NAND flashes this is enough for
+ * 4MiB size including bad blocks.
+ */
+int imx_bbu_external_nand_register_handler(const char *name, char *devicefile,
+		unsigned long flags)
+{
+	struct bbu_handler *handler;
+	int ret;
+
+	handler = xzalloc(sizeof(*handler));
+	handler->devicefile = devicefile;
+	handler->name = name;
+	handler->flags = flags;
+	handler->handler = imx_bbu_external_nand_update;
+
+	ret = bbu_register_handler(handler);
+	if (ret)
+		free(handler);
+
+	return ret;
+}
diff --git a/arch/arm/mach-imx/include/mach/bbu.h b/arch/arm/mach-imx/include/mach/bbu.h
index ad7c754..077133a 100644
--- a/arch/arm/mach-imx/include/mach/bbu.h
+++ b/arch/arm/mach-imx/include/mach/bbu.h
@@ -78,6 +78,17 @@ static inline int imx6_bbu_internal_spi_i2c_register_handler(const char *name, c
 
 #endif
 
+#if defined(CONFIG_BAREBOX_UPDATE_IMX_EXTERNAL_NAND)
+int imx_bbu_external_nand_register_handler(const char *name, char *devicefile,
+		unsigned long flags);
+#else
+static inline int imx_bbu_external_nand_register_handler(const char *name, char *devicefile,
+		unsigned long flags)
+{
+	return -ENOSYS;
+}
+#endif
+
 struct dcd_table {
 	void *data;
 	unsigned int size;
diff --git a/arch/arm/mach-imx/include/mach/imx-nand.h b/arch/arm/mach-imx/include/mach/imx-nand.h
index 8352d79..9e6416e 100644
--- a/arch/arm/mach-imx/include/mach/imx-nand.h
+++ b/arch/arm/mach-imx/include/mach/imx-nand.h
@@ -70,4 +70,10 @@ struct imx_nand_platform_data {
 #define NFC_ID				(1 << 4)
 #define NFC_STATUS			(1 << 5)
 
+/*
+ * For external NAND boot this defines the magic value for the bad block table
+ * This is found at offset ARM_HEAD_SPARE_OFS in the image on NAND.
+ */
+#define IMX_NAND_BBT_MAGIC 0xbadb10c0
+
 #endif /* __ASM_ARCH_NAND_H */
-- 
1.8.2.rc2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 4/4] ARM: i.MX pcm043: register external nand boot handler
  2013-03-12  9:29 [PATCH] fix i.MX external NAND boot bad block handling Sascha Hauer
                   ` (2 preceding siblings ...)
  2013-03-12  9:29 ` [PATCH 3/4] ARM: i.MX: Add bbu handler for external NAND boot Sascha Hauer
@ 2013-03-12  9:29 ` Sascha Hauer
  3 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2013-03-12  9:29 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/boards/pcm043/pcm043.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/boards/pcm043/pcm043.c b/arch/arm/boards/pcm043/pcm043.c
index 04418fb..a81852a 100644
--- a/arch/arm/boards/pcm043/pcm043.c
+++ b/arch/arm/boards/pcm043/pcm043.c
@@ -44,6 +44,7 @@
 #include <mach/iomux-mx35.h>
 #include <mach/devices-imx35.h>
 #include <mach/generic.h>
+#include <mach/bbu.h>
 
 static struct fec_platform_data fec_info = {
 	.xcv_type = MII100,
@@ -115,6 +116,7 @@ static int imx35_devices_init(void)
 {
 	uint32_t reg;
 	char *envstr;
+	unsigned long bbu_nand_flags = 0;
 
 	/* CS0: Nor Flash */
 	imx35_setup_weimcs(5, 0x22C0CF00, 0x75000D01, 0x00000900);
@@ -146,6 +148,7 @@ static int imx35_devices_init(void)
 		devfs_add_partition("nand0", SZ_512K, SZ_256K, DEVFS_PARTITION_FIXED, "env_raw");
 		dev_add_bb_dev("env_raw", "env0");
 		envstr = "NAND";
+		bbu_nand_flags = BBU_HANDLER_FLAG_DEFAULT;
 		break;
 	case bootsource_nor:
 	default:
@@ -163,6 +166,9 @@ static int imx35_devices_init(void)
 	armlinux_set_bootparams((void *)0x80000100);
 	armlinux_set_architecture(MACH_TYPE_PCM043);
 
+	imx_bbu_external_nand_register_handler("nand", "/dev/nand0.barebox",
+			bbu_nand_flags);
+
 	return 0;
 }
 
-- 
1.8.2.rc2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/4] ARM: head: Add some space behind the image header
  2013-03-12  9:29 ` [PATCH 2/4] ARM: head: Add some space behind the image header Sascha Hauer
@ 2013-03-12  9:41   ` Juergen Beisert
  0 siblings, 0 replies; 9+ messages in thread
From: Juergen Beisert @ 2013-03-12  9:41 UTC (permalink / raw)
  To: barebox

Sascha Hauer wrote:
> [...]
> +/*
> + * 32 bytes at this is offset is reserved in the barebox head for board/SoC + * usage
> + */
> [...]

Hmm, one 'is' too much in this sentence?

jbe

-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | http://www.pengutronix.de/  |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/4] ARM: i.MX: Add bbu handler for external NAND boot
  2013-03-12  9:29 ` [PATCH 3/4] ARM: i.MX: Add bbu handler for external NAND boot Sascha Hauer
@ 2013-03-12  9:48   ` Juergen Beisert
  2013-03-12 10:05     ` Sascha Hauer
  0 siblings, 1 reply; 9+ messages in thread
From: Juergen Beisert @ 2013-03-12  9:48 UTC (permalink / raw)
  To: barebox

Sascha Hauer wrote:
> [...]
> +               if (size_available < 0) {
> +                       printf("device is too small\n");
> +                       ret = -ENOSPC;
> +                       goto out;
> +               }
> [...]

As the user only sees bad block info when DEBUG is enabled, you should output 
more info here.
The device (or better partition?) can be too small in general, or it can be 
too small due to many bad blocks inside. IMHO it would be helpful to see more 
info here why it failed.

jbe

-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | http://www.pengutronix.de/  |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/4] ARM: i.MX: Add bbu handler for external NAND boot
  2013-03-12  9:48   ` Juergen Beisert
@ 2013-03-12 10:05     ` Sascha Hauer
  2013-03-12 10:08       ` Juergen Beisert
  0 siblings, 1 reply; 9+ messages in thread
From: Sascha Hauer @ 2013-03-12 10:05 UTC (permalink / raw)
  To: Juergen Beisert; +Cc: barebox

On Tue, Mar 12, 2013 at 10:48:16AM +0100, Juergen Beisert wrote:
> Sascha Hauer wrote:
> > [...]
> > +               if (size_available < 0) {
> > +                       printf("device is too small\n");
> > +                       ret = -ENOSPC;
> > +                       goto out;
> > +               }
> > [...]
> 
> As the user only sees bad block info when DEBUG is enabled, you should output 
> more info here.
> The device (or better partition?) can be too small in general, or it can be 
> too small due to many bad blocks inside. IMHO it would be helpful to see more 
> info here why it failed.

Ok. I reworded this to:

	printf("device is too small.\n"
			"raw partition size: 0x%08llx\n"
			"partition size w/o bad blocks: 0x%08llx\n"
			"size needed: 0x%08x\n",
			s.st_size,
			s.st_size - num_bb * blocksize,
			data->len);

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/4] ARM: i.MX: Add bbu handler for external NAND boot
  2013-03-12 10:05     ` Sascha Hauer
@ 2013-03-12 10:08       ` Juergen Beisert
  0 siblings, 0 replies; 9+ messages in thread
From: Juergen Beisert @ 2013-03-12 10:08 UTC (permalink / raw)
  To: barebox

Sascha Hauer wrote:
> On Tue, Mar 12, 2013 at 10:48:16AM +0100, Juergen Beisert wrote:
> > Sascha Hauer wrote:
> > > [...]
> > > +               if (size_available < 0) {
> > > +                       printf("device is too small\n");
> > > +                       ret = -ENOSPC;
> > > +                       goto out;
> > > +               }
> > > [...]
> >
> > As the user only sees bad block info when DEBUG is enabled, you should
> > output more info here.
> > The device (or better partition?) can be too small in general, or it can
> > be too small due to many bad blocks inside. IMHO it would be helpful to
> > see more info here why it failed.
>
> Ok. I reworded this to:
>
> 	printf("device is too small.\n"
> 			"raw partition size: 0x%08llx\n"
> 			"partition size w/o bad blocks: 0x%08llx\n"
> 			"size needed: 0x%08x\n",
> 			s.st_size,
> 			s.st_size - num_bb * blocksize,
> 			data->len);

ACK.

jbe

-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | Phone: +49-5121-206917-5128 |
Peiner Str. 6-8, 31137 Hildesheim, Germany    | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686              | http://www.pengutronix.de/  |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-03-12 10:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-12  9:29 [PATCH] fix i.MX external NAND boot bad block handling Sascha Hauer
2013-03-12  9:29 ` [PATCH 1/4] ARM: i.MX: external nand boot: check for bad blocks Sascha Hauer
2013-03-12  9:29 ` [PATCH 2/4] ARM: head: Add some space behind the image header Sascha Hauer
2013-03-12  9:41   ` Juergen Beisert
2013-03-12  9:29 ` [PATCH 3/4] ARM: i.MX: Add bbu handler for external NAND boot Sascha Hauer
2013-03-12  9:48   ` Juergen Beisert
2013-03-12 10:05     ` Sascha Hauer
2013-03-12 10:08       ` Juergen Beisert
2013-03-12  9:29 ` [PATCH 4/4] ARM: i.MX pcm043: register external nand boot handler Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox