common: fastboot: store partition name from getvar command
authorChanho Park <chanho61.park@samsung.com>
Mon, 27 Jul 2015 10:07:16 +0000 (19:07 +0900)
committerChanho Park <chanho61.park@samsung.com>
Tue, 28 Jul 2015 08:49:33 +0000 (17:49 +0900)
This patch allows to a partition entry from getvar fastboot command.
The partition name is required when we try to download chunk bytes and flash
them to mmc immediately.

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

index e7a1a89478246ec36e3bfd191207a47c8914b482..af95722e1505ed5fed923d5608f03787ee6b8737 100644 (file)
@@ -157,6 +157,11 @@ static unsigned int download_bytes;
 //static unsigned int download_bytes_unpadded;
 static unsigned int download_error;
 
+#ifdef CONFIG_FASTBOOT_FLASH_CHUNK
+#define FASTBOOT_GETVAR_PART_TYPE      "partition-type"
+static fastboot_ptentry *download_ptn;
+#endif /* CONFIG_FASTBOOT_FLASH_CHUNK */
+
 /* To support the Android-style naming of flash */
 #define MAX_PTN 16
 static fastboot_ptentry ptable[MAX_PTN];
@@ -871,19 +876,28 @@ static int process_cmd_getvar(const char *cmdbuf, char *response)
 
        if (!strcmp(cmdbuf + 7, "version"))
                strcpy(response + 4, FASTBOOT_VERSION);
-       else if (!strcmp(cmdbuf + 7, "product"))
+       else if (!strcmp(cmdbuf + 7, "product")) {
                if (interface.product_name)
                        strcpy(response + 4, interface.product_name);
-       else if (!strcmp(cmdbuf + 7, "serialno"))
+       } else if (!strcmp(cmdbuf + 7, "serialno")) {
                if (interface.serial_no)
                        strcpy(response + 4, interface.serial_no);
-       else if (!strcmp(cmdbuf + 7, "downloadsize"))
+       } else if (!strcmp(cmdbuf + 7, "downloadsize")) {
                if (interface.transfer_buffer_size)
                        sprintf(response + 4, "%08x",
                                        interface.transfer_buffer_size);
-       else
+#ifdef CONFIG_FASTBOOT_FLASH_CHUNK
+       } else if (!strncmp(cmdbuf + 7, FASTBOOT_GETVAR_PART_TYPE,
+                               strlen(FASTBOOT_GETVAR_PART_TYPE))) {
+               download_ptn = fastboot_flash_find_ptn(cmdbuf + 7 +
+                               strlen(FASTBOOT_GETVAR_PART_TYPE) + 1);
+
+               if (download_ptn && !(download_ptn->flags &
+                               FASTBOOT_PTENTRY_FLAGS_FLASH_CHUNK))
+                       download_ptn = NULL;
+#endif
+       } else
                fastboot_getvar(cmdbuf + 7, response + 4);
-
        return 0;
 }
 
@@ -1637,6 +1651,10 @@ static int get_mmc_partition_tables()
                ptable[pcount].start = info.start * info.blksz;
                ptable[pcount].length = info.size * info.blksz;
                ptable[pcount].flags = FASTBOOT_PTENTRY_FLAGS_USE_MMC_CMD;
+#ifdef CONFIG_FASTBOOT_FLASH_CHUNK
+               ptable[pcount].flags |= FASTBOOT_PTENTRY_FLAGS_FLASH_CHUNK;
+#endif
+
                pcount++;
        }
 
index 4bca7bc30b89cbb3ea593ea3ba8e50f9070cc368..b02173384af4597f216c2ec0125392ae842e7459 100644 (file)
@@ -210,6 +210,9 @@ struct fastboot_ptentry
 /* Use movi command to read/write this partition */
 #define FASTBOOT_PTENTRY_FLAGS_USE_MOVI_CMD           0x00020000
 
+/* Download and imediately flash this partition */
+#define FASTBOOT_PTENTRY_FLAGS_FLASH_CHUNK            0x00040000
+
 /* Status values */
 #define FASTBOOT_OK                    0
 #define FASTBOOT_ERROR                 -1