From 4c829466fcc8c0b5303af6bda21366657b959a30 Mon Sep 17 00:00:00 2001 From: Eugeniu Rosca Date: Tue, 26 Mar 2019 17:46:14 +0100 Subject: fastboot: getvar: correct/rename "has_slot" to "has-slot" Since its inception in upstream fastboot android-n-preview-1 [1], "has-slot" option has never taken the form of "has_slot". Amongst the users of "getvar has-slot:" is the upstream bootloadertest.py [2]. Current U-Boot "has_slot" version must be a typo. Fix it. [1] https://android.googlesource.com/platform/system/core/+/a797479bd51c ("Fix fastboot variable name") [2] https://android.googlesource.com/platform/system/extras/+/72de393e118e3 ("Bootloader verification for AndroidThings.") Fixes: f73a7df984a9 ("net: fastboot: Merge AOSP UDP fastboot") Signed-off-by: Eugeniu Rosca Acked-by: Alex Kiernan --- drivers/fastboot/fb_getvar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/fastboot') diff --git a/drivers/fastboot/fb_getvar.c b/drivers/fastboot/fb_getvar.c index 4d264c985d7..91a774a345b 100644 --- a/drivers/fastboot/fb_getvar.c +++ b/drivers/fastboot/fb_getvar.c @@ -62,7 +62,7 @@ static const struct { .variable = "slot-suffixes", .dispatch = getvar_slot_suffixes }, { - .variable = "has_slot", + .variable = "has-slot", .dispatch = getvar_has_slot #if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC) }, { -- cgit v1.3.1 From a40297d74105b3949dc72375e0fdc54fe0b170ad Mon Sep 17 00:00:00 2001 From: Eugeniu Rosca Date: Thu, 28 Mar 2019 14:31:33 +0100 Subject: fastboot: Improve error reporting on 'getvar partition-{size, type}' Currently U-Boot reports the same error message in all below cases: [A] host> fastboot getvar partition-type [B] host> fastboot getvar partition-size [C] host> fastboot getvar partition-type: [D] host> fastboot getvar partition-size: [E] host> fastboot getvar partition-type: [F] host> fastboot getvar partition-size: The message looks like: host> fastboot getvar partition-size: getvar:partition-size: FAILED (remote: partition not found) Finished. Total time: 0.003s Be more user friendly and output: - "partition not given" for [A-D] - "partition not found" for [E-F] Fixes: f73a7df984a9 ("net: fastboot: Merge AOSP UDP fastboot") Signed-off-by: Eugeniu Rosca Acked-by: Alex Kiernan --- drivers/fastboot/fb_mmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/fastboot') diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c index 4c1c7fd2cd8..d04d8a448cc 100644 --- a/drivers/fastboot/fb_mmc.c +++ b/drivers/fastboot/fb_mmc.c @@ -308,8 +308,8 @@ int fastboot_mmc_get_part_info(char *part_name, struct blk_desc **dev_desc, fastboot_fail("block device not found", response); return -ENOENT; } - if (!part_name) { - fastboot_fail("partition not found", response); + if (!part_name || !strcmp(part_name, "")) { + fastboot_fail("partition not given", response); return -ENOENT; } -- cgit v1.3.1 From b762aa126e648fa9bc62fc8997b01a4a73089367 Mon Sep 17 00:00:00 2001 From: Alex Kiernan Date: Tue, 9 Apr 2019 05:30:05 +0000 Subject: fastboot: Replace literal 32 with PART_NAME_LEN Where we have to compute partition names, rather than using a hardcoded 32 for the partition name length, replace with PART_NAME_LEN. Signed-off-by: Alex Kiernan Reviewed-by: Eugeniu Rosca --- drivers/fastboot/fb_mmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/fastboot') diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c index d04d8a448cc..90ca81da9b5 100644 --- a/drivers/fastboot/fb_mmc.c +++ b/drivers/fastboot/fb_mmc.c @@ -31,13 +31,13 @@ static int part_get_info_by_name_or_alias(struct blk_desc *dev_desc, ret = part_get_info_by_name(dev_desc, name, info); if (ret < 0) { - /* strlen("fastboot_partition_alias_") + 32(part_name) + 1 */ - char env_alias_name[25 + 32 + 1]; + /* strlen("fastboot_partition_alias_") + PART_NAME_LEN + 1 */ + char env_alias_name[25 + PART_NAME_LEN + 1]; char *aliased_part_name; /* check for alias */ strcpy(env_alias_name, "fastboot_partition_alias_"); - strncat(env_alias_name, name, 32); + strncat(env_alias_name, name, PART_NAME_LEN); aliased_part_name = env_get(env_alias_name); if (aliased_part_name != NULL) ret = part_get_info_by_name(dev_desc, -- cgit v1.3.1 From d73d9fb7e2384b55a6c1866a5d914a621cf8563a Mon Sep 17 00:00:00 2001 From: Eugeniu Rosca Date: Tue, 9 Apr 2019 21:11:40 +0200 Subject: fastboot: add support for 'getvar platform' Our R-Car3 Android userspace relies on the output of 'fastboot getvar platform' and U-Boot currently is not able to handle it: host $> fastboot getvar platform getvar:platform FAILED (remote: Variable not implemented) finished. total time: 0.001s We either have the option of adding 'fastboot.platform' variable to the default/saved environment as a workaround or add proper 'fastboot getvar platform' support in U-Boot via this patch. In the latter case, other platforms can benefit from it too. Note that R-Car3 already exports 'platform' environment variable via v2019.01 commit 00e4b57e9e71c3 ("ARM: rmobile: Set environment variable containing CPU type"). Signed-off-by: Eugeniu Rosca --- drivers/fastboot/fb_getvar.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'drivers/fastboot') diff --git a/drivers/fastboot/fb_getvar.c b/drivers/fastboot/fb_getvar.c index 91a774a345b..4268628f5ef 100644 --- a/drivers/fastboot/fb_getvar.c +++ b/drivers/fastboot/fb_getvar.c @@ -17,6 +17,7 @@ static void getvar_downloadsize(char *var_parameter, char *response); static void getvar_serialno(char *var_parameter, char *response); static void getvar_version_baseband(char *var_parameter, char *response); static void getvar_product(char *var_parameter, char *response); +static void getvar_platform(char *var_parameter, char *response); static void getvar_current_slot(char *var_parameter, char *response); static void getvar_slot_suffixes(char *var_parameter, char *response); static void getvar_has_slot(char *var_parameter, char *response); @@ -55,6 +56,9 @@ static const struct { }, { .variable = "product", .dispatch = getvar_product + }, { + .variable = "platform", + .dispatch = getvar_platform }, { .variable = "current-slot", .dispatch = getvar_current_slot @@ -117,6 +121,16 @@ static void getvar_product(char *var_parameter, char *response) fastboot_fail("Board not set", response); } +static void getvar_platform(char *var_parameter, char *response) +{ + const char *p = env_get("platform"); + + if (p) + fastboot_okay(p, response); + else + fastboot_fail("platform not set", response); +} + static void getvar_current_slot(char *var_parameter, char *response) { /* A/B not implemented, for now always return _a */ -- cgit v1.3.1