common: fastboot: retrieve partition tables from mmc
authorChanho Park <chanho61.park@samsung.com>
Mon, 27 Jul 2015 04:43:54 +0000 (13:43 +0900)
committerChanho Park <chanho61.park@samsung.com>
Tue, 28 Jul 2015 08:49:33 +0000 (17:49 +0900)
This patch allow to retrieve partition tables from mmc device. It reads
the tables through get_partition_info function and appends the
partitions the end of the static partitions.

Signed-off-by: Chanho Park <chanho61.park@samsung.com>
common/cmd_fastboot.c

index e5abff4321936d11a5943977f719157e2a9ff2ec..4b9a77e68d8ba313db447efe4081d371718ccba1 100644 (file)
@@ -1668,6 +1668,34 @@ static int set_partition_table()
 #endif
 
 #if defined(CFG_FASTBOOT_SDMMCBSP)
+
+#ifdef CONFIG_FASTBOOT_GET_MMC_PARTITIONS
+static int get_mmc_partition_tables()
+{
+       int i, ret;
+       block_dev_desc_t *dev_desc;
+       disk_partition_t info;
+
+       ret = get_device("mmc", "0", &dev_desc);
+       if (ret < 0)
+               return -1;
+
+       for (i = 1; i < 128; i++) {
+               ret = get_partition_info(dev_desc, i, &info);
+               if (ret)
+                       break;
+
+               strcpy(ptable[pcount].name, info.name);
+               ptable[pcount].start = info.start * info.blksz;
+               ptable[pcount].length = info.size * info.blksz;
+               ptable[pcount].flags = FASTBOOT_PTENTRY_FLAGS_USE_MMC_CMD;
+               pcount++;
+       }
+
+       return pcount;
+}
+#endif /* CONFIG_FASTBOOT_GET_MMC_PARTITIONS */
+
 static int set_partition_table_sdmmc()
 {
        unsigned long long start, count;
@@ -1776,6 +1804,10 @@ static int set_partition_table_sdmmc()
        pcount++;
 #endif /* End of CONFIG_ANDROID_PARTITIONS */
 
+#ifdef CONFIG_FASTBOOT_GET_MMC_PARTITIONS
+       get_mmc_partition_tables();
+#endif /* CONFIG_FASTBOOT_GET_MMC_PARTITIONS */
+
 #if 1 // Debug
        fastboot_flash_dump_ptn();
 #endif