From 9492b391a35c66e1e7630e95347259191b28314d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Thu, 10 Mar 2022 22:21:55 +0100 Subject: [PATCH] fix(st): don't try to read boot partition on SD cards MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When trying to boot from an SD card with STM32MP_EMMC_BOOT enabled, booting fails with: ERROR: Got unexpected value for active boot partition, 0 ASSERT: plat/st/common/bl2_stm32_io_storage.c:285 because SD cards don't provide a boot partition. So only try reading from such a partition when booting from eMMC. Fixes: 214c8a8d08b2 ("feat(plat/st): add STM32MP_EMMC_BOOT option") Signed-off-by: Uwe Kleine-König Change-Id: I354b737a3ae3ea577e83dfeb7096df22275d852d --- plat/st/common/bl2_stm32_io_storage.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/plat/st/common/bl2_stm32_io_storage.c b/plat/st/common/bl2_stm32_io_storage.c index 2d68a5028..43911955a 100644 --- a/plat/st/common/bl2_stm32_io_storage.c +++ b/plat/st/common/bl2_stm32_io_storage.c @@ -379,19 +379,21 @@ static void boot_mmc(enum mmc_device_type mmc_dev_type, stm32_sdmmc2_mmc_get_device_size(); #if STM32MP_EMMC_BOOT - magic = get_boot_part_ssbl_header(); + if (mmc_dev_type == MMC_IS_EMMC) { + magic = get_boot_part_ssbl_header(); - if (magic == BOOT_API_IMAGE_HEADER_MAGIC_NB) { - VERBOSE("%s, header found, jump to emmc load\n", __func__); - idx = IMG_IDX_BL33; - part = &stm32image_dev_info_spec.part_info[idx]; - part->part_offset = PLAT_EMMC_BOOT_SSBL_OFFSET; - part->bkp_offset = 0U; - mmc_device_spec.use_boot_part = true; + if (magic == BOOT_API_IMAGE_HEADER_MAGIC_NB) { + VERBOSE("%s, header found, jump to emmc load\n", __func__); + idx = IMG_IDX_BL33; + part = &stm32image_dev_info_spec.part_info[idx]; + part->part_offset = PLAT_EMMC_BOOT_SSBL_OFFSET; + part->bkp_offset = 0U; + mmc_device_spec.use_boot_part = true; - goto emmc_boot; - } else { - WARN("%s: Can't find STM32 header on a boot partition\n", __func__); + goto emmc_boot; + } else { + WARN("%s: Can't find STM32 header on a boot partition\n", __func__); + } } #endif