From patchwork Wed Sep 23 17:25:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Harkin X-Patchwork-Id: 54063 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by patches.linaro.org (Postfix) with ESMTPS id 5BAD022E14 for ; Wed, 23 Sep 2015 17:27:29 +0000 (UTC) Received: by wisv5 with SMTP id v5sf28468521wis.0 for ; Wed, 23 Sep 2015 10:27:28 -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:in-reply-to :references: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=IA1rC7DTRN46pD3OixCTHH/q3vUSnotIVHSyxWLzIa8=; b=JbMbOceICu2N/wXNZnhNeSNe0mmwhz8Q+mdYeSwqawzaeDSp+RJ9Z5Bqr/2jeNpxOr 4GLlCtWEjKs0Ene3RbICggiHdMLH+2ltGst9P6RNYdiswjYcGQTLRlli/OUI/hkcu9G1 7LkBC0+Y06WuYywqABb/GR3sy3rDZ5xRLOBIczps2uYjtyTyGNUVngaZqxTUlwmVPBJR K2fBCu+oA1l/RUKc8tyL+pIknWNJeuiSMcKahIopMuEuKB7pwRrtihHUGOlJDhVz9azN WN0vxGzKnj8x05tIZJ81ircCXdiuUA13WgdrLejNC12wbTvI7jV8iNQXHmPDAY5pre/p YOOg== X-Gm-Message-State: ALoCoQlm0F8CA87X1OO9YVfVCKADnMOy5xw46newGxKmCaJqYyoBHB7mYBeIEGAv9ph8d1VypMZO X-Received: by 10.180.106.197 with SMTP id gw5mr813822wib.7.1443029248692; Wed, 23 Sep 2015 10:27:28 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.22.31 with SMTP id m31ls127596lfi.21.gmail; Wed, 23 Sep 2015 10:27:28 -0700 (PDT) X-Received: by 10.152.45.97 with SMTP id l1mr8552196lam.15.1443029248412; Wed, 23 Sep 2015 10:27:28 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id t1si4513989lae.137.2015.09.23.10.27.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Sep 2015 10:27:28 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by lagj9 with SMTP id j9so59471838lag.2 for ; Wed, 23 Sep 2015 10:27:28 -0700 (PDT) X-Received: by 10.112.17.34 with SMTP id l2mr11827660lbd.117.1443029248290; Wed, 23 Sep 2015 10:27:28 -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.59.35 with SMTP id w3csp23484lbq; Wed, 23 Sep 2015 10:27:27 -0700 (PDT) X-Received: by 10.180.103.199 with SMTP id fy7mr5086078wib.85.1443029247124; Wed, 23 Sep 2015 10:27:27 -0700 (PDT) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id fh1si12880644wic.62.2015.09.23.10.27.26; Wed, 23 Sep 2015 10:27:27 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2BFB24B898; Wed, 23 Sep 2015 19:27:26 +0200 (CEST) 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 I5Om1TTy3m6g; Wed, 23 Sep 2015 19:27:26 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 762784B929; Wed, 23 Sep 2015 19:27:24 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 362F34B92F for ; Wed, 23 Sep 2015 19:27:16 +0200 (CEST) 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 78MKVYQzSs6X for ; Wed, 23 Sep 2015 19:27:16 +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-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by theia.denx.de (Postfix) with ESMTPS id 25FA34B935 for ; Wed, 23 Sep 2015 19:27:10 +0200 (CEST) Received: by pacfv12 with SMTP id fv12so46732394pac.2 for ; Wed, 23 Sep 2015 10:27:09 -0700 (PDT) X-Received: by 10.66.146.69 with SMTP id ta5mr39262513pab.46.1443029229732; Wed, 23 Sep 2015 10:27:09 -0700 (PDT) Received: from localhost.localdomain ([70.35.39.2]) by smtp.gmail.com with ESMTPSA id fm5sm9061765pab.24.2015.09.23.10.27.05 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Sep 2015 10:27:09 -0700 (PDT) From: Ryan Harkin To: ryan.harkin@linaro.org, u-boot@lists.denx.de, Albert Aribaud , Tom Rini Date: Wed, 23 Sep 2015 10:25:39 -0700 Message-Id: <1443029143-22313-8-git-send-email-ryan.harkin@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1443029143-22313-1-git-send-email-ryan.harkin@linaro.org> References: <1443029143-22313-1-git-send-email-ryan.harkin@linaro.org> Cc: Steve Rae Subject: [U-Boot] [PATCH 07/11] common/armflash: add command to check if image exists 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: ryan.harkin@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.215.48 as permitted sender) smtp.mailfrom=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 Add a command to the ARM flash support to check if an image exists or not. If the image is found, it will return CMD_RET_SUCCESS, else CMD_RET_FAILURE. This allows hush scripts to conditionally load images. A simple example: if afs exists ${kernel_name}; then echo found; else echo \ not found; fi Signed-off-by: Ryan Harkin Reviewed-by: Linus Walleij CC: David Feng CC: Bhupesh Sharma CC: Linus Walleij --- common/cmd_armflash.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/common/cmd_armflash.c b/common/cmd_armflash.c index 1db92b0..a37f5c4 100644 --- a/common/cmd_armflash.c +++ b/common/cmd_armflash.c @@ -251,10 +251,28 @@ static void print_images(void) } } +static int exists(const char * const name) +{ + int i; + + parse_flash(); + for (i = 0; i < num_afs_images; i++) { + struct afs_image *afi = &afs_images[i]; + + if (strcmp(afi->name, name) == 0) + return CMD_RET_SUCCESS; + } + return CMD_RET_FAILURE; +} + static int do_afs(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { + int ret = CMD_RET_SUCCESS; + if (argc == 1) { print_images(); + } else if (argc == 3 && !strcmp(argv[1], "exists")) { + ret = exists(argv[2]); } else if (argc == 3 && !strcmp(argv[1], "load")) { load_image(argv[2], 0x0); } else if (argc == 4 && !strcmp(argv[1], "load")) { @@ -266,12 +284,14 @@ static int do_afs(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return CMD_RET_USAGE; } - return 0; + return ret; } U_BOOT_CMD(afs, 4, 0, do_afs, "show AFS partitions", "no arguments\n" " - list images in flash\n" + "exists \n" + " - returns 1 if an image exists, else 0\n" "load \n" " - load an image to the location indicated in the header\n" "load 0x
\n"