From patchwork Wed Mar 11 17:02:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Scott X-Patchwork-Id: 449092 X-Patchwork-Delegate: l.majewski@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 167C3140187 for ; Thu, 12 Mar 2015 04:05:04 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BA88E4A046; Wed, 11 Mar 2015 18:05:00 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XS0DGnkLJEzk; Wed, 11 Mar 2015 18:05:00 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 02396A741B; Wed, 11 Mar 2015 18:05:00 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 37DF6A741B for ; Wed, 11 Mar 2015 18:04:56 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rZPCg3a0F3ke for ; Wed, 11 Mar 2015 18:04:56 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-ob0-f173.google.com (mail-ob0-f173.google.com [209.85.214.173]) by theia.denx.de (Postfix) with ESMTPS id B1B074A039 for ; Wed, 11 Mar 2015 18:04:51 +0100 (CET) Received: by obcuz6 with SMTP id uz6so10277314obc.5 for ; Wed, 11 Mar 2015 10:04:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=GaEB1+YefGlklLhpgca4chEylfVca2Vab5sTmQmK/bw=; b=JYNeAnpkKKFGviq2xQUxbPgx2hS/AG2smUPxPf4wPKKzhIJKsT6LNWp55iWJR0vrwp 7KV6OFv0g++G1KENlEnlX2ZJdF5R4sh5zy/iQJansOMxCERs/aiQignr1N0f9IUgSLRs d6+4udKz3vN2zJ17G6cJ0pNjvOFfdRmB64JdK3VCACH8xlnZf18bOqD947o0wzgn/Imk IKBSAjFQrgFAk1hYG3UC1uKtngFwS5ZLIgSzxNcYePwqU4d5fvZIwK1u8LVChhoCzYVb x7KQ9ylblVmD5jhm7dxTGTKtJhnJHoFGIORJuPYtDXqJ1e/ATFkT/C9IRiqNTh6pL2eX 4p4A== X-Gm-Message-State: ALoCoQlHtx+AI6LhEOclS3wOF8MiPi8W6o5dUXAeTEQceR7fAvXadaIujt9rmmc6SUrapNvFti2N X-Received: by 10.202.176.4 with SMTP id z4mr28951904oie.43.1426093490466; Wed, 11 Mar 2015 10:04:50 -0700 (PDT) Received: from localhost.localdomain (172-2-231-169.lightspeed.irvnca.sbcglobal.net. [172.2.231.169]) by mx.google.com with ESMTPSA id jt2sm2736812oeb.13.2015.03.11.10.04.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Mar 2015 10:04:49 -0700 (PDT) From: Michael Scott To: u-boot@lists.denx.de Date: Wed, 11 Mar 2015 10:02:31 -0700 Message-Id: <1426093351-8998-1-git-send-email-michael.scott@linaro.org> X-Mailer: git-send-email 2.1.4 Cc: Steve Rae , Michael Scott Subject: [U-Boot] [PATCH] fastboot: check for alias when looking up partition by name X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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_= Example: fastboot_partition_alias_boot=LNX Signed-off-by: Michael Scott Cc: Steve Rae Cc: Lukasz Majewski Acked-by: Steve Rae Acked-by: Steve Rae --- 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 and erase functions). +To define a partition alias add an environment variable similar to: +fastboot_partition_alias_= +Example: fastboot_partition_alias_boot=LNX + In Action ========= Enter into fastboot by executing the fastboot command in u-boot and you