From patchwork Mon Sep 22 21:29:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Rae X-Patchwork-Id: 37703 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A985E202A1 for ; Mon, 22 Sep 2014 21:26:10 +0000 (UTC) Received: by mail-wg0-f69.google.com with SMTP id m15sf1013835wgh.8 for ; Mon, 22 Sep 2014 14:26:09 -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 :mime-version:cc:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=Mw8TQHtuJ4eud0CJZgv+K2rsQwOIw7nk8fjLFi7rBG4=; b=INVyftLZr10zm2GNt2RMMif68yXoBvnvvcgwjytRbxa8ZQIVk6CMkGksJo3ZYWYww6 Wlx3Wy7gF7ebhJJTV4KVe5cGWAA9xOECsqRFVnGvrQE31x7OuJlvCw6Dy785/Qv+c1oc jCQTOKhRuGo9Nl3M3vIcS9T1SNiuz8QzPQKR9pBYwTh7S2tVkAhanT61GGMNxeVsdcdB WpBA4vFLWpl+ANxPuumVGWCFz+TPcmGgC3nFG+henBNbAjkCCOnniaC2dmQaVU6hep3C NimsPFejmJm9X0L+5C9Vl4xncjrRIMpds+P5vRs7U7OzOqMYMlwUjnsU2Ar3yXzcRB7q 78sA== X-Gm-Message-State: ALoCoQmdHZRq+xVNi4PXciznFnkodWMY+HJdkLLRPbwXEjn6UHj5538WrMsFCu616JEFYCgbpol7 X-Received: by 10.152.2.97 with SMTP id 1mr28918lat.6.1411421169550; Mon, 22 Sep 2014 14:26:09 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.44.165 with SMTP id f5ls596788lam.33.gmail; Mon, 22 Sep 2014 14:26:09 -0700 (PDT) X-Received: by 10.112.55.7 with SMTP id n7mr19302337lbp.16.1411421169413; Mon, 22 Sep 2014 14:26:09 -0700 (PDT) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com [209.85.217.181]) by mx.google.com with ESMTPS id i3si16077860lbd.16.2014.09.22.14.26.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Sep 2014 14:26:09 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by mail-lb0-f181.google.com with SMTP id b6so2369144lbj.40 for ; Mon, 22 Sep 2014 14:26:09 -0700 (PDT) X-Received: by 10.152.179.226 with SMTP id dj2mr28535038lac.40.1411421169332; Mon, 22 Sep 2014 14:26:09 -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.130.169 with SMTP id of9csp316405lbb; Mon, 22 Sep 2014 14:26:08 -0700 (PDT) X-Received: by 10.180.77.200 with SMTP id u8mr18337165wiw.63.1411421168752; Mon, 22 Sep 2014 14:26:08 -0700 (PDT) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id ey3si7173wib.30.2014.09.22.14.26.08 for ; Mon, 22 Sep 2014 14:26:08 -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 AA433A73EF; Mon, 22 Sep 2014 23:26:07 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 Zg82sFCFQX9I; Mon, 22 Sep 2014 23:26:07 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D8E9CA73F7; Mon, 22 Sep 2014 23:26:04 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 35F12A73F7 for ; Mon, 22 Sep 2014 23:26:02 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 tDLxywxAZqpY for ; Mon, 22 Sep 2014 23:25:59 +0200 (CEST) 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-gw1-out.broadcom.com (mail-gw1-out.broadcom.com [216.31.210.62]) by theia.denx.de (Postfix) with ESMTP id 8D49CA73EF for ; Mon, 22 Sep 2014 23:25:54 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.04,574,1406617200"; d="scan'208";a="46706722" Received: from irvexchcas08.broadcom.com (HELO IRVEXCHCAS08.corp.ad.broadcom.com) ([10.9.208.57]) by mail-gw1-out.broadcom.com with ESMTP; 22 Sep 2014 15:34:04 -0700 Received: from IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.3.174.1; Mon, 22 Sep 2014 14:25:53 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) with Microsoft SMTP Server id 14.3.174.1; Mon, 22 Sep 2014 14:25:53 -0700 Received: from mail.broadcom.com (lbrmn-vmlnx03.ric.broadcom.com [10.136.4.105]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id C85F940FE6; Mon, 22 Sep 2014 14:25:52 -0700 (PDT) From: Steve Rae To: Tom Rini Date: Mon, 22 Sep 2014 14:29:10 -0700 Message-ID: <1411421350-17805-1-git-send-email-srae@broadcom.com> X-Mailer: git-send-email 1.8.5 MIME-Version: 1.0 Cc: Marek Vasut , u-boot@lists.denx.de, Steve Rae Subject: [U-Boot] [PATCH v1] fastboot: handle flash write to GPT partition X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: srae@broadcom.com 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.181 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 a feature to allow fastboot to write the downloaded image to the space reserved for the Protective MBR and the Primary GUID Partition Table. Signed-off-by: Steve Rae --- This series depends on: http://patchwork.ozlabs.org/patch/383184/ (to 388186) README | 7 +++++++ common/fb_mmc.c | 19 ++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/README b/README index e8341b7..2e4e0c4 100644 --- a/README +++ b/README @@ -1639,6 +1639,13 @@ The following options need to be configured: regarding the non-volatile storage device. Define this to the eMMC device that fastboot should use to store the image. + CONFIG_FASTBOOT_GPT_NAME + The fastboot "flash" command supports writing the downloaded + image to the Protective MBR and the Primary GUID Partition + Table. This occurs when the specified "partition name" on the + "fastboot flash" command line matches this value. + Default is GPT_ENTRY_NAME (currently "gpt") if undefined. + - Journaling Flash filesystem support: CONFIG_JFFS2_NAND, CONFIG_JFFS2_NAND_OFF, CONFIG_JFFS2_NAND_SIZE, CONFIG_JFFS2_NAND_DEV diff --git a/common/fb_mmc.c b/common/fb_mmc.c index fb06d8a..89fbf23 100644 --- a/common/fb_mmc.c +++ b/common/fb_mmc.c @@ -4,12 +4,17 @@ * SPDX-License-Identifier: GPL-2.0+ */ +#include #include #include #include #include #include +#ifndef CONFIG_FASTBOOT_GPT_NAME +#define CONFIG_FASTBOOT_GPT_NAME GPT_ENTRY_NAME +#endif + /* The 64 defined bytes plus the '\0' */ #define RESPONSE_LEN (64 + 1) @@ -62,9 +67,9 @@ static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info, void fb_mmc_flash_write(const char *cmd, void *download_buffer, unsigned int download_bytes, char *response) { - int ret; block_dev_desc_t *dev_desc; disk_partition_t info; + lbaint_t blksz; /* initialize the response buffer */ response_str = response; @@ -76,8 +81,16 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer, return; } - ret = get_partition_info_efi_by_name(dev_desc, cmd, &info); - if (ret) { + if (strcmp(cmd, CONFIG_FASTBOOT_GPT_NAME) == 0) { + printf("%s: updating GUID Partition Table (including MBR)\n", + __func__); + /* start at Protective MBR */ + info.start = (GPT_PRIMARY_PARTITION_TABLE_LBA - 1); + blksz = dev_desc->blksz; + info.blksz = blksz; + /* assume that the Partition Entry Array starts in LBA 2 */ + info.size = (2 + (GPT_ENTRY_NUMBERS * GPT_ENTRY_SIZE) / blksz); + } else if (get_partition_info_efi_by_name(dev_desc, cmd, &info)) { error("cannot find partition: '%s'\n", cmd); fastboot_fail("cannot find partition"); return;