mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/2] ARM: i.MX: Add bootm support for i.MX flash header v3 images
@ 2024-10-30 14:59 Sascha Hauer
  2024-10-30 15:00 ` [PATCH 1/2] filetype: detect i.MX flash header v3 Sascha Hauer
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sascha Hauer @ 2024-10-30 14:59 UTC (permalink / raw)
  To: open list:BAREBOX

On i.MX9 and some i.MX8 SoCs the barebox images are encapsulated in the
i.MX flash header v3 format. This series adds support for detecting and
chainloading them via bootm command.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
Sascha Hauer (2):
      filetype: detect i.MX flash header v3
      ARM: i.MX: Add bootm handler for i.MX flash header v3 images

 arch/arm/mach-imx/Makefile       |  2 +-
 arch/arm/mach-imx/imx-v3-image.c | 50 ++++++++++++++++++++++++++++++++++++++++
 common/filetype.c                |  4 ++++
 include/filetype.h               |  1 +
 4 files changed, 56 insertions(+), 1 deletion(-)
---
base-commit: e55e492573e33823f25935ee00fe7fa7bf2c5c90
change-id: 20241030-imx-flash-header-v3-4298015d3ce2

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




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

* [PATCH 1/2] filetype: detect i.MX flash header v3
  2024-10-30 14:59 [PATCH 0/2] ARM: i.MX: Add bootm support for i.MX flash header v3 images Sascha Hauer
@ 2024-10-30 15:00 ` Sascha Hauer
  2024-10-30 15:00 ` [PATCH 2/2] ARM: i.MX: Add bootm handler for i.MX flash header v3 images Sascha Hauer
  2024-11-08 10:57 ` [PATCH 0/2] ARM: i.MX: Add bootm support " Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2024-10-30 15:00 UTC (permalink / raw)
  To: open list:BAREBOX

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/filetype.c  | 4 ++++
 include/filetype.h | 1 +
 2 files changed, 5 insertions(+)

diff --git a/common/filetype.c b/common/filetype.c
index 67ae4916d1..73ea17e19b 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -70,6 +70,7 @@ static const struct filetype_str filetype_str[] = {
 	[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" },
+	[filetype_imx_image_v3] = { "i.MX image (v3)", "imx-image-v3" },
 	[filetype_layerscape_image] = { "Layerscape image", "layerscape-PBL" },
 	[filetype_layerscape_qspi_image] = { "Layerscape QSPI image", "layerscape-qspi-PBL" },
 	[filetype_nxp_fspi_image] = { "NXP FlexSPI image", "nxp-fspi-image" },
@@ -432,6 +433,9 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize)
 	if (buf[8] == 0xAA995566 && buf[9] == 0x584C4E58)
 		return filetype_zynq_image;
 
+	if (buf8[0] == 0x0 && buf8[3] == 0x87)
+		return filetype_imx_image_v3;
+
 	return filetype_unknown;
 }
 
diff --git a/include/filetype.h b/include/filetype.h
index 6425c9c8c5..c24d061e8f 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -51,6 +51,7 @@ enum filetype {
 	filetype_elf,
 	filetype_imx_image_v1,
 	filetype_imx_image_v2,
+	filetype_imx_image_v3,
 	filetype_layerscape_image,
 	filetype_layerscape_qspi_image,
 	filetype_ubootvar,

-- 
2.39.5




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

* [PATCH 2/2] ARM: i.MX: Add bootm handler for i.MX flash header v3 images
  2024-10-30 14:59 [PATCH 0/2] ARM: i.MX: Add bootm support for i.MX flash header v3 images Sascha Hauer
  2024-10-30 15:00 ` [PATCH 1/2] filetype: detect i.MX flash header v3 Sascha Hauer
@ 2024-10-30 15:00 ` Sascha Hauer
  2024-11-08 10:57 ` [PATCH 0/2] ARM: i.MX: Add bootm support " Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2024-10-30 15:00 UTC (permalink / raw)
  To: open list:BAREBOX

This adds support for chainloading barebox images in the i.MX flash
header v3 format as found on i.MX9 and some i.MX8 SoCs,

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-imx/Makefile       |  2 +-
 arch/arm/mach-imx/imx-v3-image.c | 50 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 22ea48a833..23f51fc660 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -19,7 +19,7 @@ obj-$(CONFIG_ARCH_IMX7) += imx7.o
 obj-$(CONFIG_ARCH_VF610) += vf610.o
 obj-pbl-$(CONFIG_ARCH_IMX8M) += imx8m.o
 obj-pbl-$(CONFIG_ARCH_IMX_SCRATCHMEM) += scratch.o
-obj-$(CONFIG_ARCH_IMX9) += imx9.o
+obj-$(CONFIG_ARCH_IMX9) += imx9.o imx-v3-image.o
 lwl-$(CONFIG_ARCH_IMX_ATF) += atf.o
 obj-pbl-$(CONFIG_ARCH_IMX8M) += tzasc.o
 obj-pbl-$(CONFIG_ARCH_IMX_ROMAPI) += romapi.o
diff --git a/arch/arm/mach-imx/imx-v3-image.c b/arch/arm/mach-imx/imx-v3-image.c
new file mode 100644
index 0000000000..e5df5fdb81
--- /dev/null
+++ b/arch/arm/mach-imx/imx-v3-image.c
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <common.h>
+#include <bootm.h>
+#include <memory.h>
+#include <init.h>
+#include <soc/imx9/flash_header.h>
+
+static int do_bootm_imx_image_v3(struct image_data *data)
+{
+	void (*bb)(void);
+	resource_size_t start, end;
+	struct flash_header_v3 *hdr;
+	u32 offset;
+	int ret;
+
+	ret = memory_bank_first_find_space(&start, &end);
+	if (ret)
+		return ret;
+
+	ret = bootm_load_os(data, start);
+	if (ret)
+		return ret;
+
+	hdr = (void *)start;
+	offset = hdr->img[0].offset;
+
+	if (data->verbose)
+		printf("Loaded barebox image to 0x%08llx\n", start);
+
+	shutdown_barebox();
+
+	bb = (void *)start + offset;
+
+	bb();
+
+	return -EIO;
+}
+
+static struct image_handler imx_image_v3_handler = {
+	.name = "",
+	.bootm = do_bootm_imx_image_v3,
+	.filetype = filetype_imx_image_v3,
+};
+
+static int imx_register_image_v3_handler(void)
+{
+	return register_image_handler(&imx_image_v3_handler);
+}
+late_initcall(imx_register_image_v3_handler);

-- 
2.39.5




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

* Re: [PATCH 0/2] ARM: i.MX: Add bootm support for i.MX flash header v3 images
  2024-10-30 14:59 [PATCH 0/2] ARM: i.MX: Add bootm support for i.MX flash header v3 images Sascha Hauer
  2024-10-30 15:00 ` [PATCH 1/2] filetype: detect i.MX flash header v3 Sascha Hauer
  2024-10-30 15:00 ` [PATCH 2/2] ARM: i.MX: Add bootm handler for i.MX flash header v3 images Sascha Hauer
@ 2024-11-08 10:57 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2024-11-08 10:57 UTC (permalink / raw)
  To: open list:BAREBOX, Sascha Hauer


On Wed, 30 Oct 2024 15:59:59 +0100, Sascha Hauer wrote:
> On i.MX9 and some i.MX8 SoCs the barebox images are encapsulated in the
> i.MX flash header v3 format. This series adds support for detecting and
> chainloading them via bootm command.
> 
> 

Applied, thanks!

[1/2] filetype: detect i.MX flash header v3
      https://git.pengutronix.de/cgit/barebox/commit/?id=4a62bf7493ce (link may not be stable)
[2/2] ARM: i.MX: Add bootm handler for i.MX flash header v3 images
      https://git.pengutronix.de/cgit/barebox/commit/?id=ce829430232d (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




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

end of thread, other threads:[~2024-11-08 11:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-30 14:59 [PATCH 0/2] ARM: i.MX: Add bootm support for i.MX flash header v3 images Sascha Hauer
2024-10-30 15:00 ` [PATCH 1/2] filetype: detect i.MX flash header v3 Sascha Hauer
2024-10-30 15:00 ` [PATCH 2/2] ARM: i.MX: Add bootm handler for i.MX flash header v3 images Sascha Hauer
2024-11-08 10:57 ` [PATCH 0/2] ARM: i.MX: Add bootm support " Sascha Hauer

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