[PATCH] mach-snapdragon: capsule_update: Fix eMMC detection for non-UFS devices

Casey Connolly casey.connolly at linaro.org
Sun Nov 9 13:31:26 CET 2025


Hi Alexey,

Thanks for this detailed explanation and fix!

On 11/8/25 00:29, Alexey Minnekhanov wrote:
> Currently (since 2026.01-rc) on all SDM630/660 based devices this is
> printed, after observing long boot delay (several seconds) before
> executing preboot commands:
> 
>   QCOM-FMP: Failed to find boot partition
> 
> find_target_partition() function incorrectly assumes that eMMC is always
> at number 0. In general you can't rely on device numbering to determine if
> particular block device is eMMC or SD-card, because it depends on how
> aliases are defined in device tree "chosen" node. Some SoCs have MMC
> numbers starting at 1, not 0; so mmc1 is eMMC, mmc2 is SD-card.
> 
> Make eMMC detection reliable by using IS_SD() macro from mmc.h header.
> Using this method target boot partition can be found successfully.
> With debug prints enabled, this is printed:
> 
>   QCOM-FMP: skipped SD-Card (devnum 2)
>   QCOM-FMP: Capsule update target: boot (disk 1:60)
>   QCOM-FMP: DFU string: 'mmc 0=u-boot.bin part 1 60'
> 
> Without debug prints nothing is printed, no error about failure to find
> boot partition.>
> Fixes: fe80a5f80095 ("mach-snapdragon: CapsuleUpdate: support all boot methods")
> Signed-off-by: Alexey Minnekhanov <alexeymin at minlexx.ru>

Reviewed-by: Casey Connolly <casey.connolly at linaro.org>

> ---
>   arch/arm/mach-snapdragon/capsule_update.c | 28 +++++++++++++++++++----
>   1 file changed, 24 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm/mach-snapdragon/capsule_update.c b/arch/arm/mach-snapdragon/capsule_update.c
> index 3699d91852d..586682434b7 100644
> --- a/arch/arm/mach-snapdragon/capsule_update.c
> +++ b/arch/arm/mach-snapdragon/capsule_update.c
> @@ -13,6 +13,7 @@
>   #include <efi.h>
>   #include <efi_loader.h>
>   #include <malloc.h>
> +#include <mmc.h>
>   #include <scsi.h>
>   #include <part.h>
>   #include <linux/err.h>
> @@ -80,6 +81,23 @@ static enum ab_slot get_part_slot(const char *partname)
>   	return SLOT_NONE;
>   }
>   
> +/* Shamelessly copied from lib/efi_loader/efi_device_path.c @ 33 */
> +/*
> + * Determine if an MMC device is an SD card.
> + *
> + * @desc	block device descriptor
> + * Return:	true if the device is an SD card
> + */
> +static bool is_sd(struct blk_desc *desc)
> +{
> +	struct mmc *mmc = find_mmc_device(desc->devnum);
> +
> +	if (!mmc)
> +		return false;
> +
> +	return IS_SD(mmc) != 0U;
> +}
> +
>   /*
>    * Determine which partition U-Boot is flashed to based on the boot source (ABL/XBL),
>    * the slot status, and prioritizing the uefi partition over xbl if found.
> @@ -109,19 +127,21 @@ static int find_target_partition(int *devnum, enum uclass_id *uclass,
>   		if (device_get_uclass_id(dev) != UCLASS_BLK)
>   			continue;
>   
> +		desc = dev_get_uclass_plat(dev);
> +
>   		/* If we have a UFS then don't look at any other block devices */
>   		if (have_ufs) {
>   			if (device_get_uclass_id(dev->parent->parent) != UCLASS_UFS)
>   				continue;
> +		}
>   		/*
> -		 * If we don't have UFS, then U-Boot must be on the eMMC which is always the first
> -		 * MMC device.
> +		 * If we don't have UFS, then U-Boot must be on the eMMC
>   		 */
> -		} else if (dev->parent->seq_ > 0) {
> +		else if (IS_ENABLED(CONFIG_MMC) && is_sd(desc)) {
> +			log_debug("skipped SD-Card (devnum %d)\n", desc->devnum);
>   			continue;
>   		}
>   
> -		desc = dev_get_uclass_plat(dev);
>   		if (!desc || desc->part_type == PART_TYPE_UNKNOWN)
>   			continue;
>   		for (partnum = 1;; partnum++) {



More information about the U-Boot mailing list