[PATCH 17/21] ARM: i.MX: bbu: add target device offset

Marco Felsch m.felsch at pengutronix.de
Thu Mar 9 02:40:49 PST 2023


Make it possible to specify a custom target device offset. This is
required for the upcoming i.MX8MN/P QSPI update handler which reuse the
common update handler logic. For i.MX8MN/P QSPI boot the image must be
written to a 4K target-device-offset but before that we need to strip
the SD flash-header-offset:

     Generic-Image			Target
       +-------+  0x0                 +-------+ 0x0
       |  .... |                      |  .... |
       +-------+ flash-header-offset  +-------+ target-device-offset
       |  FCFB |                      |  FCFB |
       +-------+                      +-------+
       |  .... |                      |  .... |
       +-------+                      +-------+
       |  IVT  |                      |  IVT  |
       +-------+                      +-------+
       |  .... |                      |  .... |
       +-------+                      +-------+

Signed-off-by: Marco Felsch <m.felsch at pengutronix.de>
---
 arch/arm/mach-imx/imx-bbu-internal.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index 8eca0783eb..066b7c0002 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -26,6 +26,7 @@ struct imx_internal_bbu_handler {
 	int (*write_device)(struct imx_internal_bbu_handler *,
 			    struct bbu_data *);
 	unsigned long flash_header_offset;
+	unsigned long target_device_offset;
 	size_t device_size;
 	enum filetype expected_type;
 };
@@ -89,6 +90,9 @@ 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->target_device_offset)
+		offset += imx_handler->target_device_offset;
+
 	ret = fstat(fd, &st);
 	if (ret)
 		goto err_close;

-- 
2.30.2




More information about the barebox mailing list