]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
board: samsung: exynos-mobile: use blkmap for booting from userdata subpartitions
authorKaustabh Chakraborty <kauschluss@disroot.org>
Tue, 24 Feb 2026 15:37:09 +0000 (21:07 +0530)
committerMinkyu Kang <mk7.kang@samsung.com>
Wed, 25 Feb 2026 01:47:03 +0000 (10:47 +0900)
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>
board/samsung/exynos-mobile/exynos-mobile.c
board/samsung/exynos-mobile/exynos-mobile.env
configs/exynos-mobile_defconfig

index 1f61f28de5f11a4d72117042646d9066c74d0d39..c5e1b186ae3cd4e326db8e8520f4a3183b8fc8e0 100644 (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();
 }
index aa2e89afbacadcc86d0f1f5539f06bdb28bdc3b3..33f767319b593c4170fb60a66cc86be8a28fdaa1 100644 (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
 
index c7d206f94ac66ef61a5a24fab00d585ab0ec51a0..cee468d9c24c93c53cf22d1babe24f278c0bb37b 100644 (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