board: samsung: exynos-mobile: use blkmap for booting from userdata subpartitions

Some distributions tend to provide a single combined image with EFS and
the system root filesystem. Flashing it as-is in a single partition
(usually done in userdata partition as it is the largest) is not
bootable as U-Boot does not understand subpartitions.

Use blkmap to map the userdata partition into its own block device.

Signed-off-by: Kaustabh Chakraborty <kauschluss@disroot.org>
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
This commit is contained in:
Kaustabh Chakraborty
2026-02-24 21:07:09 +05:30
committed by Minkyu Kang
parent e4001865ff
commit db0fe21bd3
3 changed files with 53 additions and 1 deletions

View File

@@ -184,6 +184,45 @@ static void exynos_env_setup(void)
env_set("fdtfile", buf);
}
static int exynos_blk_env_setup(void)
{
const char *blk_ifname;
int blk_dev = 0;
struct blk_desc *blk_desc;
struct disk_partition info = {0};
unsigned long largest_part_start = 0, largest_part_size = 0;
int i;
blk_ifname = "mmc";
blk_desc = blk_get_dev(blk_ifname, blk_dev);
if (!blk_desc) {
log_err("%s: required mmc device not available\n", __func__);
return -ENODEV;
}
for (i = 1; i < CONFIG_EFI_PARTITION_ENTRIES_NUMBERS; i++) {
if (part_get_info(blk_desc, i, &info))
continue;
if (info.start > largest_part_size) {
largest_part_start = info.start;
largest_part_size = info.size;
}
}
if (largest_part_size) {
env_set("blkmap_blk_ifname", blk_ifname);
env_set_ulong("blkmap_blk_dev", blk_dev);
env_set_ulong("blkmap_blk_nr", largest_part_start);
env_set_hex("blkmap_size_r", largest_part_size);
} else {
log_warning("%s: no qualified partition for blkmap, skipping\n",
__func__);
}
return 0;
}
static int exynos_fastboot_setup(void)
{
struct blk_desc *blk_dev;
@@ -297,7 +336,13 @@ int board_init(void)
int misc_init_r(void)
{
int ret;
exynos_env_setup();
ret = exynos_blk_env_setup();
if (ret)
return ret;
return exynos_fastboot_setup();
}

View File

@@ -2,6 +2,11 @@ stdin=serial,button-kbd
stdout=serial,vidconsole
stderr=serial,vidconsole
blkmapcmd=blkmap create root;
blkmap map root 0 ${blkmap_size_r} linear ${blkmap_blk_ifname} ${blkmap_blk_dev} ${blkmap_blk_nr}
preboot=run blkmapcmd
bootdelay=0
bootcmd=bootefi bootmgr; pause; bootmenu

View File

@@ -12,6 +12,7 @@ CONFIG_SYS_LOAD_ADDR=0x80000000
CONFIG_ARMV8_CNTFRQ_BROKEN=y
# CONFIG_PSCI_RESET is not set
CONFIG_BUTTON_CMD=y
CONFIG_USE_PREBOOT=y
CONFIG_SAVE_PREV_BL_FDT_ADDR=y
CONFIG_SAVE_PREV_BL_INITRAMFS_START_ADDR=y
CONFIG_SYS_PBSIZE=1024
@@ -24,8 +25,9 @@ CONFIG_CMD_POWEROFF=y
CONFIG_CMD_FS_GENERIC=y
CONFIG_EFI_PARTITION=y
CONFIG_OF_UPSTREAM=y
CONFIG_OF_BOARD=y
CONFIG_OF_UPSTREAM_BUILD_VENDOR=y
CONFIG_OF_BOARD=y
CONFIG_BLKMAP=y
CONFIG_BUTTON=y
CONFIG_BUTTON_REMAP_PHONE_KEYS=y
CONFIG_CLK_EXYNOS7870=y