Commit 8a41802f21cc270cb00ac7dc1263a4c136c9a31c
Committed by
Lukasz Majewski
1 parent
0a9ac5cb5e
Exists in
v2017.01-smarct4x
and in
34 other branches
fastboot: check for alias when looking up partition by name
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>
Showing 2 changed files with 33 additions and 2 deletions Side-by-side Diff
common/fb_mmc.c
... | ... | @@ -33,6 +33,28 @@ |
33 | 33 | strncat(response_str, s, RESPONSE_LEN - 4 - 1); |
34 | 34 | } |
35 | 35 | |
36 | +static int get_partition_info_efi_by_name_or_alias(block_dev_desc_t *dev_desc, | |
37 | + const char *name, disk_partition_t *info) | |
38 | +{ | |
39 | + int ret; | |
40 | + | |
41 | + ret = get_partition_info_efi_by_name(dev_desc, name, info); | |
42 | + if (ret) { | |
43 | + /* strlen("fastboot_partition_alias_") + 32(part_name) + 1 */ | |
44 | + char env_alias_name[25 + 32 + 1]; | |
45 | + char *aliased_part_name; | |
46 | + | |
47 | + /* check for alias */ | |
48 | + strcpy(env_alias_name, "fastboot_partition_alias_"); | |
49 | + strncat(env_alias_name, name, 32); | |
50 | + aliased_part_name = getenv(env_alias_name); | |
51 | + if (aliased_part_name != NULL) | |
52 | + ret = get_partition_info_efi_by_name(dev_desc, | |
53 | + aliased_part_name, info); | |
54 | + } | |
55 | + return ret; | |
56 | +} | |
57 | + | |
36 | 58 | static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info, |
37 | 59 | const char *part_name, void *buffer, |
38 | 60 | unsigned int download_bytes) |
... | ... | @@ -98,7 +120,7 @@ |
98 | 120 | printf("........ success\n"); |
99 | 121 | fastboot_okay(""); |
100 | 122 | return; |
101 | - } else if (get_partition_info_efi_by_name(dev_desc, cmd, &info)) { | |
123 | + } else if (get_partition_info_efi_by_name_or_alias(dev_desc, cmd, &info)) { | |
102 | 124 | error("cannot find partition: '%s'\n", cmd); |
103 | 125 | fastboot_fail("cannot find partition"); |
104 | 126 | return; |
... | ... | @@ -136,7 +158,7 @@ |
136 | 158 | return; |
137 | 159 | } |
138 | 160 | |
139 | - ret = get_partition_info_efi_by_name(dev_desc, cmd, &info); | |
161 | + ret = get_partition_info_efi_by_name_or_alias(dev_desc, cmd, &info); | |
140 | 162 | if (ret) { |
141 | 163 | error("cannot find partition: '%s'", cmd); |
142 | 164 | fastboot_fail("cannot find partition"); |
doc/README.android-fastboot
... | ... | @@ -50,6 +50,15 @@ |
50 | 50 | buffer and size are set with CONFIG_USB_FASTBOOT_BUF_ADDR and |
51 | 51 | CONFIG_USB_FASTBOOT_BUF_SIZE. |
52 | 52 | |
53 | +Fastboot partition aliases can also be defined for devices where GPT | |
54 | +limitations prevent user-friendly partition names such as "boot", "system" | |
55 | +and "cache". Or, where the actual partition name doesn't match a standard | |
56 | +partition name used commonly with fastboot. Current implentation checks | |
57 | +aliases when accessing partitions by name (flash_write and erase functions). | |
58 | +To define a partition alias add an environment variable similar to: | |
59 | +fastboot_partition_alias_<alias partition name>=<actual partition name> | |
60 | +Example: fastboot_partition_alias_boot=LNX | |
61 | + | |
53 | 62 | In Action |
54 | 63 | ========= |
55 | 64 | Enter into fastboot by executing the fastboot command in u-boot and you |