{
int err = -ENOSYS;
+ __maybe_unused int partition = CONFIG_SYS_MMCSD_FS_BOOT_PARTITION;
+
+#if CONFIG_SYS_MMCSD_FS_BOOT_PARTITION == -1
+ {
+ struct disk_partition info;
+ debug("Checking for the first MBR bootable partition\n");
+ for (int type_part = 1; type_part <= DOS_ENTRY_NUMBERS; type_part++) {
+ err = part_get_info(mmc_get_blk_desc(mmc), type_part, &info);
+ if (err)
+ continue;
+ debug("Partition %d is of type %d and bootable=%d\n", type_part, info.sys_ind, info.bootable);
+ if (info.bootable != 0) {
+ debug("Partition %d is bootable, using it\n", type_part);
+ partition = type_part;
+ break;
+ }
+ }
+ printf("Using first bootable partition: %d\n", partition);
+ if (partition == CONFIG_SYS_MMCSD_FS_BOOT_PARTITION) {
+ return -ENOSYS;
+ }
+ }
+#endif
+
#ifdef CONFIG_SPL_FS_FAT
if (!spl_start_uboot()) {
err = spl_load_image_fat_os(spl_image, bootdev, mmc_get_blk_desc(mmc),
- CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
+ partition);
if (!err)
return err;
}
#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
err = spl_load_image_fat(spl_image, bootdev, mmc_get_blk_desc(mmc),
- CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
+ partition,
filename);
if (!err)
return err;
#ifdef CONFIG_SPL_FS_EXT4
if (!spl_start_uboot()) {
err = spl_load_image_ext_os(spl_image, bootdev, mmc_get_blk_desc(mmc),
- CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
+ partition);
if (!err)
return err;
}
#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
err = spl_load_image_ext(spl_image, bootdev, mmc_get_blk_desc(mmc),
- CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
+ partition,
filename);
if (!err)
return err;