From patchwork Fri Feb 20 14:54:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 44864 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8576421554 for ; Fri, 20 Feb 2015 16:22:39 +0000 (UTC) Received: by mail-wg0-f72.google.com with SMTP id l18sf9842881wgh.3 for ; Fri, 20 Feb 2015 08:22:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mime-version:in-reply-to:references :from:date:message-id:to:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :content-type:content-transfer-encoding:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list; bh=0AI9G/m/FqlHpjggopiTLg9l4sp9ipi4E9+2Byf1pzE=; b=RMX2rlWCxRmqA467KvM4M4y9PtQIekQ4wD3fxdHNV35V9MT3vfjvrPbI7kf6sY6YXv spjZGN60u9cmyoMBuP+sX7QG09oJIkqSarCDzIhO97EZF6ojv2unjlr2BtEv4qnHqCNY QKu10KccYZ0VKj5LwRx9VLscZuQBM9cTY5IgjHms0TVp+HjZjX3VCb7h8XIR6ngm/eTV ai1C3neXJvoSoJ3+YeZI+WA3NS7N5LO1OHvLOvSvgsMaiOpOnKoesoE8lxHCTn2IVN9Z laZzmrtiwTBsAEqrLjdXEP5uY/eThiW49b0d7ikkwh+VndyZsR1SUdcGf5VRT3seWhpd +62w== X-Gm-Message-State: ALoCoQkeEaQog3/x/AOiomiML6TV6AX90cFRXG4OPFP5yjUc1wJEfzwQ61EyEOP73tezH4IUPajJ X-Received: by 10.112.144.130 with SMTP id sm2mr1432527lbb.9.1424449358778; Fri, 20 Feb 2015 08:22:38 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.115.180 with SMTP id jp20ls233435lab.64.gmail; Fri, 20 Feb 2015 08:22:38 -0800 (PST) X-Received: by 10.152.9.230 with SMTP id d6mr7471902lab.16.1424449358633; Fri, 20 Feb 2015 08:22:38 -0800 (PST) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id ec7si18387673lbc.32.2015.02.20.08.22.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Feb 2015 08:22:38 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by lbdu14 with SMTP id u14so7262307lbd.1 for ; Fri, 20 Feb 2015 08:22:38 -0800 (PST) X-Received: by 10.112.167.36 with SMTP id zl4mr9622725lbb.32.1424449358488; Fri, 20 Feb 2015 08:22:38 -0800 (PST) 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 h5csp1261509lbj; Fri, 20 Feb 2015 08:22:37 -0800 (PST) X-Received: by 10.180.19.9 with SMTP id a9mr21032219wie.85.1424449357460; Fri, 20 Feb 2015 08:22:37 -0800 (PST) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id b11si3597791wiw.57.2015.02.20.08.22.35; Fri, 20 Feb 2015 08:22:37 -0800 (PST) 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 696FB62081; Fri, 20 Feb 2015 17:19:43 +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 J6Bm3F7evVBU; Fri, 20 Feb 2015 17:19:43 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3FBA74B7CB; Fri, 20 Feb 2015 17:18:10 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 82F0D4A02C for ; Fri, 20 Feb 2015 15:55:19 +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 w6BH2QcuokWM for ; Fri, 20 Feb 2015 15:55:19 +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-la0-f46.google.com (mail-la0-f46.google.com [209.85.215.46]) by theia.denx.de (Postfix) with ESMTPS id 2846C4A02A for ; Fri, 20 Feb 2015 15:55:17 +0100 (CET) Received: by labhs14 with SMTP id hs14so6621135lab.1 for ; Fri, 20 Feb 2015 06:55:16 -0800 (PST) X-Received: by 10.152.4.233 with SMTP id n9mr8783224lan.61.1424444116715; Fri, 20 Feb 2015 06:55:16 -0800 (PST) MIME-Version: 1.0 Received: by 10.112.26.240 with HTTP; Fri, 20 Feb 2015 06:54:56 -0800 (PST) In-Reply-To: <1424289147-21828-1-git-send-email-dileep.katta@linaro.org> References: <1424289147-21828-1-git-send-email-dileep.katta@linaro.org> From: Rob Herring Date: Fri, 20 Feb 2015 08:54:56 -0600 Message-ID: To: Dileep Katta X-Mailman-Approved-At: Fri, 20 Feb 2015 17:17:09 +0100 Cc: srae@broadcom.com, angelabaker@ti.com, u-boot@lists.denx.de, trini@ti.com Subject: Re: [U-Boot] [PATCH v1 1/1] fastboot: Update getvar command to get 'userdata' partition size 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: rob.herring@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.174 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 On Wed, Feb 18, 2015 at 1:52 PM, Dileep Katta wrote: > This patch adds functionality to getvar command to get the userdata partition > size. This is non-standard and doesn't scale to other partitions. There is already a standard var "partition-size:". There is also "partition-type:" which probably needs to be supported as well. It would probably be good to have generic code to retrieve fastboot variables from a u-boot environment variables. Something like this: fastboot: allow retrieving fastboot variables from env Signed-off-by: Rob Herring } Rob > Signed-off-by: Dileep Katta > --- > common/fb_mmc.c | 38 ++++++++++++++++++++++++++++++++++++++ > drivers/usb/gadget/f_fastboot.c | 2 ++ > include/fb_mmc.h | 2 ++ > 3 files changed, 42 insertions(+) > > diff --git a/common/fb_mmc.c b/common/fb_mmc.c > index 6ea3938..1bb6335 100644 > --- a/common/fb_mmc.c > +++ b/common/fb_mmc.c > @@ -32,6 +32,44 @@ void fastboot_okay(const char *s) > strncat(response_str, s, RESPONSE_LEN - 4 - 1); > } > > +void fb_mmc_get_ptn_size(const char *cmd, char *response) > +{ > + int ret; > + block_dev_desc_t *dev_desc; > + disk_partition_t info; > + u32 sz_mb; > + u64 sz = 0; > + char buf[RESPONSE_LEN]; > + > + /* initialize the response buffer */ > + response_str = response; > + > + dev_desc = get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV); > + if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) { > + error("invalid mmc device"); > + fastboot_fail("invalid mmc device"); > + return; > + } > + > + ret = get_partition_info_efi_by_name(dev_desc, cmd, &info); > + if (ret) { > + error("cannot find partition: '%s'", cmd); > + fastboot_fail("cannot find partition"); > + return; > + } > + > + sz = (info.size * (u64)info.blksz) >> 10; > + > + if (sz >= 0xFFFFFFFF) { > + sz_mb = (u32)(sz >> 10); > + sprintf(buf, "0x%d MB", sz_mb); > + fastboot_okay(buf); > + } else { > + sprintf(buf, "%d KB", (u32)sz); > + fastboot_okay(buf); > + } > +} > + > 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) > diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c > index 310175a..17b64ef 100644 > --- a/drivers/usb/gadget/f_fastboot.c > +++ b/drivers/usb/gadget/f_fastboot.c > @@ -363,6 +363,8 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req) > strncat(response, s, chars_left); > else > strcpy(response, "FAILValue not set"); > + } else if (!strcmp_l1("userdata_size", cmd)) { > + fb_mmc_get_ptn_size("userdata", response); > } else { > error("unknown variable: %s\n", cmd); > strcpy(response, "FAILVariable not implemented"); > diff --git a/include/fb_mmc.h b/include/fb_mmc.h > index 1ad1d13..353f325 100644 > --- a/include/fb_mmc.h > +++ b/include/fb_mmc.h > @@ -4,5 +4,7 @@ > * SPDX-License-Identifier: GPL-2.0+ > */ > > +void fb_mmc_get_ptn_size(const char *cmd, char *response); > + > void fb_mmc_flash_write(const char *cmd, void *download_buffer, > unsigned int download_bytes, char *response); > -- > 1.8.3.2 > diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 310175a..31e1063 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -364,8 +364,15 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req) else strcpy(response, "FAILValue not set"); } else { - error("unknown variable: %s\n", cmd); - strcpy(response, "FAILVariable not implemented"); + char envstr[32]; + snprintf(envstr, sizeof(envstr) - 1, "fastboot.%s", cmd); + s = getenv(envstr); + if (s) { + strncat(response, s, chars_left); + } else { + error("unknown variable: %s\n", cmd); + strcpy(response, "FAILVariable not implemented"); + } } fastboot_tx_write_str(response);