Skip to content

Commit

Permalink
mmc_core: Add kconfig to override boot part size
Browse files Browse the repository at this point in the history
Since punchboot these days actually uses the extcsd to report the
correct size of boot partitions we need a way to be backwards compatible
with existing systems.

This option allows the user to override the boot partition size to
something less than the physical size.

Most users should leave this disabled.
  • Loading branch information
jonasblixt committed Apr 24, 2023
1 parent 856b5e2 commit 46a3dcd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/drivers/mmc/Kconfig
Expand Up @@ -24,6 +24,20 @@ config MMC_CORE_HS200_TUNE
and other conditions that might affect timing to get good tap delay
value.

config MMC_CORE_OVERRIDE_BOOT_PART_SZ
bool "Override boot partition size"
default n
depends on MMC_CORE
help
Most user want to set this to 'n'. Under some circumstances it can
be useful to ignore what extcsd report and forcibly set the boot partition
size to something else.

config MMC_CORE_BOOT_PART_SZ_KiB
int "Override boot partition size (KiB)"
depends on MMC_CORE_OVERRIDE_BOOT_PART_SZ
default 0

config IMX_USDHC
depends on SOC_FAMILY_IMX
select MMC_CORE
Expand Down
12 changes: 10 additions & 2 deletions src/drivers/mmc/mmc_core.c
Expand Up @@ -648,8 +648,16 @@ static int mmc_setup(void)
LOG_INFO("Pre EOL %x", mmc_ext_csd[EXT_CSD_PRE_EOL_INFO]);
*/

lba_t boot_part_last_lba = 0;

#ifdef CONFIG_MMC_CORE_OVERRIDE_BOOT_PART_SZ
boot_part_last_lba = CONFIG_MMC_CORE_BOOT_PART_SZ_KiB * 2 - 1;
#else
boot_part_last_lba = mmc_ext_csd[EXT_CSD_BOOT_MULT] * 256 - 1;
#endif

bio_dev_t d = bio_allocate(0,
mmc_ext_csd[EXT_CSD_BOOT_MULT] * 256 - 1,
boot_part_last_lba,
512,
mmc_cfg->boot0_uu,
"eMMC BOOT0");
Expand All @@ -671,7 +679,7 @@ static int mmc_setup(void)
return rc;

d = bio_allocate(0,
mmc_ext_csd[EXT_CSD_BOOT_MULT] * 256 - 1,
boot_part_last_lba,
512,
mmc_cfg->boot1_uu,
"eMMC BOOT1");
Expand Down

0 comments on commit 46a3dcd

Please sign in to comment.