fastboot: check for alias when looking up partition by name
authorMichael Scott <michael.scott@linaro.org>
Wed, 11 Mar 2015 17:02:31 +0000 (10:02 -0700)
committerLukasz Majewski <l.majewski@samsung.com>
Tue, 14 Apr 2015 08:19:04 +0000 (10:19 +0200)
Implement an alias name check for devices where GPT limitations prevent
user-friendly partition names such as "boot", "system" and "cache". Or,
where the actual partition name doesn't match a standard partition name
used commonly with fastboot.

To set an alias, add an environment setting as follows:
fastboot_partition_alias_<alias partition name>=<actual partition name>

Example: fastboot_partition_alias_boot=LNX

Signed-off-by: Michael Scott <michael.scott@linaro.org>
Acked-by: Steve Rae <srae@broadcom.com>
Cc: Steve Rae <srae@broadcom.com>
Cc: Lukasz Majewski <l.majewski@samsung.com>
common/fb_mmc.c
doc/README.android-fastboot

index 75899e4c285842451b519d3c8edff51014e2f35a..0c48cf929f8fd568d4d06095ede231ab81a97a6a 100644 (file)
@@ -33,6 +33,28 @@ void fastboot_okay(const char *s)
        strncat(response_str, s, RESPONSE_LEN - 4 - 1);
 }
 
+static int get_partition_info_efi_by_name_or_alias(block_dev_desc_t *dev_desc,
+               const char *name, disk_partition_t *info)
+{
+       int ret;
+
+       ret = get_partition_info_efi_by_name(dev_desc, name, info);
+       if (ret) {
+               /* strlen("fastboot_partition_alias_") + 32(part_name) + 1 */
+               char env_alias_name[25 + 32 + 1];
+               char *aliased_part_name;
+
+               /* check for alias */
+               strcpy(env_alias_name, "fastboot_partition_alias_");
+               strncat(env_alias_name, name, 32);
+               aliased_part_name = getenv(env_alias_name);
+               if (aliased_part_name != NULL)
+                       ret = get_partition_info_efi_by_name(dev_desc,
+                                       aliased_part_name, info);
+       }
+       return ret;
+}
+
 static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info,
                const char *part_name, void *buffer,
                unsigned int download_bytes)
@@ -98,7 +120,7 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer,
                printf("........ success\n");
                fastboot_okay("");
                return;
-       } else if (get_partition_info_efi_by_name(dev_desc, cmd, &info)) {
+       } else if (get_partition_info_efi_by_name_or_alias(dev_desc, cmd, &info)) {
                error("cannot find partition: '%s'\n", cmd);
                fastboot_fail("cannot find partition");
                return;
@@ -136,7 +158,7 @@ void fb_mmc_erase(const char *cmd, char *response)
                return;
        }
 
-       ret = get_partition_info_efi_by_name(dev_desc, cmd, &info);
+       ret = get_partition_info_efi_by_name_or_alias(dev_desc, cmd, &info);
        if (ret) {
                error("cannot find partition: '%s'", cmd);
                fastboot_fail("cannot find partition");
index 5526a4343c5cefc94c05bcfde39824f5c0567223..04411e98bc935476422027293704bd3643b1e3a8 100644 (file)
@@ -50,6 +50,15 @@ buffer should be as large as possible for a platform. The location of the
 buffer and size are set with CONFIG_USB_FASTBOOT_BUF_ADDR and
 CONFIG_USB_FASTBOOT_BUF_SIZE.
 
+Fastboot partition aliases can also be defined for devices where GPT
+limitations prevent user-friendly partition names such as "boot", "system"
+and "cache".  Or, where the actual partition name doesn't match a standard
+partition name used commonly with fastboot.  Current implentation checks
+aliases when accessing partitions by name (flash_write and erase functions).
+To define a partition alias add an environment variable similar to:
+fastboot_partition_alias_<alias partition name>=<actual partition name>
+Example: fastboot_partition_alias_boot=LNX
+
 In Action
 =========
 Enter into fastboot by executing the fastboot command in u-boot and you