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: 45689 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 870AD214C6 for ; Wed, 11 Mar 2015 17:05:08 +0000 (UTC) Received: by wivr20 with SMTP id r20sf8354203wiv.0 for ; Wed, 11 Mar 2015 10:05:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:cc:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=g5+XQzkMgknpuVMJ6bNChes6BzwOPZRJhDDqpn4NI8Y=; b=Kan+4HuvHxp7tOHI//Iwk8zAhH0lCi9b6kehtJZHf+mWGcty38LR3gwI96rtiNirGU KZXcVXtrT95/4rdNRwV+w9b7etdkgjX3uZ5Ur3A9CMsh6cAdqhLW9khAvQsya/+teayj Hu+goxHftKldNvr3Nu3i177jHMLfqmJw+fBJOnf1ohM5Q4JblgZUoXMga/LebWO7Xwid F2eQi+r7gPpNroQ9G9nJPnTcPJUsGw6wJNtkegMA4d8CDZVW832Fry0VRTMfTVYIayAY tzMTaQ9fCtC4sEcOyrb9cUkjCdvMWxblm0pfWOlVgopBzGG0OqpdwX++eRbz0bagVRoL Os2Q== X-Gm-Message-State: ALoCoQnZ7MHD10Ro1shpGPem/4FV1dHfSJwNqXN7ong6fJsIatZEZFWPVDTuWt7n23N/7d24U8wt X-Received: by 10.180.90.175 with SMTP id bx15mr2354712wib.3.1426093507834; Wed, 11 Mar 2015 10:05:07 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.237 with SMTP id r13ls181907lal.74.gmail; Wed, 11 Mar 2015 10:05:07 -0700 (PDT) X-Received: by 10.152.88.99 with SMTP id bf3mr34673603lab.37.1426093507559; Wed, 11 Mar 2015 10:05:07 -0700 (PDT) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id ry4si2712986lbc.90.2015.03.11.10.05.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Mar 2015 10:05:07 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by lbjb6 with SMTP id b6so10268021lbj.9 for ; Wed, 11 Mar 2015 10:05:07 -0700 (PDT) X-Received: by 10.152.43.51 with SMTP id t19mr34944923lal.73.1426093507456; Wed, 11 Mar 2015 10:05:07 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp2905800lbj; Wed, 11 Mar 2015 10:05:06 -0700 (PDT) X-Received: by 10.194.243.1 with SMTP id wu1mr81489636wjc.69.1426093501875; Wed, 11 Mar 2015 10:05:01 -0700 (PDT) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id ei5si635370wib.117.2015.03.11.10.05.01; Wed, 11 Mar 2015 10:05:01 -0700 (PDT) Received-SPF: none (google.com: u-boot-bounces@lists.denx.de does not designate permitted sender hosts) client-ip=85.214.87.163; 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-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: 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" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: michael.scott@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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 --- 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