mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 00/24] i.MX BBU improvements and bugfixes
@ 2018-08-24  2:52 Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 01/24] ARM: i.MX: bbu: Remove unused define Andrey Smirnov
                   ` (24 more replies)
  0 siblings, 25 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Everyone:

This series is the result simplification, bugfixing and adding
features to some of the code in BBU subsytem:

  - Patches 1 - 13 are a number of code simplifications intended to
    minimize amount of duplicated code as well as generic improvements
    (IMHO)

  - Patches 14 - 18 are i.MX8MQ and VF610 related changes

  - Patches 19 - 24 are a result of discovering that a number of error
    cases were silently ignored and not reported as update
    failures. Patch 22 is technically not related to BBU at all, but
    since I discovered the problem while working on this series, I
    kept it as a part of this series

This patchset was tested of following platforms:

  - i.MX51 ZII RDU1 (SPI-NOR and eMMC)
  - i.MX6Q ZII RDU2 (SPI-NOR and eMMC)
  - VF610 ZII Vybrid Dev Board Rev C. (SPI-NOR)
  - i.MX8MQ NXP EVK (eMMC)
  - i.MX8MQ ZII RDU3 (not supported by upstream Barebox)

Feedback is wellcome!

Changes since [v1]:

    - Added inner-image check for i.MX51 and other v1 users
      (i.MX27/imx_bbu_external_nor_register_handler() is now the only
      user of filetype_unknown)

    - Added pwrite_full() implementation converted corresponding patch
      to use pwrite_full()

    - Added != NULL in "bbu: Remove logical negation in
      barebox_update_handler_exists()" for better clarity

    - Fixed various spelling errors

[v1] http://lists.infradead.org/pipermail/barebox/2018-August/034286.html

Thanks,
Andrey Smirnov

Andrey Smirnov (24):
  ARM: i.MX: bbu: Remove unused define
  filetype: Add arch/ to include path
  filetype: Add code to detect i.MX image v1
  filetype: Add code to detect i.MX image v2
  ARM: i.MX: bbu: Move inner-image type check
  ARM: i.MX: bbu: Drop IMX_INTERNAL_FLAG_NAND
  ARM: i.MX: bbu: Consolidate various update helpers
  ARM: i.MX: bbu: Simplify imx53_bbu_internal_nand_register_handler()
  ARM: i.MX: bbu: Constify all 'devicefile' arguments
  ARM: i.MX: bbu: Detect which platforms need v2 i.MX header
  ARM: i.MX: bbu: Alias imx5*_bbu_internal_mmc_register_handler()
  ARM: i.MX: bbu: Alias imx5*_bbu_internal_spi_i2c_register_handler()
  ARM: i.MX: bbu: Move protect code into a separate routine
  ARM: i.MX: bbu: Adjust FLASH_HEADER_OFFSET_MMC for i.MX8MQ
  ARM: i.MX: bbu: Add support for SPI/I2C on VFxxx
  ARM: i.MX: zii-vf610-dev-rev-b/c: Add support for BBU on SPI-NOR
  ARM: i.MX: bbu: Add support for MMC on i.MX8MQ
  ARM: nxp-imx8mq-evk: Add eMMC BBU configuration
  libfile: Introduce pwrite_full()
  ARM: i.MX: bbu: Use pwrite_full() instead of pwrite()
  bbu: Remove logical negation in barebox_update_handler_exists()
  block: Do not ignore error in blk->ops->write()
  bbu: Report update failures explicitly
  bbu: command: Make sure specified update handler exists

 arch/arm/boards/nxp-imx8mq-evk/board.c |   3 +
 arch/arm/boards/zii-vf610-dev/board.c  |  19 ++
 arch/arm/dts/vf610-zii-dev-rev-b.dts   |  11 +
 arch/arm/mach-imx/imx-bbu-internal.c   | 344 ++++++++++++++-----------
 arch/arm/mach-imx/include/mach/bbu.h   |  60 +++--
 commands/barebox-update.c              |  15 +-
 common/Makefile                        |   1 +
 common/bbu.c                           |  14 +-
 common/block.c                         |  17 +-
 common/filetype.c                      |  11 +
 include/filetype.h                     |   2 +
 include/libfile.h                      |   1 +
 lib/libfile.c                          |  24 ++
 13 files changed, 337 insertions(+), 185 deletions(-)

-- 
2.17.1


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

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

* [PATCH v2 01/24] ARM: i.MX: bbu: Remove unused define
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
@ 2018-08-24  2:52 ` Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 02/24] filetype: Add arch/ to include path Andrey Smirnov
                   ` (23 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/imx-bbu-internal.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index 55e344cff..67ae2961c 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -16,8 +16,6 @@
  * GNU General Public License for more details.
  */
 
-#define IMX_INTERNAL_NAND_BBU
-
 #include <common.h>
 #include <malloc.h>
 #include <bbu.h>
-- 
2.17.1


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

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

* [PATCH v2 02/24] filetype: Add arch/ to include path
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 01/24] ARM: i.MX: bbu: Remove unused define Andrey Smirnov
@ 2018-08-24  2:52 ` Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 03/24] filetype: Add code to detect i.MX image v1 Andrey Smirnov
                   ` (22 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Add arch/ to include path for filetype.o so that it would be possible
to pull in various machine specific constants in.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 common/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/Makefile b/common/Makefile
index b6284c255..13920cc5a 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_DDR_SPD)		+= ddr_spd.o
 obj-$(CONFIG_ENV_HANDLING)	+= environment.o
 obj-$(CONFIG_ENVIRONMENT_VARIABLES) += env.o
 obj-$(CONFIG_FILETYPE)		+= filetype.o
+CFLAGS_filetype.o = -I$(srctree)/arch/
 obj-$(CONFIG_FLEXIBLE_BOOTARGS)	+= bootargs.o
 obj-$(CONFIG_GLOBALVAR)		+= globalvar.o
 obj-$(CONFIG_GREGORIAN_CALENDER) += date.o
-- 
2.17.1


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

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

* [PATCH v2 03/24] filetype: Add code to detect i.MX image v1
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 01/24] ARM: i.MX: bbu: Remove unused define Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 02/24] filetype: Add arch/ to include path Andrey Smirnov
@ 2018-08-24  2:52 ` Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 04/24] filetype: Add code to detect i.MX image v2 Andrey Smirnov
                   ` (21 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Modify file_detect_type() and add code needed to be able to detect
i.MX boot images with v1 header.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 common/filetype.c  | 7 +++++++
 include/filetype.h | 1 +
 2 files changed, 8 insertions(+)

diff --git a/common/filetype.c b/common/filetype.c
index c5f2384a6..8f2be2773 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -29,6 +29,8 @@
 #include <image-sparse.h>
 #include <elf.h>
 
+#include <arm/mach-imx/include/mach/imx-header.h>
+
 struct filetype_str {
 	const char *name;	/* human readable filetype */
 	const char *shortname;	/* short string without spaces for shell scripts */
@@ -71,6 +73,7 @@ static const struct filetype_str filetype_str[] = {
 	[filetype_android_sparse] = { "Android sparse image", "sparse" },
 	[filetype_arm64_linux_image] = { "ARM aarch64 Linux image", "aarch64-linux" },
 	[filetype_elf] = { "ELF", "elf" },
+	[filetype_imx_image_v1] = { "i.MX image (v1)", "imx-image-v1" },
 };
 
 const char *file_type_to_string(enum filetype f)
@@ -250,6 +253,7 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize)
 	const u64 *buf64 = _buf;
 	const u8 *buf8 = _buf;
 	const u16 *buf16 = _buf;
+	const struct imx_flash_header *imx_flash_header = _buf;
 	enum filetype type;
 
 	if (bufsize < 9)
@@ -361,6 +365,9 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize)
 	if (strncmp(buf8, ELFMAG, 4) == 0)
 		return filetype_elf;
 
+	if (imx_flash_header->dcd_barker == DCD_BARKER)
+		return filetype_imx_image_v1;
+
 	return filetype_unknown;
 }
 
diff --git a/include/filetype.h b/include/filetype.h
index 237ed3fbe..e2df5fabf 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -43,6 +43,7 @@ enum filetype {
 	filetype_android_sparse,
 	filetype_arm64_linux_image,
 	filetype_elf,
+	filetype_imx_image_v1,
 	filetype_max,
 };
 
-- 
2.17.1


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

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

* [PATCH v2 04/24] filetype: Add code to detect i.MX image v2
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
                   ` (2 preceding siblings ...)
  2018-08-24  2:52 ` [PATCH v2 03/24] filetype: Add code to detect i.MX image v1 Andrey Smirnov
@ 2018-08-24  2:52 ` Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 05/24] ARM: i.MX: bbu: Move inner-image type check Andrey Smirnov
                   ` (20 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Modify file_detect_type() and add code needed to be able to detect
i.MX boot images with v2 header.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 common/filetype.c  | 4 ++++
 include/filetype.h | 1 +
 2 files changed, 5 insertions(+)

diff --git a/common/filetype.c b/common/filetype.c
index 8f2be2773..f8b6bc895 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -74,6 +74,7 @@ static const struct filetype_str filetype_str[] = {
 	[filetype_arm64_linux_image] = { "ARM aarch64 Linux image", "aarch64-linux" },
 	[filetype_elf] = { "ELF", "elf" },
 	[filetype_imx_image_v1] = { "i.MX image (v1)", "imx-image-v1" },
+	[filetype_imx_image_v2] = { "i.MX image (v2)", "imx-image-v2" },
 };
 
 const char *file_type_to_string(enum filetype f)
@@ -368,6 +369,9 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize)
 	if (imx_flash_header->dcd_barker == DCD_BARKER)
 		return filetype_imx_image_v1;
 
+	if (is_imx_flash_header_v2(_buf))
+		return filetype_imx_image_v2;
+
 	return filetype_unknown;
 }
 
diff --git a/include/filetype.h b/include/filetype.h
index e2df5fabf..395053dd5 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -44,6 +44,7 @@ enum filetype {
 	filetype_arm64_linux_image,
 	filetype_elf,
 	filetype_imx_image_v1,
+	filetype_imx_image_v2,
 	filetype_max,
 };
 
-- 
2.17.1


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

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

* [PATCH v2 05/24] ARM: i.MX: bbu: Move inner-image type check
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
                   ` (3 preceding siblings ...)
  2018-08-24  2:52 ` [PATCH v2 04/24] filetype: Add code to detect i.MX image v2 Andrey Smirnov
@ 2018-08-24  2:52 ` Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 06/24] ARM: i.MX: bbu: Drop IMX_INTERNAL_FLAG_NAND Andrey Smirnov
                   ` (19 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Since imx_bbu_check_prereq() already uses file_detect_type() and we've
extended it to understand i.MX boot image file type, we can simplify a
bunch of repetitive code as follows:

    1. Convert all checks from IVT_BARKER to filetype_imx_image_v2
       check

    2. Move all of the checking to be a part of imx_bbu_check_prereq()

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/imx-bbu-internal.c | 68 ++++++++++++++++++----------
 1 file changed, 43 insertions(+), 25 deletions(-)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index 67ae2961c..b334fe3d8 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -106,11 +106,43 @@ err_close:
 	return ret;
 }
 
-static int imx_bbu_check_prereq(const char *devicefile, struct bbu_data *data)
+static int imx_bbu_check_prereq(struct imx_internal_bbu_handler *imx_handler,
+				const char *devicefile, struct bbu_data *data,
+				enum filetype expected_type)
 {
 	int ret;
-
-	if (file_detect_type(data->image, data->len) != filetype_arm_barebox) {
+	const void *blob;
+	size_t len;
+	enum filetype type;
+
+	type = file_detect_type(data->image, data->len);
+
+	switch (type) {
+	case filetype_arm_barebox:
+		/*
+		 * Specifying expected_type as unknown will disable the
+		 * inner image type check.
+		 *
+		 * The only user of this code is
+		 * imx_bbu_external_nor_register_handler() used by
+		 * i.MX27.
+		 */
+		if (expected_type == filetype_unknown)
+			break;
+
+		blob = data->image + imx_handler->flash_header_offset;
+		len  = data->len   - imx_handler->flash_header_offset;
+		type = file_detect_type(blob, len);
+
+		if (type != expected_type) {
+			pr_err("Expected image type: %s, "
+			       "detected image type: %s\n",
+			       file_type_to_string(expected_type),
+			       file_type_to_string(type));
+			return -EINVAL;
+		}
+		break;
+	default:
 		if (!bbu_force(data, "Not an ARM barebox image"))
 			return -EINVAL;
 	}
@@ -137,7 +169,8 @@ static int imx_bbu_internal_v1_update(struct bbu_handler *handler, struct bbu_da
 		container_of(handler, struct imx_internal_bbu_handler, handler);
 	int ret;
 
-	ret = imx_bbu_check_prereq(data->devicefile, data);
+	ret = imx_bbu_check_prereq(imx_handler, data->devicefile, data,
+				   filetype_imx_image_v1);
 	if (ret)
 		return ret;
 
@@ -319,8 +352,6 @@ out:
 	return ret;
 }
 
-#define IVT_BARKER		0x402000d1
-
 /*
  * Update barebox on a v2 type internal boot (i.MX53)
  *
@@ -333,19 +364,12 @@ static int imx_bbu_internal_v2_update(struct bbu_handler *handler, struct bbu_da
 	struct imx_internal_bbu_handler *imx_handler =
 		container_of(handler, struct imx_internal_bbu_handler, handler);
 	int ret;
-	const uint32_t *barker;
 
-	ret = imx_bbu_check_prereq(data->devicefile, data);
+	ret = imx_bbu_check_prereq(imx_handler, data->devicefile, data,
+				   filetype_imx_image_v2);
 	if (ret)
 		return ret;
 
-	barker = data->image + imx_handler->flash_header_offset;
-
-	if (*barker != IVT_BARKER) {
-		pr_err("Board does not provide DCD data and this image is no imximage\n");
-		return -EINVAL;
-	}
-
 	if (imx_handler->handler.flags & IMX_INTERNAL_FLAG_NAND)
 		ret = imx_bbu_internal_v2_write_nand_dbbt(imx_handler, data);
 	else
@@ -361,18 +385,10 @@ static int imx_bbu_internal_v2_mmcboot_update(struct bbu_handler *handler,
 	struct imx_internal_bbu_handler *imx_handler =
 		container_of(handler, struct imx_internal_bbu_handler, handler);
 	int ret;
-	const uint32_t *barker;
 	char *bootpartvar;
 	const char *bootpart;
 	char *devicefile;
 
-	barker = data->image + imx_handler->flash_header_offset;
-
-	if (*barker != IVT_BARKER) {
-		pr_err("Board does not provide DCD data and this image is no imximage\n");
-		return -EINVAL;
-	}
-
 	ret = asprintf(&bootpartvar, "%s.boot", data->devicefile);
 	if (ret < 0)
 		return ret;
@@ -389,7 +405,8 @@ static int imx_bbu_internal_v2_mmcboot_update(struct bbu_handler *handler,
 	if (ret < 0)
 		goto free_bootpartvar;
 
-	ret = imx_bbu_check_prereq(devicefile, data);
+	ret = imx_bbu_check_prereq(imx_handler, devicefile, data,
+				   filetype_imx_image_v2);
 	if (ret)
 		goto free_devicefile;
 
@@ -414,7 +431,8 @@ static int imx_bbu_external_update(struct bbu_handler *handler, struct bbu_data
 		container_of(handler, struct imx_internal_bbu_handler, handler);
 	int ret;
 
-	ret = imx_bbu_check_prereq(data->devicefile, data);
+	ret = imx_bbu_check_prereq(imx_handler, data->devicefile, data,
+				   filetype_unknown);
 	if (ret)
 		return ret;
 
-- 
2.17.1


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

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

* [PATCH v2 06/24] ARM: i.MX: bbu: Drop IMX_INTERNAL_FLAG_NAND
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
                   ` (4 preceding siblings ...)
  2018-08-24  2:52 ` [PATCH v2 05/24] ARM: i.MX: bbu: Move inner-image type check Andrey Smirnov
@ 2018-08-24  2:52 ` Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 07/24] ARM: i.MX: bbu: Consolidate various update helpers Andrey Smirnov
                   ` (18 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Replace IMX_INTERNAL_FLAG_NAND with a function pointer that can be
customized by individual registration functions. The change by iteself
doesn't have that much value, however it makes the simplification in
the commit that follows more straightforward.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/imx-bbu-internal.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index b334fe3d8..d6e45f13c 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -32,11 +32,12 @@
 
 #define FLASH_HEADER_OFFSET_MMC		0x400
 
-#define IMX_INTERNAL_FLAG_NAND		BIT(31)
 #define IMX_INTERNAL_FLAG_ERASE		BIT(30)
 
 struct imx_internal_bbu_handler {
 	struct bbu_handler handler;
+	int (*write_device)(struct imx_internal_bbu_handler *,
+			    struct bbu_data *);
 	unsigned long flash_header_offset;
 	size_t device_size;
 };
@@ -106,6 +107,13 @@ err_close:
 	return ret;
 }
 
+static int __imx_bbu_write_device(struct imx_internal_bbu_handler *imx_handler,
+				  struct bbu_data *data)
+{
+	return imx_bbu_write_device(imx_handler, data->devicefile, data,
+				    data->image, data->len);
+}
+
 static int imx_bbu_check_prereq(struct imx_internal_bbu_handler *imx_handler,
 				const char *devicefile, struct bbu_data *data,
 				enum filetype expected_type)
@@ -370,13 +378,7 @@ static int imx_bbu_internal_v2_update(struct bbu_handler *handler, struct bbu_da
 	if (ret)
 		return ret;
 
-	if (imx_handler->handler.flags & IMX_INTERNAL_FLAG_NAND)
-		ret = imx_bbu_internal_v2_write_nand_dbbt(imx_handler, data);
-	else
-		ret = imx_bbu_write_device(imx_handler, data->devicefile, data,
-					   data->image, data->len);
-
-	return ret;
+	return imx_handler->write_device(imx_handler, data);
 }
 
 static int imx_bbu_internal_v2_mmcboot_update(struct bbu_handler *handler,
@@ -452,6 +454,8 @@ static struct imx_internal_bbu_handler *__init_handler(const char *name, char *d
 	handler->name = name;
 	handler->flags = flags;
 
+	imx_handler->write_device = __imx_bbu_write_device;
+
 	return imx_handler;
 }
 
@@ -543,13 +547,13 @@ int imx53_bbu_internal_nand_register_handler(const char *name,
 {
 	struct imx_internal_bbu_handler *imx_handler;
 
-	imx_handler = __init_handler(name, NULL, flags |
-				     IMX_INTERNAL_FLAG_NAND);
+	imx_handler = __init_handler(name, NULL, flags);
 	imx_handler->flash_header_offset = FLASH_HEADER_OFFSET_MMC;
 
 	imx_handler->handler.handler = imx_bbu_internal_v2_update;
 	imx_handler->handler.devicefile = "/dev/nand0";
 	imx_handler->device_size = partition_size;
+	imx_handler->write_device = imx_bbu_internal_v2_write_nand_dbbt;
 
 	return __register_handler(imx_handler);
 }
-- 
2.17.1


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

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

* [PATCH v2 07/24] ARM: i.MX: bbu: Consolidate various update helpers
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
                   ` (5 preceding siblings ...)
  2018-08-24  2:52 ` [PATCH v2 06/24] ARM: i.MX: bbu: Drop IMX_INTERNAL_FLAG_NAND Andrey Smirnov
@ 2018-08-24  2:52 ` Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 08/24] ARM: i.MX: bbu: Simplify imx53_bbu_internal_nand_register_handler() Andrey Smirnov
                   ` (17 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

All three, imx_bbu_internal_v1_update(), imx_bbu_external_update() and
imx_bbu_internal_v2_update() are doing exactly the same thing. Instead
of having three almost identical functions, convert
imx_bbu_internal_v2_update() (the most versatile of the three) to be a
generic function and use it everywhere.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/imx-bbu-internal.c | 70 +++++-----------------------
 1 file changed, 12 insertions(+), 58 deletions(-)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index d6e45f13c..1041a0673 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -40,6 +40,7 @@ struct imx_internal_bbu_handler {
 			    struct bbu_data *);
 	unsigned long flash_header_offset;
 	size_t device_size;
+	enum filetype expected_type;
 };
 
 /*
@@ -164,31 +165,6 @@ static int imx_bbu_check_prereq(struct imx_internal_bbu_handler *imx_handler,
 	return 0;
 }
 
-/*
- * Update barebox on a v1 type internal boot (i.MX25, i.MX35, i.MX51)
- *
- * This constructs a DCD header, adds the specific DCD data and writes
- * the resulting image to the device. Currently this handles MMC/SD
- * devices.
- */
-static int imx_bbu_internal_v1_update(struct bbu_handler *handler, struct bbu_data *data)
-{
-	struct imx_internal_bbu_handler *imx_handler =
-		container_of(handler, struct imx_internal_bbu_handler, handler);
-	int ret;
-
-	ret = imx_bbu_check_prereq(imx_handler, data->devicefile, data,
-				   filetype_imx_image_v1);
-	if (ret)
-		return ret;
-
-	pr_info("updating to %s\n", data->devicefile);
-
-	ret = imx_bbu_write_device(imx_handler, data->devicefile, data, data->image, data->len);
-
-	return ret;
-}
-
 #define DBBT_MAGIC	0x44424254
 #define FCB_MAGIC	0x20424346
 
@@ -360,21 +336,14 @@ out:
 	return ret;
 }
 
-/*
- * Update barebox on a v2 type internal boot (i.MX53)
- *
- * This constructs a DCD header, adds the specific DCD data and writes
- * the resulting image to the device. Currently this handles MMC/SD
- * and NAND devices.
- */
-static int imx_bbu_internal_v2_update(struct bbu_handler *handler, struct bbu_data *data)
+static int imx_bbu_update(struct bbu_handler *handler, struct bbu_data *data)
 {
 	struct imx_internal_bbu_handler *imx_handler =
 		container_of(handler, struct imx_internal_bbu_handler, handler);
 	int ret;
 
 	ret = imx_bbu_check_prereq(imx_handler, data->devicefile, data,
-				   filetype_imx_image_v2);
+				   imx_handler->expected_type);
 	if (ret)
 		return ret;
 
@@ -427,21 +396,6 @@ free_bootpartvar:
 	return ret;
 }
 
-static int imx_bbu_external_update(struct bbu_handler *handler, struct bbu_data *data)
-{
-	struct imx_internal_bbu_handler *imx_handler =
-		container_of(handler, struct imx_internal_bbu_handler, handler);
-	int ret;
-
-	ret = imx_bbu_check_prereq(imx_handler, data->devicefile, data,
-				   filetype_unknown);
-	if (ret)
-		return ret;
-
-	return imx_bbu_write_device(imx_handler, data->devicefile, data,
-				    data->image, data->len);
-}
-
 static struct imx_internal_bbu_handler *__init_handler(const char *name, char *devicefile,
 		unsigned long flags)
 {
@@ -453,7 +407,9 @@ static struct imx_internal_bbu_handler *__init_handler(const char *name, char *d
 	handler->devicefile = devicefile;
 	handler->name = name;
 	handler->flags = flags;
+	handler->handler = imx_bbu_update;
 
+	imx_handler->expected_type = filetype_unknown;
 	imx_handler->write_device = __imx_bbu_write_device;
 
 	return imx_handler;
@@ -472,7 +428,8 @@ static int __register_handler(struct imx_internal_bbu_handler *imx_handler)
 
 static int
 imx_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
-				      unsigned long flags, void *handler)
+				      unsigned long flags,
+				      enum filetype expected_type)
 {
 	struct imx_internal_bbu_handler *imx_handler;
 
@@ -480,7 +437,7 @@ imx_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
 				     IMX_BBU_FLAG_KEEP_HEAD);
 	imx_handler->flash_header_offset = FLASH_HEADER_OFFSET_MMC;
 
-	imx_handler->handler.handler = handler;
+	imx_handler->expected_type = expected_type;
 
 	return __register_handler(imx_handler);
 }
@@ -494,8 +451,6 @@ int imx51_bbu_internal_spi_i2c_register_handler(const char *name,
 				     IMX_INTERNAL_FLAG_ERASE);
 	imx_handler->flash_header_offset = FLASH_HEADER_OFFSET_MMC;
 
-	imx_handler->handler.handler = imx_bbu_internal_v1_update;
-
 	return __register_handler(imx_handler);
 }
 
@@ -507,7 +462,7 @@ int imx51_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
 {
 
 	return imx_bbu_internal_mmc_register_handler(name, devicefile, flags,
-						  imx_bbu_internal_v1_update);
+						     filetype_imx_image_v1);
 }
 
 /*
@@ -517,7 +472,7 @@ int imx53_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
 		unsigned long flags)
 {
 	return imx_bbu_internal_mmc_register_handler(name, devicefile, flags,
-						  imx_bbu_internal_v2_update);
+						     filetype_imx_image_v2);
 }
 
 /*
@@ -534,7 +489,7 @@ int imx53_bbu_internal_spi_i2c_register_handler(const char *name, char *devicefi
 				     IMX_INTERNAL_FLAG_ERASE);
 	imx_handler->flash_header_offset = FLASH_HEADER_OFFSET_MMC;
 
-	imx_handler->handler.handler = imx_bbu_internal_v2_update;
+	imx_handler->expected_type = filetype_imx_image_v2;
 
 	return __register_handler(imx_handler);
 }
@@ -550,7 +505,7 @@ int imx53_bbu_internal_nand_register_handler(const char *name,
 	imx_handler = __init_handler(name, NULL, flags);
 	imx_handler->flash_header_offset = FLASH_HEADER_OFFSET_MMC;
 
-	imx_handler->handler.handler = imx_bbu_internal_v2_update;
+	imx_handler->expected_type = filetype_imx_image_v2;
 	imx_handler->handler.devicefile = "/dev/nand0";
 	imx_handler->device_size = partition_size;
 	imx_handler->write_device = imx_bbu_internal_v2_write_nand_dbbt;
@@ -611,7 +566,6 @@ int imx_bbu_external_nor_register_handler(const char *name, char *devicefile,
 
 	imx_handler = __init_handler(name, devicefile, flags |
 				     IMX_INTERNAL_FLAG_ERASE);
-	imx_handler->handler.handler = imx_bbu_external_update;
 
 	return __register_handler(imx_handler);
 }
-- 
2.17.1


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

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

* [PATCH v2 08/24] ARM: i.MX: bbu: Simplify imx53_bbu_internal_nand_register_handler()
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
                   ` (6 preceding siblings ...)
  2018-08-24  2:52 ` [PATCH v2 07/24] ARM: i.MX: bbu: Consolidate various update helpers Andrey Smirnov
@ 2018-08-24  2:52 ` Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 09/24] ARM: i.MX: bbu: Constify all 'devicefile' arguments Andrey Smirnov
                   ` (16 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Second parameter of __init_handler() will initialize
handler.devicefile for us, so there's no need to to it explicitly
after.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/imx-bbu-internal.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index 1041a0673..add353914 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -502,11 +502,10 @@ int imx53_bbu_internal_nand_register_handler(const char *name,
 {
 	struct imx_internal_bbu_handler *imx_handler;
 
-	imx_handler = __init_handler(name, NULL, flags);
+	imx_handler = __init_handler(name, "/dev/nand0", flags);
 	imx_handler->flash_header_offset = FLASH_HEADER_OFFSET_MMC;
 
 	imx_handler->expected_type = filetype_imx_image_v2;
-	imx_handler->handler.devicefile = "/dev/nand0";
 	imx_handler->device_size = partition_size;
 	imx_handler->write_device = imx_bbu_internal_v2_write_nand_dbbt;
 
-- 
2.17.1


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

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

* [PATCH v2 09/24] ARM: i.MX: bbu: Constify all 'devicefile' arguments
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
                   ` (7 preceding siblings ...)
  2018-08-24  2:52 ` [PATCH v2 08/24] ARM: i.MX: bbu: Simplify imx53_bbu_internal_nand_register_handler() Andrey Smirnov
@ 2018-08-24  2:52 ` Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 10/24] ARM: i.MX: bbu: Detect which platforms need v2 i.MX header Andrey Smirnov
                   ` (15 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Constify all 'devicefile' arguments since they are treated as so by
all of the users in BBU code.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/imx-bbu-internal.c | 40 +++++++++++++++++-----------
 arch/arm/mach-imx/include/mach/bbu.h | 40 ++++++++++++++--------------
 2 files changed, 44 insertions(+), 36 deletions(-)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index add353914..be17189f1 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -396,8 +396,9 @@ free_bootpartvar:
 	return ret;
 }
 
-static struct imx_internal_bbu_handler *__init_handler(const char *name, char *devicefile,
-		unsigned long flags)
+static struct imx_internal_bbu_handler *__init_handler(const char *name,
+						       const char *devicefile,
+						       unsigned long flags)
 {
 	struct imx_internal_bbu_handler *imx_handler;
 	struct bbu_handler *handler;
@@ -427,7 +428,7 @@ static int __register_handler(struct imx_internal_bbu_handler *imx_handler)
 }
 
 static int
-imx_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
+imx_bbu_internal_mmc_register_handler(const char *name, const char *devicefile,
 				      unsigned long flags,
 				      enum filetype expected_type)
 {
@@ -443,7 +444,7 @@ imx_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
 }
 
 int imx51_bbu_internal_spi_i2c_register_handler(const char *name,
-		char *devicefile, unsigned long flags)
+		const char *devicefile, unsigned long flags)
 {
 	struct imx_internal_bbu_handler *imx_handler;
 
@@ -457,8 +458,9 @@ int imx51_bbu_internal_spi_i2c_register_handler(const char *name,
 /*
  * Register an i.MX51 internal boot update handler for MMC/SD
  */
-int imx51_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
-		unsigned long flags)
+int imx51_bbu_internal_mmc_register_handler(const char *name,
+					    const char *devicefile,
+					    unsigned long flags)
 {
 
 	return imx_bbu_internal_mmc_register_handler(name, devicefile, flags,
@@ -468,8 +470,9 @@ int imx51_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
 /*
  * Register an i.MX53 internal boot update handler for MMC/SD
  */
-int imx53_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
-		unsigned long flags)
+int imx53_bbu_internal_mmc_register_handler(const char *name,
+					    const char *devicefile,
+					    unsigned long flags)
 {
 	return imx_bbu_internal_mmc_register_handler(name, devicefile, flags,
 						     filetype_imx_image_v2);
@@ -480,8 +483,9 @@ int imx53_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
  * EEPROMs / flashes. Nearly the same as MMC/SD, but we do not need to
  * keep a partition table. We have to erase the device beforehand though.
  */
-int imx53_bbu_internal_spi_i2c_register_handler(const char *name, char *devicefile,
-		unsigned long flags)
+int imx53_bbu_internal_spi_i2c_register_handler(const char *name,
+						const char *devicefile,
+						unsigned long flags)
 {
 	struct imx_internal_bbu_handler *imx_handler;
 
@@ -515,14 +519,16 @@ int imx53_bbu_internal_nand_register_handler(const char *name,
 /*
  * Register an i.MX6 internal boot update handler for MMC/SD
  */
-int imx6_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
+int imx6_bbu_internal_mmc_register_handler(const char *name,
+					   const char *devicefile,
 					   unsigned long flags)
 	__alias(imx53_bbu_internal_mmc_register_handler);
 
 /*
  * Register an VF610 internal boot update handler for MMC/SD
  */
-int vf610_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
+int vf610_bbu_internal_mmc_register_handler(const char *name,
+					    const char *devicefile,
 					    unsigned long flags)
 	__alias(imx6_bbu_internal_mmc_register_handler);
 
@@ -535,7 +541,8 @@ int vf610_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
  * Note that no further partitioning of the boot partition is supported up to
  * now.
  */
-int imx6_bbu_internal_mmcboot_register_handler(const char *name, char *devicefile,
+int imx6_bbu_internal_mmcboot_register_handler(const char *name,
+					       const char *devicefile,
 					       unsigned long flags)
 {
 	struct imx_internal_bbu_handler *imx_handler;
@@ -554,12 +561,13 @@ int imx6_bbu_internal_mmcboot_register_handler(const char *name, char *devicefil
  * keep a partition table. We have to erase the device beforehand though.
  */
 int imx6_bbu_internal_spi_i2c_register_handler(const char *name,
-					       char *devicefile,
+					       const char *devicefile,
 					       unsigned long flags)
 	__alias(imx53_bbu_internal_spi_i2c_register_handler);
 
-int imx_bbu_external_nor_register_handler(const char *name, char *devicefile,
-		unsigned long flags)
+int imx_bbu_external_nor_register_handler(const char *name,
+					  const char *devicefile,
+					  unsigned long flags)
 {
 	struct imx_internal_bbu_handler *imx_handler;
 
diff --git a/arch/arm/mach-imx/include/mach/bbu.h b/arch/arm/mach-imx/include/mach/bbu.h
index b9b2c5bcb..b16766c75 100644
--- a/arch/arm/mach-imx/include/mach/bbu.h
+++ b/arch/arm/mach-imx/include/mach/bbu.h
@@ -32,57 +32,57 @@ struct imx_dcd_v2_entry;
 
 #ifdef CONFIG_BAREBOX_UPDATE
 
-int imx51_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
+int imx51_bbu_internal_mmc_register_handler(const char *name, const char *devicefile,
 		unsigned long flags);
 
 int imx51_bbu_internal_spi_i2c_register_handler(const char *name,
-		char *devicefile, unsigned long flags);
+		const char *devicefile, unsigned long flags);
 
-int imx53_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
+int imx53_bbu_internal_mmc_register_handler(const char *name, const char *devicefile,
 		unsigned long flags);
 
-int imx53_bbu_internal_spi_i2c_register_handler(const char *name, char *devicefile,
+int imx53_bbu_internal_spi_i2c_register_handler(const char *name, const char *devicefile,
 		unsigned long flags);
 
 int imx53_bbu_internal_nand_register_handler(const char *name,
 		unsigned long flags, int partition_size);
 
-int imx6_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
+int imx6_bbu_internal_mmc_register_handler(const char *name, const char *devicefile,
 		unsigned long flags);
 
-int imx6_bbu_internal_mmcboot_register_handler(const char *name, char *devicefile,
+int imx6_bbu_internal_mmcboot_register_handler(const char *name, const char *devicefile,
 		unsigned long flags);
 
-int imx6_bbu_internal_spi_i2c_register_handler(const char *name, char *devicefile,
+int imx6_bbu_internal_spi_i2c_register_handler(const char *name, const char *devicefile,
 		unsigned long flags);
 
-int vf610_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
+int vf610_bbu_internal_mmc_register_handler(const char *name, const char *devicefile,
 		unsigned long flags);
 
-int imx_bbu_external_nor_register_handler(const char *name, char *devicefile,
+int imx_bbu_external_nor_register_handler(const char *name, const char *devicefile,
 		unsigned long flags);
 
 #else
 
-static inline int imx51_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
+static inline int imx51_bbu_internal_mmc_register_handler(const char *name, const char *devicefile,
 		unsigned long flags)
 {
 	return -ENOSYS;
 }
 
 static inline int imx51_bbu_internal_spi_i2c_register_handler(const char *name,
-		char *devicefile, unsigned long flags)
+		const char *devicefile, unsigned long flags)
 {
 	return -ENOSYS;
 }
 
-static inline int imx53_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
+static inline int imx53_bbu_internal_mmc_register_handler(const char *name, const char *devicefile,
 		unsigned long flags)
 {
 	return -ENOSYS;
 }
 
-static inline int imx53_bbu_internal_spi_i2c_register_handler(const char *name, char *devicefile,
+static inline int imx53_bbu_internal_spi_i2c_register_handler(const char *name, const char *devicefile,
 		unsigned long flags)
 {
 	return -ENOSYS;
@@ -94,32 +94,32 @@ static inline int imx53_bbu_internal_nand_register_handler(const char *name,
 	return -ENOSYS;
 }
 
-static inline int imx6_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
+static inline int imx6_bbu_internal_mmc_register_handler(const char *name, const char *devicefile,
 		unsigned long flags)
 {
 	return -ENOSYS;
 }
 
 static inline int imx6_bbu_internal_mmcboot_register_handler(const char *name,
-							     char *devicefile,
+							     const char *devicefile,
 							     unsigned long flags)
 {
 	return -ENOSYS;
 }
 
-static inline int imx6_bbu_internal_spi_i2c_register_handler(const char *name, char *devicefile,
+static inline int imx6_bbu_internal_spi_i2c_register_handler(const char *name, const char *devicefile,
 		unsigned long flags)
 {
 	return -ENOSYS;
 }
 
-static inline int vf610_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
+static inline int vf610_bbu_internal_mmc_register_handler(const char *name, const char *devicefile,
 					    unsigned long flags)
 {
 	return -ENOSYS;
 }
 
-static inline int imx_bbu_external_nor_register_handler(const char *name, char *devicefile,
+static inline int imx_bbu_external_nor_register_handler(const char *name, const char *devicefile,
 		unsigned long flags)
 {
 	return -ENOSYS;
@@ -127,10 +127,10 @@ static inline int imx_bbu_external_nor_register_handler(const char *name, char *
 #endif
 
 #if defined(CONFIG_BAREBOX_UPDATE_IMX_EXTERNAL_NAND)
-int imx_bbu_external_nand_register_handler(const char *name, char *devicefile,
+int imx_bbu_external_nand_register_handler(const char *name, const char *devicefile,
 		unsigned long flags);
 #else
-static inline int imx_bbu_external_nand_register_handler(const char *name, char *devicefile,
+static inline int imx_bbu_external_nand_register_handler(const char *name, const char *devicefile,
 		unsigned long flags)
 {
 	return -ENOSYS;
-- 
2.17.1


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

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

* [PATCH v2 10/24] ARM: i.MX: bbu: Detect which platforms need v2 i.MX header
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
                   ` (8 preceding siblings ...)
  2018-08-24  2:52 ` [PATCH v2 09/24] ARM: i.MX: bbu: Constify all 'devicefile' arguments Andrey Smirnov
@ 2018-08-24  2:52 ` Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 11/24] ARM: i.MX: bbu: Alias imx5*_bbu_internal_mmc_register_handler() Andrey Smirnov
                   ` (14 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Detect which platforms need header v2 based on current CPU type and
replace all of the code explicitly specifying that.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/imx-bbu-internal.c | 32 +++++++++++++++++-----------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index be17189f1..c47a1726a 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -29,6 +29,7 @@
 #include <ioctl.h>
 #include <environment.h>
 #include <mach/bbu.h>
+#include <mach/generic.h>
 
 #define FLASH_HEADER_OFFSET_MMC		0x400
 
@@ -336,6 +337,18 @@ out:
 	return ret;
 }
 
+static enum filetype imx_bbu_expected_filetype(void)
+{
+	if (cpu_is_mx8mq() ||
+	    cpu_is_mx7()   ||
+	    cpu_is_mx6()   ||
+	    cpu_is_vf610() ||
+	    cpu_is_mx53())
+		return filetype_imx_image_v2;
+
+	return filetype_imx_image_v1;
+}
+
 static int imx_bbu_update(struct bbu_handler *handler, struct bbu_data *data)
 {
 	struct imx_internal_bbu_handler *imx_handler =
@@ -410,7 +423,7 @@ static struct imx_internal_bbu_handler *__init_handler(const char *name,
 	handler->flags = flags;
 	handler->handler = imx_bbu_update;
 
-	imx_handler->expected_type = filetype_unknown;
+	imx_handler->expected_type = imx_bbu_expected_filetype();
 	imx_handler->write_device = __imx_bbu_write_device;
 
 	return imx_handler;
@@ -429,8 +442,7 @@ static int __register_handler(struct imx_internal_bbu_handler *imx_handler)
 
 static int
 imx_bbu_internal_mmc_register_handler(const char *name, const char *devicefile,
-				      unsigned long flags,
-				      enum filetype expected_type)
+				      unsigned long flags)
 {
 	struct imx_internal_bbu_handler *imx_handler;
 
@@ -438,8 +450,6 @@ imx_bbu_internal_mmc_register_handler(const char *name, const char *devicefile,
 				     IMX_BBU_FLAG_KEEP_HEAD);
 	imx_handler->flash_header_offset = FLASH_HEADER_OFFSET_MMC;
 
-	imx_handler->expected_type = expected_type;
-
 	return __register_handler(imx_handler);
 }
 
@@ -462,9 +472,7 @@ int imx51_bbu_internal_mmc_register_handler(const char *name,
 					    const char *devicefile,
 					    unsigned long flags)
 {
-
-	return imx_bbu_internal_mmc_register_handler(name, devicefile, flags,
-						     filetype_imx_image_v1);
+	return imx_bbu_internal_mmc_register_handler(name, devicefile, flags);
 }
 
 /*
@@ -474,8 +482,7 @@ int imx53_bbu_internal_mmc_register_handler(const char *name,
 					    const char *devicefile,
 					    unsigned long flags)
 {
-	return imx_bbu_internal_mmc_register_handler(name, devicefile, flags,
-						     filetype_imx_image_v2);
+	return imx_bbu_internal_mmc_register_handler(name, devicefile, flags);
 }
 
 /*
@@ -493,8 +500,6 @@ int imx53_bbu_internal_spi_i2c_register_handler(const char *name,
 				     IMX_INTERNAL_FLAG_ERASE);
 	imx_handler->flash_header_offset = FLASH_HEADER_OFFSET_MMC;
 
-	imx_handler->expected_type = filetype_imx_image_v2;
-
 	return __register_handler(imx_handler);
 }
 
@@ -509,7 +514,6 @@ int imx53_bbu_internal_nand_register_handler(const char *name,
 	imx_handler = __init_handler(name, "/dev/nand0", flags);
 	imx_handler->flash_header_offset = FLASH_HEADER_OFFSET_MMC;
 
-	imx_handler->expected_type = filetype_imx_image_v2;
 	imx_handler->device_size = partition_size;
 	imx_handler->write_device = imx_bbu_internal_v2_write_nand_dbbt;
 
@@ -574,5 +578,7 @@ int imx_bbu_external_nor_register_handler(const char *name,
 	imx_handler = __init_handler(name, devicefile, flags |
 				     IMX_INTERNAL_FLAG_ERASE);
 
+	imx_handler->expected_type = filetype_unknown;
+
 	return __register_handler(imx_handler);
 }
-- 
2.17.1


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

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

* [PATCH v2 11/24] ARM: i.MX: bbu: Alias imx5*_bbu_internal_mmc_register_handler()
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
                   ` (9 preceding siblings ...)
  2018-08-24  2:52 ` [PATCH v2 10/24] ARM: i.MX: bbu: Detect which platforms need v2 i.MX header Andrey Smirnov
@ 2018-08-24  2:52 ` Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 12/24] ARM: i.MX: bbu: Alias imx5*_bbu_internal_spi_i2c_register_handler() Andrey Smirnov
                   ` (13 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Alias imx5*_bbu_internal_mmc_register_handler() to
imx_bbu_internal_mmc_register_handler()

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/imx-bbu-internal.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index c47a1726a..d45fe1b68 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -471,9 +471,7 @@ int imx51_bbu_internal_spi_i2c_register_handler(const char *name,
 int imx51_bbu_internal_mmc_register_handler(const char *name,
 					    const char *devicefile,
 					    unsigned long flags)
-{
-	return imx_bbu_internal_mmc_register_handler(name, devicefile, flags);
-}
+	__alias(imx_bbu_internal_mmc_register_handler);
 
 /*
  * Register an i.MX53 internal boot update handler for MMC/SD
@@ -481,9 +479,7 @@ int imx51_bbu_internal_mmc_register_handler(const char *name,
 int imx53_bbu_internal_mmc_register_handler(const char *name,
 					    const char *devicefile,
 					    unsigned long flags)
-{
-	return imx_bbu_internal_mmc_register_handler(name, devicefile, flags);
-}
+	__alias(imx_bbu_internal_mmc_register_handler);
 
 /*
  * Register an i.MX6 internal boot update handler for i2c/spi
-- 
2.17.1


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

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

* [PATCH v2 12/24] ARM: i.MX: bbu: Alias imx5*_bbu_internal_spi_i2c_register_handler()
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
                   ` (10 preceding siblings ...)
  2018-08-24  2:52 ` [PATCH v2 11/24] ARM: i.MX: bbu: Alias imx5*_bbu_internal_mmc_register_handler() Andrey Smirnov
@ 2018-08-24  2:52 ` Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 13/24] ARM: i.MX: bbu: Move protect code into a separate routine Andrey Smirnov
                   ` (12 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Alias imx5*_bbu_internal_spi_i2c_register_handler() to a common function.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/imx-bbu-internal.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index d45fe1b68..fef3797a1 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -453,8 +453,10 @@ imx_bbu_internal_mmc_register_handler(const char *name, const char *devicefile,
 	return __register_handler(imx_handler);
 }
 
-int imx51_bbu_internal_spi_i2c_register_handler(const char *name,
-		const char *devicefile, unsigned long flags)
+static int
+imx_bbu_internal_spi_i2c_register_handler(const char *name,
+					  const char *devicefile,
+					  unsigned long flags)
 {
 	struct imx_internal_bbu_handler *imx_handler;
 
@@ -465,6 +467,11 @@ int imx51_bbu_internal_spi_i2c_register_handler(const char *name,
 	return __register_handler(imx_handler);
 }
 
+int imx51_bbu_internal_spi_i2c_register_handler(const char *name,
+						const char *devicefile,
+						unsigned long flags)
+	__alias(imx_bbu_internal_spi_i2c_register_handler);
+
 /*
  * Register an i.MX51 internal boot update handler for MMC/SD
  */
@@ -489,15 +496,7 @@ int imx53_bbu_internal_mmc_register_handler(const char *name,
 int imx53_bbu_internal_spi_i2c_register_handler(const char *name,
 						const char *devicefile,
 						unsigned long flags)
-{
-	struct imx_internal_bbu_handler *imx_handler;
-
-	imx_handler = __init_handler(name, devicefile, flags |
-				     IMX_INTERNAL_FLAG_ERASE);
-	imx_handler->flash_header_offset = FLASH_HEADER_OFFSET_MMC;
-
-	return __register_handler(imx_handler);
-}
+	__alias(imx_bbu_internal_spi_i2c_register_handler);
 
 /*
  * Register an i.MX53 internal boot update handler for NAND
-- 
2.17.1


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

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

* [PATCH v2 13/24] ARM: i.MX: bbu: Move protect code into a separate routine
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
                   ` (11 preceding siblings ...)
  2018-08-24  2:52 ` [PATCH v2 12/24] ARM: i.MX: bbu: Alias imx5*_bbu_internal_spi_i2c_register_handler() Andrey Smirnov
@ 2018-08-24  2:52 ` Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 14/24] ARM: i.MX: bbu: Adjust FLASH_HEADER_OFFSET_MMC for i.MX8MQ Andrey Smirnov
                   ` (11 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Both code sections responsible for enabling/disabling underlying
device write protection are almost identical to each other. To avoid
code duplication move them into a separate routine and adjust the rest
of the code accordignly.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/imx-bbu-internal.c | 62 +++++++++++++++++++---------
 1 file changed, 42 insertions(+), 20 deletions(-)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index fef3797a1..12d48401d 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -44,6 +44,41 @@ struct imx_internal_bbu_handler {
 	enum filetype expected_type;
 };
 
+static bool
+imx_bbu_erase_required(struct imx_internal_bbu_handler *imx_handler)
+{
+	return imx_handler->handler.flags & IMX_INTERNAL_FLAG_ERASE;
+}
+
+static int imx_bbu_protect(int fd, struct imx_internal_bbu_handler *imx_handler,
+			   const char *devicefile, int offset, int image_len,
+			   int prot)
+{
+	const char *prefix = prot ? "" : "un";
+	int ret;
+
+	if (!imx_bbu_erase_required(imx_handler))
+		return 0;
+
+	pr_debug("%s: %sprotecting %s from 0x%08x to 0x%08x\n", __func__,
+		 prefix, devicefile, offset, image_len);
+
+	ret = protect(fd, image_len, offset, prot);
+	if (ret) {
+		/*
+		 * If protect() is not implemented for this device,
+		 * just report success
+		 */
+		if (ret == -ENOSYS)
+			return 0;
+
+		pr_err("%sprotecting %s failed with %s\n", prefix, devicefile,
+		       strerror(-ret));
+	}
+
+	return ret;
+}
+
 /*
  * Actually write an image to the target device, eventually keeping a
  * DOS partition table on the device
@@ -67,16 +102,12 @@ static int imx_bbu_write_device(struct imx_internal_bbu_handler *imx_handler,
 	if (imx_handler->handler.flags & IMX_BBU_FLAG_KEEP_HEAD)
 		offset += imx_handler->flash_header_offset;
 
-	if (imx_handler->handler.flags & IMX_INTERNAL_FLAG_ERASE) {
-		pr_debug("%s: unprotecting %s from 0x%08x to 0x%08x\n", __func__,
-				devicefile, offset, image_len);
-		ret = protect(fd, image_len, offset, 0);
-		if (ret && ret != -ENOSYS) {
-			pr_err("unprotecting %s failed with %s\n", devicefile,
-					strerror(-ret));
-			goto err_close;
-		}
+	ret = imx_bbu_protect(fd, imx_handler, devicefile, offset,
+			      image_len, 0);
+	if (ret)
+		goto err_close;
 
+	if (imx_bbu_erase_required(imx_handler)) {
 		pr_debug("%s: erasing %s from 0x%08x to 0x%08x\n", __func__,
 				devicefile, offset, image_len);
 		ret = erase(fd, image_len, offset);
@@ -91,17 +122,8 @@ static int imx_bbu_write_device(struct imx_internal_bbu_handler *imx_handler,
 	if (ret < 0)
 		goto err_close;
 
-	if (imx_handler->handler.flags & IMX_INTERNAL_FLAG_ERASE) {
-		pr_debug("%s: protecting %s from 0x%08x to 0x%08x\n", __func__,
-				devicefile, offset, image_len);
-		ret = protect(fd, image_len, offset, 1);
-		if (ret && ret != -ENOSYS) {
-			pr_err("protecting %s failed with %s\n", devicefile,
-					strerror(-ret));
-		}
-	}
-
-	ret = 0;
+	imx_bbu_protect(fd, imx_handler, devicefile, offset,
+			image_len, 1);
 
 err_close:
 	close(fd);
-- 
2.17.1


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

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

* [PATCH v2 14/24] ARM: i.MX: bbu: Adjust FLASH_HEADER_OFFSET_MMC for i.MX8MQ
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
                   ` (12 preceding siblings ...)
  2018-08-24  2:52 ` [PATCH v2 13/24] ARM: i.MX: bbu: Move protect code into a separate routine Andrey Smirnov
@ 2018-08-24  2:52 ` Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 15/24] ARM: i.MX: bbu: Add support for SPI/I2C on VFxxx Andrey Smirnov
                   ` (10 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Flash header is located at 33KiB mark on i.MX8MQ, so we need to take
that into account when initializing imx_handler->flash_header_offset.

Convert FLASH_HEADER_OFFSET_MMC into a function call that will check
if Barebox is running on i.MX8MQ CPU and adjust the offset
accordingly.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/imx-bbu-internal.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index 12d48401d..c1b3d9ce8 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -31,8 +31,6 @@
 #include <mach/bbu.h>
 #include <mach/generic.h>
 
-#define FLASH_HEADER_OFFSET_MMC		0x400
-
 #define IMX_INTERNAL_FLAG_ERASE		BIT(30)
 
 struct imx_internal_bbu_handler {
@@ -371,6 +369,20 @@ static enum filetype imx_bbu_expected_filetype(void)
 	return filetype_imx_image_v1;
 }
 
+static unsigned long imx_bbu_flash_header_offset_mmc(void)
+{
+	unsigned long offset = SZ_1K;
+
+	/*
+	 * i.MX8MQ moved the header by 32K to accomodate for GPT
+	 * partition tables
+	 */
+	if (cpu_is_mx8mq())
+		offset += SZ_32K;
+
+	return offset;
+}
+
 static int imx_bbu_update(struct bbu_handler *handler, struct bbu_data *data)
 {
 	struct imx_internal_bbu_handler *imx_handler =
@@ -470,7 +482,7 @@ imx_bbu_internal_mmc_register_handler(const char *name, const char *devicefile,
 
 	imx_handler = __init_handler(name, devicefile, flags |
 				     IMX_BBU_FLAG_KEEP_HEAD);
-	imx_handler->flash_header_offset = FLASH_HEADER_OFFSET_MMC;
+	imx_handler->flash_header_offset = imx_bbu_flash_header_offset_mmc();
 
 	return __register_handler(imx_handler);
 }
@@ -484,7 +496,7 @@ imx_bbu_internal_spi_i2c_register_handler(const char *name,
 
 	imx_handler = __init_handler(name, devicefile, flags |
 				     IMX_INTERNAL_FLAG_ERASE);
-	imx_handler->flash_header_offset = FLASH_HEADER_OFFSET_MMC;
+	imx_handler->flash_header_offset = imx_bbu_flash_header_offset_mmc();
 
 	return __register_handler(imx_handler);
 }
@@ -529,7 +541,7 @@ int imx53_bbu_internal_nand_register_handler(const char *name,
 	struct imx_internal_bbu_handler *imx_handler;
 
 	imx_handler = __init_handler(name, "/dev/nand0", flags);
-	imx_handler->flash_header_offset = FLASH_HEADER_OFFSET_MMC;
+	imx_handler->flash_header_offset = imx_bbu_flash_header_offset_mmc();
 
 	imx_handler->device_size = partition_size;
 	imx_handler->write_device = imx_bbu_internal_v2_write_nand_dbbt;
@@ -569,7 +581,7 @@ int imx6_bbu_internal_mmcboot_register_handler(const char *name,
 	struct imx_internal_bbu_handler *imx_handler;
 
 	imx_handler = __init_handler(name, devicefile, flags);
-	imx_handler->flash_header_offset = FLASH_HEADER_OFFSET_MMC;
+	imx_handler->flash_header_offset = imx_bbu_flash_header_offset_mmc();
 
 	imx_handler->handler.handler = imx_bbu_internal_v2_mmcboot_update;
 
-- 
2.17.1


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

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

* [PATCH v2 15/24] ARM: i.MX: bbu: Add support for SPI/I2C on VFxxx
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
                   ` (13 preceding siblings ...)
  2018-08-24  2:52 ` [PATCH v2 14/24] ARM: i.MX: bbu: Adjust FLASH_HEADER_OFFSET_MMC for i.MX8MQ Andrey Smirnov
@ 2018-08-24  2:52 ` Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 16/24] ARM: i.MX: zii-vf610-dev-rev-b/c: Add support for BBU on SPI-NOR Andrey Smirnov
                   ` (9 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/imx-bbu-internal.c | 10 ++++++++++
 arch/arm/mach-imx/include/mach/bbu.h | 11 +++++++++++
 2 files changed, 21 insertions(+)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index c1b3d9ce8..ecc885d29 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -598,6 +598,16 @@ int imx6_bbu_internal_spi_i2c_register_handler(const char *name,
 					       unsigned long flags)
 	__alias(imx53_bbu_internal_spi_i2c_register_handler);
 
+/*
+ * Register an VFxxx internal boot update handler for i2c/spi
+ * EEPROMs / flashes. Nearly the same as MMC/SD, but we do not need to
+ * keep a partition table. We have to erase the device beforehand though.
+ */
+int vf610_bbu_internal_spi_i2c_register_handler(const char *name,
+						const char *devicefile,
+						unsigned long flags)
+	__alias(imx6_bbu_internal_spi_i2c_register_handler);
+
 int imx_bbu_external_nor_register_handler(const char *name,
 					  const char *devicefile,
 					  unsigned long flags)
diff --git a/arch/arm/mach-imx/include/mach/bbu.h b/arch/arm/mach-imx/include/mach/bbu.h
index b16766c75..d543d0e92 100644
--- a/arch/arm/mach-imx/include/mach/bbu.h
+++ b/arch/arm/mach-imx/include/mach/bbu.h
@@ -59,6 +59,9 @@ int imx6_bbu_internal_spi_i2c_register_handler(const char *name, const char *dev
 int vf610_bbu_internal_mmc_register_handler(const char *name, const char *devicefile,
 		unsigned long flags);
 
+int vf610_bbu_internal_spi_i2c_register_handler(const char *name, const char *devicefile,
+						unsigned long flags);
+
 int imx_bbu_external_nor_register_handler(const char *name, const char *devicefile,
 		unsigned long flags);
 
@@ -124,6 +127,14 @@ static inline int imx_bbu_external_nor_register_handler(const char *name, const
 {
 	return -ENOSYS;
 }
+
+static inline int
+vf610_bbu_internal_spi_i2c_register_handler(const char *name, char *devicefile,
+					    unsigned long flags)
+{
+	return -ENOSYS;
+}
+
 #endif
 
 #if defined(CONFIG_BAREBOX_UPDATE_IMX_EXTERNAL_NAND)
-- 
2.17.1


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

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

* [PATCH v2 16/24] ARM: i.MX: zii-vf610-dev-rev-b/c: Add support for BBU on SPI-NOR
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
                   ` (14 preceding siblings ...)
  2018-08-24  2:52 ` [PATCH v2 15/24] ARM: i.MX: bbu: Add support for SPI/I2C on VFxxx Andrey Smirnov
@ 2018-08-24  2:52 ` Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 17/24] ARM: i.MX: bbu: Add support for MMC on i.MX8MQ Andrey Smirnov
                   ` (8 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/boards/zii-vf610-dev/board.c | 19 +++++++++++++++++++
 arch/arm/dts/vf610-zii-dev-rev-b.dts  | 11 +++++++++++
 2 files changed, 30 insertions(+)

diff --git a/arch/arm/boards/zii-vf610-dev/board.c b/arch/arm/boards/zii-vf610-dev/board.c
index d88b26164..818044ce6 100644
--- a/arch/arm/boards/zii-vf610-dev/board.c
+++ b/arch/arm/boards/zii-vf610-dev/board.c
@@ -149,6 +149,25 @@ static int zii_vf610_dev_set_hostname(void)
 }
 late_initcall(zii_vf610_dev_set_hostname);
 
+static int zii_vf610_dev_register_bbu(void)
+{
+	int ret;
+	if (!of_machine_is_compatible("zii,vf610dev-c") &&
+	    !of_machine_is_compatible("zii,vf610dev-b"))
+		return 0;
+
+	ret = vf610_bbu_internal_spi_i2c_register_handler("SPI",
+							  "/dev/m25p0.bootloader",
+							  0);
+	if (ret) {
+		pr_err("Failed to register SPI BBU handler");
+		return ret;
+	}
+
+	return 0;
+}
+late_initcall(zii_vf610_dev_register_bbu);
+
 static int zii_vf610_spu3_register_bbu(void)
 {
 	int ret;
diff --git a/arch/arm/dts/vf610-zii-dev-rev-b.dts b/arch/arm/dts/vf610-zii-dev-rev-b.dts
index 1eb01f44a..ac0807c49 100644
--- a/arch/arm/dts/vf610-zii-dev-rev-b.dts
+++ b/arch/arm/dts/vf610-zii-dev-rev-b.dts
@@ -45,3 +45,14 @@
 #include <arm/vf610-zii-dev-rev-b.dts>
 
 #include "vf610-zii-dev.dtsi"
+
+/ {
+	spi0 {
+		m25p128@0 {
+			partition@0 {
+				label = "bootloader";
+				reg = <0x0 0x100000>;
+			};
+		};
+	};
+};
-- 
2.17.1


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

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

* [PATCH v2 17/24] ARM: i.MX: bbu: Add support for MMC on i.MX8MQ
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
                   ` (15 preceding siblings ...)
  2018-08-24  2:52 ` [PATCH v2 16/24] ARM: i.MX: zii-vf610-dev-rev-b/c: Add support for BBU on SPI-NOR Andrey Smirnov
@ 2018-08-24  2:52 ` Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 18/24] ARM: nxp-imx8mq-evk: Add eMMC BBU configuration Andrey Smirnov
                   ` (7 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/imx-bbu-internal.c | 8 ++++++++
 arch/arm/mach-imx/include/mach/bbu.h | 9 +++++++++
 2 files changed, 17 insertions(+)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index ecc885d29..59fe6218e 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -565,6 +565,14 @@ int vf610_bbu_internal_mmc_register_handler(const char *name,
 					    unsigned long flags)
 	__alias(imx6_bbu_internal_mmc_register_handler);
 
+/*
+ * Register an i.MX8MQ internal boot update handler for MMC/SD
+ */
+int imx8mq_bbu_internal_mmc_register_handler(const char *name,
+					     const char *devicefile,
+					     unsigned long flags)
+	__alias(imx6_bbu_internal_mmc_register_handler);
+
 /*
  * Register a handler that writes to the non-active boot partition of an mmc
  * medium and on success activates the written-to partition. So the machine can
diff --git a/arch/arm/mach-imx/include/mach/bbu.h b/arch/arm/mach-imx/include/mach/bbu.h
index d543d0e92..b30403328 100644
--- a/arch/arm/mach-imx/include/mach/bbu.h
+++ b/arch/arm/mach-imx/include/mach/bbu.h
@@ -62,6 +62,9 @@ int vf610_bbu_internal_mmc_register_handler(const char *name, const char *device
 int vf610_bbu_internal_spi_i2c_register_handler(const char *name, const char *devicefile,
 						unsigned long flags);
 
+int imx8mq_bbu_internal_mmc_register_handler(const char *name, const char *devicefile,
+					     unsigned long flags);
+
 int imx_bbu_external_nor_register_handler(const char *name, const char *devicefile,
 		unsigned long flags);
 
@@ -122,6 +125,12 @@ static inline int vf610_bbu_internal_mmc_register_handler(const char *name, cons
 	return -ENOSYS;
 }
 
+static inline int imx8mq_bbu_internal_mmc_register_handler(const char *name, const char *devicefile,
+							   unsigned long flags);
+{
+	return -ENOSYS;
+}
+
 static inline int imx_bbu_external_nor_register_handler(const char *name, const char *devicefile,
 		unsigned long flags)
 {
-- 
2.17.1


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

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

* [PATCH v2 18/24] ARM: nxp-imx8mq-evk: Add eMMC BBU configuration
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
                   ` (16 preceding siblings ...)
  2018-08-24  2:52 ` [PATCH v2 17/24] ARM: i.MX: bbu: Add support for MMC on i.MX8MQ Andrey Smirnov
@ 2018-08-24  2:52 ` Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 19/24] libfile: Introduce pwrite_full() Andrey Smirnov
                   ` (6 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Add BBU configuration to allow programming Barebox to eMMC. Normally
factory U-Boot is shipped in mmc0.boot0, so us using user partition
for Barebox should allow those two to coexist.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/boards/nxp-imx8mq-evk/board.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/boards/nxp-imx8mq-evk/board.c b/arch/arm/boards/nxp-imx8mq-evk/board.c
index d93e21da1..868c25ebb 100644
--- a/arch/arm/boards/nxp-imx8mq-evk/board.c
+++ b/arch/arm/boards/nxp-imx8mq-evk/board.c
@@ -21,6 +21,7 @@
 #include <init.h>
 #include <asm/memory.h>
 #include <linux/sizes.h>
+#include <mach/bbu.h>
 
 static int imx8mq_evk_mem_init(void)
 {
@@ -39,6 +40,8 @@ static int nxp_imx8mq_evk_init(void)
 
 	barebox_set_hostname("imx8mq-evk");
 
+	imx8mq_bbu_internal_mmc_register_handler("eMMC", "/dev/mmc0", 0);
+
 	return 0;
 }
 device_initcall(nxp_imx8mq_evk_init);
-- 
2.17.1


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

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

* [PATCH v2 19/24] libfile: Introduce pwrite_full()
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
                   ` (17 preceding siblings ...)
  2018-08-24  2:52 ` [PATCH v2 18/24] ARM: nxp-imx8mq-evk: Add eMMC BBU configuration Andrey Smirnov
@ 2018-08-24  2:52 ` Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 20/24] ARM: i.MX: bbu: Use pwrite_full() instead of pwrite() Andrey Smirnov
                   ` (5 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Analogous to what we have with write()/write_full(), introduce a
lightweight wrapper around pwrite() that guarantees the either all
data is going to be written or a negative error code would be
returned.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 include/libfile.h |  1 +
 lib/libfile.c     | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/include/libfile.h b/include/libfile.h
index 2c5eef71f..f1d695187 100644
--- a/include/libfile.h
+++ b/include/libfile.h
@@ -1,6 +1,7 @@
 #ifndef __LIBFILE_H
 #define __LIBFILE_H
 
+int pwrite_full(int fd, const void *buf, size_t size, loff_t offset);
 int write_full(int fd, const void *buf, size_t size);
 int read_full(int fd, void *buf, size_t size);
 
diff --git a/lib/libfile.c b/lib/libfile.c
index 0052e789f..39c85b2fc 100644
--- a/lib/libfile.c
+++ b/lib/libfile.c
@@ -23,6 +23,30 @@
 #include <stdlib.h>
 #include <linux/stat.h>
 
+/*
+ * pwrite_full - write to filedescriptor at offset
+ *
+ * Like pwrite, but guarantees to write the full buffer out, else it
+ * returns with an error.
+ */
+int pwrite_full(int fd, const void *buf, size_t size, loff_t offset)
+{
+	size_t insize = size;
+	int now;
+
+	while (size) {
+		now = pwrite(fd, buf, size, offset);
+		if (now <= 0)
+			return now;
+		size -= now;
+		buf += now;
+		offset += now;
+	}
+
+	return insize;
+}
+EXPORT_SYMBOL(pwrite_full);
+
 /*
  * write_full - write to filedescriptor
  *
-- 
2.17.1


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

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

* [PATCH v2 20/24] ARM: i.MX: bbu: Use pwrite_full() instead of pwrite()
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
                   ` (18 preceding siblings ...)
  2018-08-24  2:52 ` [PATCH v2 19/24] libfile: Introduce pwrite_full() Andrey Smirnov
@ 2018-08-24  2:52 ` Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 21/24] bbu: Remove logical negation in barebox_update_handler_exists() Andrey Smirnov
                   ` (4 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Use pwrite_full() instead of pwrite() to make sure that all of the
data was written to target device. While at it adjust return value of
imx_bbu_write_device() to be zero in case of success.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/imx-bbu-internal.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index 59fe6218e..504e359bc 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -30,6 +30,7 @@
 #include <environment.h>
 #include <mach/bbu.h>
 #include <mach/generic.h>
+#include <libfile.h>
 
 #define IMX_INTERNAL_FLAG_ERASE		BIT(30)
 
@@ -116,9 +117,12 @@ static int imx_bbu_write_device(struct imx_internal_bbu_handler *imx_handler,
 		}
 	}
 
-	ret = pwrite(fd, buf, image_len, offset);
-	if (ret < 0)
+	ret = pwrite_full(fd, buf, image_len, offset);
+	if (ret < 0) {
+		pr_err("writing to %s failed with %s\n", devicefile,
+		       strerror(-ret));
 		goto err_close;
+	}
 
 	imx_bbu_protect(fd, imx_handler, devicefile, offset,
 			image_len, 1);
@@ -126,7 +130,7 @@ static int imx_bbu_write_device(struct imx_internal_bbu_handler *imx_handler,
 err_close:
 	close(fd);
 
-	return ret;
+	return ret < 0 ? ret : 0;
 }
 
 static int __imx_bbu_write_device(struct imx_internal_bbu_handler *imx_handler,
-- 
2.17.1


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

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

* [PATCH v2 21/24] bbu: Remove logical negation in barebox_update_handler_exists()
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
                   ` (19 preceding siblings ...)
  2018-08-24  2:52 ` [PATCH v2 20/24] ARM: i.MX: bbu: Use pwrite_full() instead of pwrite() Andrey Smirnov
@ 2018-08-24  2:52 ` Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 22/24] block: Do not ignore error in blk->ops->write() Andrey Smirnov
                   ` (3 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Returning !bbu_find_handler() from barebox_update_handler_exists()
would return the opposite result from what the name of that funciton
implies. Drop the "!" to make it behave as expected.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 common/bbu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/bbu.c b/common/bbu.c
index 11e44f4a7..9e206227a 100644
--- a/common/bbu.c
+++ b/common/bbu.c
@@ -151,7 +151,7 @@ bool barebox_update_handler_exists(struct bbu_data *data)
 	if (!data->handler_name)
 		return false;
 
-	return !bbu_find_handler(data->handler_name);
+	return bbu_find_handler(data->handler_name) != NULL;
 }
 
 static int bbu_check_of_compat(struct bbu_data *data)
-- 
2.17.1


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

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

* [PATCH v2 22/24] block: Do not ignore error in blk->ops->write()
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
                   ` (20 preceding siblings ...)
  2018-08-24  2:52 ` [PATCH v2 21/24] bbu: Remove logical negation in barebox_update_handler_exists() Andrey Smirnov
@ 2018-08-24  2:52 ` Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 23/24] bbu: Report update failures explicitly Andrey Smirnov
                   ` (2 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Getting a error from blk->ops->write() is not a very unlikely
event (happens quite often during new board bringup), so we need to
catch and propagate them to upper layers so they can be at least
reported properly. Change the code of all of the callers to bail out
as soon as blk->ops->write() fails.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 common/block.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/common/block.c b/common/block.c
index 219b943af..8d0de42d9 100644
--- a/common/block.c
+++ b/common/block.c
@@ -44,13 +44,17 @@ struct chunk {
 static int writebuffer_flush(struct block_device *blk)
 {
 	struct chunk *chunk;
+	int ret;
 
 	if (!IS_ENABLED(CONFIG_BLOCK_WRITE))
 		return 0;
 
 	list_for_each_entry(chunk, &blk->buffered_blocks, list) {
 		if (chunk->dirty) {
-			blk->ops->write(blk, chunk->data, chunk->block_start, blk->rdbufsize);
+			ret = blk->ops->write(blk, chunk->data, chunk->block_start, blk->rdbufsize);
+			if (ret < 0)
+				return ret;
+
 			chunk->dirty = 0;
 		}
 	}
@@ -107,6 +111,7 @@ static void *block_get_cached(struct block_device *blk, int block)
 static struct chunk *get_chunk(struct block_device *blk)
 {
 	struct chunk *chunk;
+	int ret;
 
 	if (list_empty(&blk->idle_blocks)) {
 		/* use last entry which is the most unused */
@@ -114,8 +119,11 @@ static struct chunk *get_chunk(struct block_device *blk)
 		if (chunk->dirty) {
 			size_t num_blocks = min(blk->rdbufsize,
 					blk->num_blocks - chunk->block_start);
-			blk->ops->write(blk, chunk->data, chunk->block_start,
-					num_blocks);
+			ret = blk->ops->write(blk, chunk->data, chunk->block_start,
+					      num_blocks);
+			if (ret < 0)
+				return ERR_PTR(ret);
+
 			chunk->dirty = 0;
 		}
 
@@ -140,6 +148,9 @@ static int block_cache(struct block_device *blk, int block)
 	int ret;
 
 	chunk = get_chunk(blk);
+	if (IS_ERR(chunk))
+		return PTR_ERR(chunk);
+
 	chunk->block_start = block & ~blk->blkmask;
 
 	debug("%s: %d to %d\n", __func__, chunk->block_start,
-- 
2.17.1


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

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

* [PATCH v2 23/24] bbu: Report update failures explicitly
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
                   ` (21 preceding siblings ...)
  2018-08-24  2:52 ` [PATCH v2 22/24] block: Do not ignore error in blk->ops->write() Andrey Smirnov
@ 2018-08-24  2:52 ` Andrey Smirnov
  2018-08-24  2:52 ` [PATCH v2 24/24] bbu: command: Make sure specified update handler exists Andrey Smirnov
  2018-08-24  8:09 ` [PATCH v2 00/24] i.MX BBU improvements and bugfixes Sascha Hauer
  24 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Change the code of barebox_update() to explicitly log that update
failed instead of failing silently (unless update was interrupted) and
relying on user checking the return code.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 common/bbu.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/common/bbu.c b/common/bbu.c
index 9e206227a..3974bf672 100644
--- a/common/bbu.c
+++ b/common/bbu.c
@@ -260,13 +260,13 @@ int barebox_update(struct bbu_data *data)
 		return ret;
 
 	ret = handler->handler(handler, data);
-	if (ret == -EINTR)
-		printf("update aborted\n");
-
-	if (!ret)
-		printf("update succeeded\n");
+	if (ret) {
+		printf("update %s\n", (ret == -EINTR) ? "aborted" : "failed");
+		return ret;
+	}
 
-	return ret;
+	printf("update succeeded\n");
+	return 0;
 }
 
 /*
-- 
2.17.1


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

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

* [PATCH v2 24/24] bbu: command: Make sure specified update handler exists
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
                   ` (22 preceding siblings ...)
  2018-08-24  2:52 ` [PATCH v2 23/24] bbu: Report update failures explicitly Andrey Smirnov
@ 2018-08-24  2:52 ` Andrey Smirnov
  2018-08-24  8:09 ` [PATCH v2 00/24] i.MX BBU improvements and bugfixes Sascha Hauer
  24 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2018-08-24  2:52 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Add code to verify that update handler specified with either -t or of
-d exists before commencing the update procedure.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 commands/barebox-update.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/commands/barebox-update.c b/commands/barebox-update.c
index 84798ab0d..f76aa19a5 100644
--- a/commands/barebox-update.c
+++ b/commands/barebox-update.c
@@ -24,6 +24,12 @@
 #include <bbu.h>
 #include <fs.h>
 
+static void print_handlers_list(void)
+{
+	printf("registered update handlers:\n");
+	bbu_handlers_list();
+}
+
 static int do_barebox_update(int argc, char *argv[])
 {
 	int opt, ret, repair = 0;
@@ -46,8 +52,7 @@ static int do_barebox_update(int argc, char *argv[])
 			data.flags |= BBU_FLAG_YES;
 			break;
 		case 'l':
-			printf("registered update handlers:\n");
-			bbu_handlers_list();
+			print_handlers_list();
 			return 0;
 		case 'r':
 			repair = 1;
@@ -57,6 +62,12 @@ static int do_barebox_update(int argc, char *argv[])
 		}
 	}
 
+	if (!barebox_update_handler_exists(&data)) {
+		printf("handler '%s' does not exist\n", data.handler_name);
+		print_handlers_list();
+		return COMMAND_ERROR;
+	}
+
 	if (argc - optind > 0) {
 		data.imagefile = argv[optind];
 
-- 
2.17.1


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

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

* Re: [PATCH v2 00/24] i.MX BBU improvements and bugfixes
  2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
                   ` (23 preceding siblings ...)
  2018-08-24  2:52 ` [PATCH v2 24/24] bbu: command: Make sure specified update handler exists Andrey Smirnov
@ 2018-08-24  8:09 ` Sascha Hauer
  24 siblings, 0 replies; 26+ messages in thread
From: Sascha Hauer @ 2018-08-24  8:09 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox

On Thu, Aug 23, 2018 at 07:52:19PM -0700, Andrey Smirnov wrote:
> Everyone:
> 
> This series is the result simplification, bugfixing and adding
> features to some of the code in BBU subsytem:
> 
>   - Patches 1 - 13 are a number of code simplifications intended to
>     minimize amount of duplicated code as well as generic improvements
>     (IMHO)
> 
>   - Patches 14 - 18 are i.MX8MQ and VF610 related changes
> 
>   - Patches 19 - 24 are a result of discovering that a number of error
>     cases were silently ignored and not reported as update
>     failures. Patch 22 is technically not related to BBU at all, but
>     since I discovered the problem while working on this series, I
>     kept it as a part of this series

Applied, thanks

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] 26+ messages in thread

end of thread, other threads:[~2018-08-24  8:15 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-24  2:52 [PATCH v2 00/24] i.MX BBU improvements and bugfixes Andrey Smirnov
2018-08-24  2:52 ` [PATCH v2 01/24] ARM: i.MX: bbu: Remove unused define Andrey Smirnov
2018-08-24  2:52 ` [PATCH v2 02/24] filetype: Add arch/ to include path Andrey Smirnov
2018-08-24  2:52 ` [PATCH v2 03/24] filetype: Add code to detect i.MX image v1 Andrey Smirnov
2018-08-24  2:52 ` [PATCH v2 04/24] filetype: Add code to detect i.MX image v2 Andrey Smirnov
2018-08-24  2:52 ` [PATCH v2 05/24] ARM: i.MX: bbu: Move inner-image type check Andrey Smirnov
2018-08-24  2:52 ` [PATCH v2 06/24] ARM: i.MX: bbu: Drop IMX_INTERNAL_FLAG_NAND Andrey Smirnov
2018-08-24  2:52 ` [PATCH v2 07/24] ARM: i.MX: bbu: Consolidate various update helpers Andrey Smirnov
2018-08-24  2:52 ` [PATCH v2 08/24] ARM: i.MX: bbu: Simplify imx53_bbu_internal_nand_register_handler() Andrey Smirnov
2018-08-24  2:52 ` [PATCH v2 09/24] ARM: i.MX: bbu: Constify all 'devicefile' arguments Andrey Smirnov
2018-08-24  2:52 ` [PATCH v2 10/24] ARM: i.MX: bbu: Detect which platforms need v2 i.MX header Andrey Smirnov
2018-08-24  2:52 ` [PATCH v2 11/24] ARM: i.MX: bbu: Alias imx5*_bbu_internal_mmc_register_handler() Andrey Smirnov
2018-08-24  2:52 ` [PATCH v2 12/24] ARM: i.MX: bbu: Alias imx5*_bbu_internal_spi_i2c_register_handler() Andrey Smirnov
2018-08-24  2:52 ` [PATCH v2 13/24] ARM: i.MX: bbu: Move protect code into a separate routine Andrey Smirnov
2018-08-24  2:52 ` [PATCH v2 14/24] ARM: i.MX: bbu: Adjust FLASH_HEADER_OFFSET_MMC for i.MX8MQ Andrey Smirnov
2018-08-24  2:52 ` [PATCH v2 15/24] ARM: i.MX: bbu: Add support for SPI/I2C on VFxxx Andrey Smirnov
2018-08-24  2:52 ` [PATCH v2 16/24] ARM: i.MX: zii-vf610-dev-rev-b/c: Add support for BBU on SPI-NOR Andrey Smirnov
2018-08-24  2:52 ` [PATCH v2 17/24] ARM: i.MX: bbu: Add support for MMC on i.MX8MQ Andrey Smirnov
2018-08-24  2:52 ` [PATCH v2 18/24] ARM: nxp-imx8mq-evk: Add eMMC BBU configuration Andrey Smirnov
2018-08-24  2:52 ` [PATCH v2 19/24] libfile: Introduce pwrite_full() Andrey Smirnov
2018-08-24  2:52 ` [PATCH v2 20/24] ARM: i.MX: bbu: Use pwrite_full() instead of pwrite() Andrey Smirnov
2018-08-24  2:52 ` [PATCH v2 21/24] bbu: Remove logical negation in barebox_update_handler_exists() Andrey Smirnov
2018-08-24  2:52 ` [PATCH v2 22/24] block: Do not ignore error in blk->ops->write() Andrey Smirnov
2018-08-24  2:52 ` [PATCH v2 23/24] bbu: Report update failures explicitly Andrey Smirnov
2018-08-24  2:52 ` [PATCH v2 24/24] bbu: command: Make sure specified update handler exists Andrey Smirnov
2018-08-24  8:09 ` [PATCH v2 00/24] i.MX BBU improvements and bugfixes Sascha Hauer

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