[PATCH v2 1/3] ARM: i.MX8MP: bbu: fix wrong flash header offset for eMMC boot partition

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux