public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Michael Scott <michael.scott@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] fastboot: check for alias when looking up partition by name
Date: Thu, 12 Mar 2015 10:17:19 -0700	[thread overview]
Message-ID: <5501CA1F.5000903@linaro.org> (raw)
In-Reply-To: <5501BD75.4020006@broadcom.com>


On 03/12/2015 09:23 AM, Steve Rae wrote:
>
>
> On 15-03-11 10:02 AM, Michael Scott wrote:
>> 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>
>> Cc: Steve Rae <srae@broadcom.com>
>> Cc: Lukasz Majewski <l.majewski@samsung.com>
>> ---
>>   common/fb_mmc.c             | 26 ++++++++++++++++++++++++--
>>   doc/README.android-fastboot |  9 +++++++++
>>   2 files changed, 33 insertions(+), 2 deletions(-)
>>
>> diff --git a/common/fb_mmc.c b/common/fb_mmc.c
>> index 75899e4..0c48cf9 100644
>> --- a/common/fb_mmc.c
>> +++ b/common/fb_mmc.c
>> @@ -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");
>> diff --git a/doc/README.android-fastboot b/doc/README.android-fastboot
>> index 5526a43..04411e9 100644
>> --- a/doc/README.android-fastboot
>> +++ b/doc/README.android-fastboot
>> @@ -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 andThere's 
>> already a driver
> for DWC2 in drivers/usb/gadget/s3c_udc_otg.c . This driver should really
> be properly renamed though ;-/  erase functions).
Hi Steve,

I'm a bit confused with the mention of drivers/usb/gadget/s3c_udc_otg.c and
how it relates back this patch.  I'm willing to make any corrections you 
would
like, but may need some clarification.

>> +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
>>
>
> An interesting feature (which seems unnecessary to me...) However,
A bit of background:

We are using fastboot support on Nvidia Jetson-TK1 platform where
a GPT limitation sets partition names to 3 letters.

IE: LNX = boot, APP = system and UDA = userdata.

To present a "normal" fastboot experience to users, we use this patch.

> Acked-by: Steve Rae <srae@broadcom.com>

Thank you for the Ack!

  reply	other threads:[~2015-03-12 17:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-11 17:02 [U-Boot] [PATCH] fastboot: check for alias when looking up partition by name Michael Scott
2015-03-12 16:23 ` Steve Rae
2015-03-12 17:17   ` Michael Scott [this message]
2015-03-12 18:14     ` Steve Rae
2015-03-20  7:50       ` Lukasz Majewski
2015-03-20 16:30         ` Steve Rae
2015-03-23  9:13           ` Lukasz Majewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5501CA1F.5000903@linaro.org \
    --to=michael.scott@linaro.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox