Skip to contentSkip to conversation

spl: mmc: raw: Try to load u-boot if Linux image is not found

PATCH In review Lokesh Vutla 2 participants 2 messages Apr 11, 2016 – Apr 12, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spl: mmc: raw: Try to load u-boot if Linux image is not found

If CONFIG_SPL_OS_BOOT is enabled and Linux image is not flashed at RAW_MODE_KERNEL_SECTOR in MMC, spl still assumes that Linux is available and tries to boot it and hangs. In order to avoid this, adding a check to verify if parsed image header is of type IH_OS_LINUX. If it fails then fall back to load u-boot image.

---
 common/spl/spl_mmc.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
common/spl/spl_mmc.c +11 -1
index 7d3bfc6..1a10c55 100644
@@ -178,6 +178,7 @@ static int mmc_load_image_raw_partition(struct mmc *mmc, int partition)
 static int mmc_load_image_raw_os(struct mmc *mmc)
 {
 	unsigned long count;
+	int ret;
 
 	count = mmc->block_dev.block_read(&mmc->block_dev,
 		CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR,
@@ -190,8 +191,17 @@ static int mmc_load_image_raw_os(struct mmc *mmc)
 		return -1;
 	}
 
-	return mmc_load_image_raw_sector(mmc,
+	ret = mmc_load_image_raw_sector(mmc,
 		CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR);
+	if (ret)
+		return ret;
+
+	if (spl_image.os != IH_OS_LINUX) {
+		puts("Expected Linux image is not found. Trying to start U-boot\n");
+		return -ENOENT;
+	}
+
+	return 0;
 }
 #else
 int spl_start_uboot(void)
Signature · 1 line
2.1.4
#1 lore raw
Quoted 7 lines · Lokesh Vutla

If CONFIG_SPL_OS_BOOT is enabled and Linux image is not flashed at RAW_MODE_KERNEL_SECTOR in MMC, spl still assumes that Linux is available and tries to boot it and hangs. In order to avoid this, adding a check to verify if parsed image header is of type IH_OS_LINUX. If it fails then fall back to load u-boot image.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160411/cc12c6fa/attachment.sig>