public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH 1/2] imx: kontron-sl-mx8mm: Adjust offset for U-Boot proper in case of eMMC fastboot
@ 2025-11-04 10:30 Frieder Schrempf
  2025-11-04 10:30 ` [PATCH 2/2] imx: kontron-sl-mx8mm: Implement spl_board_loader_name() Frieder Schrempf
  2025-11-04 18:07 ` [PATCH 1/2] imx: kontron-sl-mx8mm: Adjust offset for U-Boot proper in case of eMMC fastboot Fabio Estevam
  0 siblings, 2 replies; 3+ messages in thread
From: Frieder Schrempf @ 2025-11-04 10:30 UTC (permalink / raw)
  To: Stefano Babic, Fabio Estevam, Frieder Schrempf, Tom Rini, u-boot
  Cc: NXP i . MX U-Boot Team

From: Frieder Schrempf <frieder.schrempf@kontron.de>

The image offset on SD/MMC devices is 33 KiB, except for eMMC boot if
fastboot is enabled. In this case it is 1 KiB. In order to make the
the bootloader universal, check the fastboot OTP boot fuse and adjust
the offset.

Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
---
 board/kontron/sl-mx8mm/spl.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/board/kontron/sl-mx8mm/spl.c b/board/kontron/sl-mx8mm/spl.c
index e3b029752b8..50eb0eb13e1 100644
--- a/board/kontron/sl-mx8mm/spl.c
+++ b/board/kontron/sl-mx8mm/spl.c
@@ -186,6 +186,26 @@ static int power_init_board(void)
 	return 0;
 }
 
+unsigned long board_spl_mmc_get_uboot_raw_sector(struct mmc *mmc, unsigned long raw_sect)
+{
+	/*
+	 * The image offset on SD/MMC devices is 33 KiB, except for eMMC boot if
+	 * fastboot is enabled. In this case it is 1 KiB. In order to make the
+	 * bootloader universal, check the fastboot OTP boot fuse and adjust
+	 * the offset.
+	 */
+	if (!IS_SD(mmc) && (readl(OCOTP_BASE_ADDR + 0x470) & 0x80)) {
+		switch (EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config)) {
+		case EMMC_BOOT_PART_BOOT1:
+		case EMMC_BOOT_PART_BOOT2:
+			raw_sect -= 32 * 2;
+			break;
+		}
+	}
+
+	return raw_sect;
+}
+
 void board_init_f(ulong dummy)
 {
 	int ret;
-- 
2.51.0


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

* [PATCH 2/2] imx: kontron-sl-mx8mm: Implement spl_board_loader_name()
  2025-11-04 10:30 [PATCH 1/2] imx: kontron-sl-mx8mm: Adjust offset for U-Boot proper in case of eMMC fastboot Frieder Schrempf
@ 2025-11-04 10:30 ` Frieder Schrempf
  2025-11-04 18:07 ` [PATCH 1/2] imx: kontron-sl-mx8mm: Adjust offset for U-Boot proper in case of eMMC fastboot Fabio Estevam
  1 sibling, 0 replies; 3+ messages in thread
From: Frieder Schrempf @ 2025-11-04 10:30 UTC (permalink / raw)
  To: Stefano Babic, Fabio Estevam, Frieder Schrempf, Tom Rini, u-boot
  Cc: NXP i . MX U-Boot Team

From: Frieder Schrempf <frieder.schrempf@kontron.de>

This allows to print user-friendly names for the boot device
probed by SPL to the console.

Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
---
 board/kontron/sl-mx8mm/spl.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/board/kontron/sl-mx8mm/spl.c b/board/kontron/sl-mx8mm/spl.c
index 50eb0eb13e1..a5cdd2ab6d1 100644
--- a/board/kontron/sl-mx8mm/spl.c
+++ b/board/kontron/sl-mx8mm/spl.c
@@ -206,6 +206,33 @@ unsigned long board_spl_mmc_get_uboot_raw_sector(struct mmc *mmc, unsigned long
 	return raw_sect;
 }
 
+const char *spl_board_loader_name(u32 boot_device)
+{
+	static char name[16];
+	struct mmc *mmc;
+
+	switch (boot_device) {
+	case BOOT_DEVICE_SPI:
+		sprintf(name, "SPI NOR");
+		return name;
+	case BOOT_DEVICE_MMC1:
+		mmc_init_device(0);
+		mmc = find_mmc_device(0);
+		mmc_init(mmc);
+		snprintf(name, sizeof(name), "eMMC %s",
+			 emmc_hwpart_names[EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config)]);
+		return name;
+	case BOOT_DEVICE_MMC2:
+		sprintf(name, "SD card");
+		return name;
+	case BOOT_DEVICE_BOARD:
+		sprintf(name, "USB OTG");
+		return name;
+	}
+
+	return NULL;
+}
+
 void board_init_f(ulong dummy)
 {
 	int ret;
-- 
2.51.0


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

* Re: [PATCH 1/2] imx: kontron-sl-mx8mm: Adjust offset for U-Boot proper in case of eMMC fastboot
  2025-11-04 10:30 [PATCH 1/2] imx: kontron-sl-mx8mm: Adjust offset for U-Boot proper in case of eMMC fastboot Frieder Schrempf
  2025-11-04 10:30 ` [PATCH 2/2] imx: kontron-sl-mx8mm: Implement spl_board_loader_name() Frieder Schrempf
@ 2025-11-04 18:07 ` Fabio Estevam
  1 sibling, 0 replies; 3+ messages in thread
From: Fabio Estevam @ 2025-11-04 18:07 UTC (permalink / raw)
  To: Frieder Schrempf
  Cc: Stefano Babic, Frieder Schrempf, Tom Rini, u-boot,
	NXP i . MX U-Boot Team

On Tue, Nov 4, 2025 at 7:30 AM Frieder Schrempf <frieder@fris.de> wrote:
>
> From: Frieder Schrempf <frieder.schrempf@kontron.de>
>
> The image offset on SD/MMC devices is 33 KiB, except for eMMC boot if
> fastboot is enabled. In this case it is 1 KiB. In order to make the
> the bootloader universal, check the fastboot OTP boot fuse and adjust
> the offset.
>
> Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>

Applied the series, thanks.

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

end of thread, other threads:[~2025-11-04 18:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-04 10:30 [PATCH 1/2] imx: kontron-sl-mx8mm: Adjust offset for U-Boot proper in case of eMMC fastboot Frieder Schrempf
2025-11-04 10:30 ` [PATCH 2/2] imx: kontron-sl-mx8mm: Implement spl_board_loader_name() Frieder Schrempf
2025-11-04 18:07 ` [PATCH 1/2] imx: kontron-sl-mx8mm: Adjust offset for U-Boot proper in case of eMMC fastboot Fabio Estevam

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