diff --git a/include/mmc.h b/include/mmc.h index 20481b0ace..40ed3bc01a 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -217,6 +217,7 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx) #define EXT_CSD_WR_REL_PARAM 166 /* R */ #define EXT_CSD_WR_REL_SET 167 /* R/W */ #define EXT_CSD_RPMB_MULT 168 /* RO */ +#define EXT_CSD_BOOT_WP 173 /* R/W & R/W/C_P */ #define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */ #define EXT_CSD_BOOT_BUS_WIDTH 177 #define EXT_CSD_PART_CONF 179 /* R/W */ @@ -328,6 +329,8 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx) #define MMC_QUIRK_RETRY_SEND_CID BIT(0) #define MMC_QUIRK_RETRY_SET_BLOCKLEN BIT(1) +#define BOOT1_PWR_WP (0x83) + enum mmc_voltage { MMC_SIGNAL_VOLTAGE_000 = 0, MMC_SIGNAL_VOLTAGE_120 = 1, @@ -339,6 +342,7 @@ enum mmc_voltage { MMC_SIGNAL_VOLTAGE_180 |\ MMC_SIGNAL_VOLTAGE_330) + /* Maximum block size for MMC */ #define MMC_MAX_BLOCK_LEN 512 diff --git a/lib/avb/fsl/fsl_avb_ab_flow.c b/lib/avb/fsl/fsl_avb_ab_flow.c index 35fad53f7f..8a67de79eb 100644 --- a/lib/avb/fsl/fsl_avb_ab_flow.c +++ b/lib/avb/fsl/fsl_avb_ab_flow.c @@ -62,6 +62,8 @@ bool fsl_slot_is_bootable(AvbABSlotData* slot) { #define PARTITION_MISC "misc" #define PARTITION_BOOTLOADER "bootloader" +extern int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value); + /* Pre-declaration of h_spl_load_read(), see detail implementation in * common/spl/spl_mmc.c. */ @@ -281,6 +283,11 @@ int mmc_load_image_raw_sector_dual_uboot( return -1; } } + /* Set power-on write protection to boot1 partition. */ + if (mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_WP, BOOT1_PWR_WP)) { + printf("Unable to set power-on write protection to boot1!\n"); + return -1; + } /* Load AB metadata from misc partition */ if (fsl_load_metadata_dual_uboot(dev_desc, &ab_data,