mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 1/3] ARM: i.MX8MP: bbu: fix wrong flash header offset for eMMC boot partition
@ 2021-08-30 11:51 Ahmad Fatoum
  2021-08-30 11:51 ` [PATCH v2 2/3] mci: imx-esdhc-pbl: support eMMC boot partitions on i.MX8MP Ahmad Fatoum
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2021-08-30 11:51 UTC (permalink / raw)
  To: barebox; +Cc: lst, ukl, rcz, Ahmad Fatoum

According to the reference manual of the i.MX8MP, the bootrom expects
the bootloader to sit directly at the start of the eMMC boot partition.

The 32K offset is only valid for eMMC user partitions and SD.
Tell barebox_update about this, so it can strip away the first 32K
when writing to an eMMC boot partition.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
  - fix wrong use of flash header offset: This refers to offset in file,
    but we want to change offset on disk. There is a knob for that
    (IMX_BBU_FLAG_PARTITION_STARTS_AT_HEADER), so use that instead

Tested on i.MX8MN.
---
 arch/arm/mach-imx/imx-bbu-internal.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index 880f8b249642..91e1785d18e0 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -393,6 +393,18 @@ static unsigned long imx_bbu_flash_header_offset_mmc(void)
 	return SZ_1K;
 }
 
+static unsigned long imx_bbu_flash_header_offset_mmcboot(unsigned long *flags)
+{
+	/*
+	 * i.MX8MP places IVT directly at start of eMMC boot partition. IVT
+	 * in eMMC user partition and SD is at 32K offset.
+	 */
+	if (cpu_is_mx8mp())
+		*flags |= IMX_BBU_FLAG_PARTITION_STARTS_AT_HEADER;
+
+	return imx_bbu_flash_header_offset_mmc();
+}
+
 static int imx_bbu_update(struct bbu_handler *handler, struct bbu_data *data)
 {
 	struct imx_internal_bbu_handler *imx_handler =
@@ -606,9 +618,12 @@ static int imx_bbu_internal_mmcboot_register_handler(const char *name,
 						     unsigned long flags)
 {
 	struct imx_internal_bbu_handler *imx_handler;
+	unsigned long flash_header_offset;
+
+	flash_header_offset = imx_bbu_flash_header_offset_mmcboot(&flags);
 
 	imx_handler = __init_handler(name, devicefile, flags);
-	imx_handler->flash_header_offset = imx_bbu_flash_header_offset_mmc();
+	imx_handler->flash_header_offset = flash_header_offset;
 
 	imx_handler->handler.handler = imx_bbu_internal_mmcboot_update;
 
-- 
2.30.2


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


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

end of thread, other threads:[~2021-10-04 11:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-30 11:51 [PATCH v2 1/3] ARM: i.MX8MP: bbu: fix wrong flash header offset for eMMC boot partition Ahmad Fatoum
2021-08-30 11:51 ` [PATCH v2 2/3] mci: imx-esdhc-pbl: support eMMC boot partitions on i.MX8MP Ahmad Fatoum
2021-10-04 10:56   ` Sascha Hauer
2021-10-04 11:00     ` Ahmad Fatoum
2021-10-04 11:41       ` Sascha Hauer
2021-08-30 11:51 ` [PATCH v2 3/3] ARM: i.MX8MP: EVK: change bbu handler from eMMC user to boot partition Ahmad Fatoum
2021-08-31  9:42 ` [PATCH v2 1/3] ARM: i.MX8MP: bbu: fix wrong flash header offset for eMMC " Rouven Czerwinski

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