Skip to contentSkip to conversation

imx-common: spl: return boot mode for asked MMC device in spl_boot_mode()

PATCH New Anatolij Gustschin 2 participants 3 messages Aug 1, 2017 – Aug 2, 2017

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

PATCH 1/1 imx-common: spl: return boot mode for asked MMC device in spl_boot_mode()

Boards may extend or re-define the boot list in their board_boot_order() function by modifying spl_boot_list. E.g. a board might boot SPL from a slow SPI NOR flash and then load the U-Boot from an eMMC or SD-card. Or it might use additional MMC boot device in spl_boot_list for cases when the image in SPI NOR flash is not found, so it could fall back to eMMC, SD-card or another boot device.

Getting the MMC boot mode in spl_mmc will fail when we are trying to boot from an MMC device in the spl_boot_list and the original board boot mode (as returned by spl_boot_device()) is not an MMC boot mode. Fix it by checking the asked MMC boot device from the spl_boot_mode() argument.

---
 arch/arm/mach-imx/spl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-imx/spl.c +1 -1
index 75698c4..cbb9dd5 100644
@@ -84,7 +84,7 @@ u32 spl_boot_device(void)
 /* called from spl_mmc to see type of boot mode for storage (RAW or FAT) */
 u32 spl_boot_mode(const u32 boot_device)
 {
-	switch (spl_boot_device()) {
+	switch (boot_device) {
 	/* for MMC return either RAW or FAT mode */
 	case BOOT_DEVICE_MMC1:
 	case BOOT_DEVICE_MMC2:
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 imx-common: spl: return boot mode for asked MMC device in spl_boot_mode()

Hi anatolji,

Quoted 24 lines · Anatolij Gustschin

Boards may extend or re-define the boot list in their board_boot_order() function by modifying spl_boot_list. E.g. a board might boot SPL from a slow SPI NOR flash and then load the U-Boot from an eMMC or SD-card. Or it might use additional MMC boot device in spl_boot_list for cases when the image in SPI NOR flash is not found, so it could fall back to eMMC, SD-card or another boot device.

Getting the MMC boot mode in spl_mmc will fail when we are trying to boot from an MMC device in the spl_boot_list and the original board boot mode (as returned by spl_boot_device()) is not an MMC boot mode. Fix it by checking the asked MMC boot device from the spl_boot_mode() argument.

---
 arch/arm/mach-imx/spl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-imx/spl.c +0 -0
index 75698c4..cbb9dd5 100644

arch/arm/mach-imx/spl.c u32 spl_boot_device(void) · line 90

Quoted 8 lines
arch/arm/mach-imx/spl.c +1 -1
@@ -84,7 +84,7 @@ u32 spl_boot_device(void)
 /* called from spl_mmc to see type of boot mode for storage (RAW or FAT) */
 u32 spl_boot_mode(const u32 boot_device)
 {
-	switch (spl_boot_device()) {
+	switch (boot_device) {
 	/* for MMC return either RAW or FAT mode */
 	case BOOT_DEVICE_MMC1:
 	case BOOT_DEVICE_MMC2:

Nevertheless it seems difficult to be consistent. Let's start with the case where a on-board device (SPI or eMMC) does not boot, and the way to save the board is to boot from an external board. And SPL on the onboard flash is damaged, but not u-boot.img. Anyway, we want that the board boots with its consistent status, that is with the pair SPL+u-boot.img. In the example I tracked, both from the SD card. This is consistent using spl_boot_device, because it does not try to boot from a different device as the one where SPL was loaded.

Best regards,
Stefano

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#2 lore raw

PATCH 1/1 imx-common: spl: return boot mode for asked MMC device in spl_boot_mode()

Hi Stefano,

On Wed, 2 Aug 2017 11:54:24 +0200
Stefano Babic sbabic at denx.de wrote:
...

Quoted 12 lines

arch/arm/mach-imx/spl.c u32 spl_boot_device(void) · line 90

Quoted 11 lines

+++ b/arch/arm/mach-imx/spl.c

arch/arm/mach-imx/spl.c +1 -1
@@ -84,7 +84,7 @@ u32 spl_boot_device(void)
 /* called from spl_mmc to see type of boot mode for storage (RAW or FAT) */
 u32 spl_boot_mode(const u32 boot_device)
 {
-	switch (spl_boot_device()) {
+	switch (boot_device) {
 	/* for MMC return either RAW or FAT mode */
 	case BOOT_DEVICE_MMC1:
 	case BOOT_DEVICE_MMC2:
Quoted 8 lines

Nevertheless it seems difficult to be consistent. Let's start with the case where a on-board device (SPI or eMMC) does not boot, and the way to save the board is to boot from an external board. And SPL on the onboard flash is damaged, but not u-boot.img. Anyway, we want that the board boots with its consistent status, that is with the pair SPL+u-boot.img. In the example I tracked, both from the SD card. This is consistent using spl_boot_device, because it does not try to boot from a different device as the one where SPL was loaded.

thanks for explanation, I'll have to find another way then, or will maintain this patch out of tree.

--
Anatolij