From patchwork Fri Jun 22 14:58:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Kiernan X-Patchwork-Id: 933433 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="X9ZbpaW2"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41C1sR5jttz9s2L for ; Sat, 23 Jun 2018 00:58:19 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 75AEFC21C2F; Fri, 22 Jun 2018 14:58:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 54CFEC21C2F; Fri, 22 Jun 2018 14:58:14 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D7313C21C2F; Fri, 22 Jun 2018 14:58:12 +0000 (UTC) Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by lists.denx.de (Postfix) with ESMTPS id 7AB37C21C2C for ; Fri, 22 Jun 2018 14:58:12 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id p126-v6so2557192wmb.2 for ; Fri, 22 Jun 2018 07:58:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=JMPwdXIz/5DvST4DYNQLtwQfNKRbA7Kc0DEz15Ix1mM=; b=X9ZbpaW2BBWdW04OJxheaXUcJQnfBYWmfKG4CnjhhnOTkooX9h3qnGc0NDrhVMM2tq no6AJZ9tlWCodDO5Q07Dw5DtLScfjA9T9rduUlyCtSm1EaYnzvi23G26NZWo7MEjIqqC gDhLA2MLe3XcjI/kpYlLde6X8+B9Cn2zXWZYldz8ag/Bdp5LPr+9qz2JjtrCewCg/cs9 tVn+Mce8auNuPakgcoSLCu2lWxDd3WDON1tfopABYPZZtjv6Qbvxn3j8/Rn2QYocuqnH bAAC0OXbVf88fpOhHnAIEa5ijgvAqqITW4pdlwMSzE6fwwcxkgiVxZDb59dWdsJv4oyS B8TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=JMPwdXIz/5DvST4DYNQLtwQfNKRbA7Kc0DEz15Ix1mM=; b=P6c39qYk2BxJl/DJ3WDwGigBbV+tLc5fuxInOO9Abwh9bUVR7vFG7CZQ7wNXMRq7QC IobA8dRfpgqDBTVgXhJM4daaleJf2a3ZWbMDK6M+mVATtyGLaLSqUVKM4OxVSckhLdMK iSkE9idYALmEY7/m5e8d7sxEDKLk/Pslkz9r/nZ1mdBTgVMhtOgeRsebHu9klcl/Av9J 6Hipe8wGkYsIMMP8np/NOxbKknOoB2EnXRymeFu0ThfJjPm5nmW/NyDZi4gXfFbGMItX XcN6Bo7HT3hq126m7G7NSiE4MxwwuALX3LKgdhZKyQprgP8LAcxZRjJpNX5CszUI71az Rjrw== X-Gm-Message-State: APt69E14QuGMZa73CHSfAYmJ1TF15IwXFi084JAxGdKH+7+7jlM3nOxN ZeEFtoMGoqujxGcKrMTXqtcoJsmc X-Google-Smtp-Source: ADUXVKIiRhDK7UIOOXPowi8SGF3ox/Fkoy7V06FmXu9jjii9OXLROra4RNXMzmE++MVvo92lWxwkFw== X-Received: by 2002:a1c:2350:: with SMTP id j77-v6mr1890337wmj.108.1529679491935; Fri, 22 Jun 2018 07:58:11 -0700 (PDT) Received: from localhost.localdomain (193.164.125.18.ip.redstone-isp.net. [193.164.125.18]) by smtp.gmail.com with ESMTPSA id y18-v6sm329983wrn.68.2018.06.22.07.58.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Jun 2018 07:58:11 -0700 (PDT) From: Alex Kiernan To: u-boot@lists.denx.de Date: Fri, 22 Jun 2018 14:58:02 +0000 Message-Id: <20180622145802.2097-1-alex.kiernan@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [U-Boot] [PATCH] cmd: fit_image: Add default property for FIT format scripts X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" When sourcing a FIT format script, if we've not been told the unit name to use, look for a default property at the root of /images to work out which unit we should use. Signed-off-by: Alex Kiernan Reviewed-by: Simon Glass --- cmd/source.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/cmd/source.c b/cmd/source.c index 92481c4fff..6d98a1cfd3 100644 --- a/cmd/source.c +++ b/cmd/source.c @@ -22,6 +22,24 @@ #include #include +#if defined(CONFIG_FIT) +/** + * get_default_image() - Return default property from /images + * + * Return: Pointer to value of default property (or NULL) + */ +static const char *get_default_image(const void *fit) +{ + int images_noffset; + + images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH); + if (images_noffset < 0) + return NULL; + + return fdt_getprop(fit, images_noffset, FIT_DEFAULT_PROP, NULL); +} +#endif + int source (ulong addr, const char *fit_uname) { @@ -87,17 +105,20 @@ source (ulong addr, const char *fit_uname) #endif #if defined(CONFIG_FIT) case IMAGE_FORMAT_FIT: - if (fit_uname == NULL) { - puts ("No FIT subimage unit name\n"); - return 1; - } - fit_hdr = buf; if (!fit_check_format (fit_hdr)) { puts ("Bad FIT image format\n"); return 1; } + if (!fit_uname) + fit_uname = get_default_image(fit_hdr); + + if (!fit_uname) { + puts("No FIT subimage unit name\n"); + return 1; + } + /* get script component image node offset */ noffset = fit_image_get_node (fit_hdr, fit_uname); if (noffset < 0) {