Skip to contentSkip to conversation

mvebu: clearfog: add support for emmc boot

PATCH In review Josua Mayer 2 participants 7 messages Oct 25, 2023 – Oct 27, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover mvebu: clearfog: add support for emmc boot

On Armada 388 booting from eMMC is different to SD-Card in two major ways:

- Environment location
- Sectors scanned by Boot-ROM

This patchset first makes it possible to select offset 4096 for eMMC partition. Here U-Boot can be placed to avoid conflict conflict with MBR.

Secondly the bubt command is updated to use LBA-4096 for eMMC data partition only, keeping previous values for SD and boot0/1 unchanged

Changes since v1:

- New defconfigs for environment location are skipped in this version, pending further research if it can be auto-detected.

- invert logic of if statement allowing it to compile both with, and without CONFIG_SUPPORT_EMMC_BOOT defined. Reported by Stefan Roese with turris_mox_defconfig, thanks!

Josua Mayer (2):
arm: mvebu: allow additional 4096 offset for bootable mmc image
cmd: mvebu/bubt: move eMMC data-partition uboot from LBA-0 to 4096

 arch/arm/mach-mvebu/spl.c |  5 +++--
 cmd/mvebu/bubt.c          | 11 +++++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)
Signature · 1 line
2.35.3
#1 lore raw

PATCH v2 1/2 arm: mvebu: allow additional 4096 offset for bootable mmc image

Disarm the error message forcing u-boot/spl image to be located at sector 0 on eMMC data-partition and microSD.
Offset 0 makes sense on eMMC boot partitions only, data partition must use 4096 to avoid conflicting with MBR.

Valid offsets when booting from microSD, reported by boot-rom v1.73:

BootROM: Bad header at offset 00000200
BootROM: Bad header at offset 00004400
BootROM: Bad header at offset 00200000
BootROM: Bad header at offset 00400000
BootROM: Bad header at offset 00600000
BootROM: Bad header at offset 00800000
BootROM: Bad header at offset 00A00000
BootROM: Bad header at offset 00C00000
BootROM: Bad header at offset 00E00000
BootROM: Bad header at offset 01000000
BootROM: Bad header at offset 01200000
BootROM: Bad header at offset 01400000
BootROM: Bad header at offset 01600000
BootROM: Bad header at offset 01800000
BootROM: Bad header at offset 01A00000
BootROM: Bad header at offset 01C00000
BootROM: Bad header at offset 01E00000
BootROM: Bad header at offset 02000000
BootROM: Bad header at offset 02200000
BootROM: Bad header at offset 02400000
BootROM: Bad header at offset 02600000
BootROM: Bad header at offset 02800000
BootROM: Bad header at offset 02A00000
BootROM: Bad header at offset 02C00000
BootROM: Bad header at offset 02E00000

Valid offsets when booting from eMMC:

BootROM: Bad header at offset 00000000
BootROM: Bad header at offset 00200000 Switching BootPartitions.
BootROM: Bad header at offset 00000000
BootROM: Bad header at offset 00200000

Fixes 2226ca17348 ("arm: mvebu: Load U-Boot proper binary in SPL code based on kwbimage header")
---
 arch/arm/mach-mvebu/spl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/mach-mvebu/spl.c +3 -2
index eaaa68a8564..79f8877745b 100644
@@ -71,8 +71,9 @@
 #error CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR must be set to 0
 #endif
 #if !defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET) || \
-    CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET != 0
-#error CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET must be set to 0
+    (CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET != 0 && \
+     CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET != 4096)
+#error CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET must be set to either 0 or 4096
 #endif
 #endif
 
Signature · 1 line
2.35.3
Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] arm: mvebu: allow additional 4096 offset for bootable mmc image

Quoted 41 lines · Josua Mayer

Disarm the error message forcing u-boot/spl image to be located at sector 0 on eMMC data-partition and microSD.
Offset 0 makes sense on eMMC boot partitions only, data partition must use 4096 to avoid conflicting with MBR.

Valid offsets when booting from microSD, reported by boot-rom v1.73:

BootROM: Bad header at offset 00000200
BootROM: Bad header at offset 00004400
BootROM: Bad header at offset 00200000
BootROM: Bad header at offset 00400000
BootROM: Bad header at offset 00600000
BootROM: Bad header at offset 00800000
BootROM: Bad header at offset 00A00000
BootROM: Bad header at offset 00C00000
BootROM: Bad header at offset 00E00000
BootROM: Bad header at offset 01000000
BootROM: Bad header at offset 01200000
BootROM: Bad header at offset 01400000
BootROM: Bad header at offset 01600000
BootROM: Bad header at offset 01800000
BootROM: Bad header at offset 01A00000
BootROM: Bad header at offset 01C00000
BootROM: Bad header at offset 01E00000
BootROM: Bad header at offset 02000000
BootROM: Bad header at offset 02200000
BootROM: Bad header at offset 02400000
BootROM: Bad header at offset 02600000
BootROM: Bad header at offset 02800000
BootROM: Bad header at offset 02A00000
BootROM: Bad header at offset 02C00000
BootROM: Bad header at offset 02E00000

Valid offsets when booting from eMMC:

BootROM: Bad header at offset 00000000
BootROM: Bad header at offset 00200000 Switching BootPartitions.
BootROM: Bad header at offset 00000000
BootROM: Bad header at offset 00200000

Quoted 3 lines
Fixes 2226ca17348 ("arm: mvebu: Load U-Boot proper binary in SPL code based on kwbimage header")

Thanks,
Stefan

Quoted 10 lines
---
  arch/arm/mach-mvebu/spl.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/mach-mvebu/spl.c +0 -0
index eaaa68a8564..79f8877745b 100644
@@ -71,8 +71,9 @@
  #error CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR must be set to 0

arch/arm/mach-mvebu/spl.c line 79

Quoted 10 lines
arch/arm/mach-mvebu/spl.c +3 -2
  #endif
  #if !defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET) || \
-    CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET != 0
-#error CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET must be set to 0
+    (CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET != 0 && \
+     CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET != 4096)
+#error CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET must be set to either 0 or 4096
  #endif
  #endif
 

Viele Grüße,
Stefan Roese

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
#3 lore raw

Re: [PATCH v2 1/2] arm: mvebu: allow additional 4096 offset for bootable mmc image

Quoted 42 lines · Stefan Roese
Quoted 41 lines · Josua Mayer

Disarm the error message forcing u-boot/spl image to be located at sector 0 on eMMC data-partition and microSD.
Offset 0 makes sense on eMMC boot partitions only, data partition must use 4096 to avoid conflicting with MBR.

Valid offsets when booting from microSD, reported by boot-rom v1.73:

BootROM: Bad header at offset 00000200
BootROM: Bad header at offset 00004400
BootROM: Bad header at offset 00200000
BootROM: Bad header at offset 00400000
BootROM: Bad header at offset 00600000
BootROM: Bad header at offset 00800000
BootROM: Bad header at offset 00A00000
BootROM: Bad header at offset 00C00000
BootROM: Bad header at offset 00E00000
BootROM: Bad header at offset 01000000
BootROM: Bad header at offset 01200000
BootROM: Bad header at offset 01400000
BootROM: Bad header at offset 01600000
BootROM: Bad header at offset 01800000
BootROM: Bad header at offset 01A00000
BootROM: Bad header at offset 01C00000
BootROM: Bad header at offset 01E00000
BootROM: Bad header at offset 02000000
BootROM: Bad header at offset 02200000
BootROM: Bad header at offset 02400000
BootROM: Bad header at offset 02600000
BootROM: Bad header at offset 02800000
BootROM: Bad header at offset 02A00000
BootROM: Bad header at offset 02C00000
BootROM: Bad header at offset 02E00000

Valid offsets when booting from eMMC:

BootROM: Bad header at offset 00000000
BootROM: Bad header at offset 00200000 Switching BootPartitions.
BootROM: Bad header at offset 00000000
BootROM: Bad header at offset 00200000

Quoted 5 lines
Quoted 3 lines
Fixes 2226ca17348 ("arm: mvebu: Load U-Boot proper binary in SPL code based on kwbimage header")

Applied to u-boot-marvell/master

Thanks,
Stefan

Quoted 21 lines

Thanks,
Stefan

Quoted 16 lines

---
  arch/arm/mach-mvebu/spl.c | 5 +++--

  1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/mach-mvebu/spl.c +0 -2
index eaaa68a8564..79f8877745b 100644
@@ -71,8 +71,9 @@
   #error CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR must be set to 0
   #endif
   #if !defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET) || \
-    CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET != 0
-#error CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET must be set 

to 0
+    (CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET != 0 && \

Quoted 9 lines
Quoted 5 lines

+     CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET != 4096) +#error CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET must be set to either 0 or 4096
  #endif
  #endif

Viele Grüße,
Stefan Roese

Viele Grüße,
Stefan Roese

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
#4 lore raw

PATCH v2 2/2 cmd: mvebu/bubt: move eMMC data-partition uboot from LBA-0 to 4096

In reply to Josua Mayer

A38x bootrom only searches 2 sectors when booting from eMMC, irregardless of data or boot partition: 0 & 4096.

For eMMC boot partitions sector 0 is fine, but on data partition it conflicts with MBR.

Change bubt command default to 4096 for eMMC data partition only, to allow using an MBR partition table on the eMMC data partition while also booting from it.

---
V1 -> V2: fixed build without CONFIG_SUPPORT_EMMC_BOOT

 cmd/mvebu/bubt.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
cmd/mvebu/bubt.c +9 -2
index ca24a5c1c4b..744b1c20aa8 100644
@@ -240,9 +240,16 @@ static int mmc_burn_image(size_t image_size)
 #endif
 
 	/* SD reserves LBA-0 for MBR and boots from LBA-1,
-	 * MMC/eMMC boots from LBA-0
+	 * MMC/eMMC boots from LBA-0 and LBA-4096
 	 */
-	start_lba = IS_SD(mmc) ? 1 : 0;
+	if (IS_SD(mmc))
+		start_lba = 1;
+#ifdef CONFIG_SUPPORT_EMMC_BOOT
+	else if (part)
+		start_lba = 0;
+#endif
+	else
+		start_lba = 4096;
 #ifdef CONFIG_BLK
 	blk_count = image_size / mmc->write_bl_len;
 	if (image_size % mmc->write_bl_len)
Signature · 1 line
2.35.3
Reviewed-by on v2 2/2
#5 lore raw

Re: [PATCH v2 2/2] cmd: mvebu/bubt: move eMMC data-partition uboot from LBA-0 to 4096

Quoted 11 lines · Josua Mayer

A38x bootrom only searches 2 sectors when booting from eMMC, irregardless of data or boot partition: 0 & 4096.

For eMMC boot partitions sector 0 is fine, but on data partition it conflicts with MBR.

Change bubt command default to 4096 for eMMC data partition only, to allow using an MBR partition table on the eMMC data partition while also booting from it.

Thanks,
Stefan

Quoted 19 lines

---
V1 -> V2: fixed build without CONFIG_SUPPORT_EMMC_BOOT

  cmd/mvebu/bubt.c | 11 +++++++++--
  1 file changed, 9 insertions(+), 2 deletions(-)
cmd/mvebu/bubt.c +2 -2
index ca24a5c1c4b..744b1c20aa8 100644
@@ -240,9 +240,16 @@ static int mmc_burn_image(size_t image_size)
  #endif
 
  	/* SD reserves LBA-0 for MBR and boots from LBA-1,
-	 * MMC/eMMC boots from LBA-0
+	 * MMC/eMMC boots from LBA-0 and LBA-4096
  	 */
-	start_lba = IS_SD(mmc) ? 1 : 0;
+	if (IS_SD(mmc))

cmd/mvebu/bubt.c static int mmc_burn_image(size_t image_size) · line 255

Quoted 10 lines
cmd/mvebu/bubt.c +7 -0
+		start_lba = 1;
+#ifdef CONFIG_SUPPORT_EMMC_BOOT
+	else if (part)
+		start_lba = 0;
+#endif
+	else
+		start_lba = 4096;
  #ifdef CONFIG_BLK
  	blk_count = image_size / mmc->write_bl_len;
  	if (image_size % mmc->write_bl_len)

Viele Grüße,
Stefan Roese

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
#6 lore raw

Re: [PATCH v2 2/2] cmd: mvebu/bubt: move eMMC data-partition uboot from LBA-0 to 4096

Quoted 7 lines · Stefan Roese
Quoted 6 lines · Josua Mayer

A38x bootrom only searches 2 sectors when booting from eMMC, irregardless of data or boot partition: 0 & 4096.

For eMMC boot partitions sector 0 is fine, but on data partition it conflicts with MBR.

Quoted 7 lines
Quoted 5 lines

Change bubt command default to 4096 for eMMC data partition only, to allow using an MBR partition table on the eMMC data partition while also booting from it.

Applied to u-boot-marvell/master

Thanks,
Stefan

Quoted 26 lines

Thanks,
Stefan

Quoted 23 lines

---
V1 -> V2: fixed build without CONFIG_SUPPORT_EMMC_BOOT

  cmd/mvebu/bubt.c | 11 +++++++++--

  1 file changed, 9 insertions(+), 2 deletions(-)
cmd/mvebu/bubt.c +7 -2
index ca24a5c1c4b..744b1c20aa8 100644
@@ -240,9 +240,16 @@ static int mmc_burn_image(size_t image_size)
   #endif
       /* SD reserves LBA-0 for MBR and boots from LBA-1,
-     * MMC/eMMC boots from LBA-0
+     * MMC/eMMC boots from LBA-0 and LBA-4096
        */
-    start_lba = IS_SD(mmc) ? 1 : 0;
+    if (IS_SD(mmc))
+        start_lba = 1;
+#ifdef CONFIG_SUPPORT_EMMC_BOOT
+    else if (part)
+        start_lba = 0;
+#endif
Quoted 9 lines

cmd/mvebu/bubt.c static int mmc_burn_image(size_t image_size) · line 255

Quoted 5 lines
cmd/mvebu/bubt.c +2 -0
+    else
+        start_lba = 4096;
   #ifdef CONFIG_BLK
       blk_count = image_size / mmc->write_bl_len;
       if (image_size % mmc->write_bl_len)

Viele Grüße,
Stefan Roese

Viele Grüße,
Stefan Roese

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]