From patchwork Tue Sep 17 21:09:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 1163605 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=quarantine dis=none) header.from=ti.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="BoQ7+DkD"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46Xwjk1F2Pz9sPS for ; Wed, 18 Sep 2019 07:10:00 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 5B5B1C21E1E; Tue, 17 Sep 2019 21:09:47 +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=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 E0EF2C21C50; Tue, 17 Sep 2019 21:09:45 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4EE3EC21C50; Tue, 17 Sep 2019 21:09:45 +0000 (UTC) Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by lists.denx.de (Postfix) with ESMTPS id 9697EC21C29 for ; Tue, 17 Sep 2019 21:09:44 +0000 (UTC) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x8HL9f4b122406; Tue, 17 Sep 2019 16:09:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1568754581; bh=mNagqvf5szNZ5ABrRb3pJXzGvWwR4Eeg/UCPiN1F/E8=; h=From:To:CC:Subject:Date; b=BoQ7+DkDWcp33oil0YuvlmtJ3/NQQOEbCWQxxKv0uRSnpE4Y8Pw/uvbplZtBzKqBL LeD9ZHGBsGaH2stuE4JTD0kBcTjXOSDLfs3mXoQE6MGljpw+RVRBA54vNh5sHf7gDS Az6YJXq9QUJGzxss/zUEnkWaIGCvqQ0jAwxcicuA= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x8HL9fOk086677 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 17 Sep 2019 16:09:41 -0500 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 17 Sep 2019 16:09:37 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 16:09:38 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id x8HL9eE7083357; Tue, 17 Sep 2019 16:09:40 -0500 Received: from localhost ([10.250.95.88]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id x8HL9dZ11546; Tue, 17 Sep 2019 16:09:39 -0500 (CDT) From: "Andrew F. Davis" To: Tom Rini , Lokesh Vutla Date: Tue, 17 Sep 2019 17:09:33 -0400 Message-ID: <20190917210935.3666-1-afd@ti.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 1/3] tools: dumpimage: Provide more feedback on internal errors 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The dumpimage utility errors out in a number of places without providing sufficient feedback to allow the user to easily determine what has gone wrong. Add additional error messages to make the cause of the failure more obvious. Signed-off-by: Andrew F. Davis Reviewed-by: Lokesh Vutla --- tools/dumpimage.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/dumpimage.c b/tools/dumpimage.c index ee3d41dda4..d5f893daf1 100644 --- a/tools/dumpimage.c +++ b/tools/dumpimage.c @@ -35,14 +35,23 @@ static int dumpimage_extract_subimage(struct image_type_params *tparams, if (tparams->verify_header) { retval = tparams->verify_header((unsigned char *)ptr, sbuf->st_size, ¶ms); - if (retval != 0) + if (retval != 0) { + fprintf(stderr, "%s: failed to verify header of %s\n", + params.cmdname, tparams->name); return -1; + } + /* * Extract the file from the image * if verify is successful */ if (tparams->extract_subimage) { retval = tparams->extract_subimage(ptr, ¶ms); + if (retval != 0) { + fprintf(stderr, "%s: extract_subimage failed for %s\n", + params.cmdname, tparams->name); + return -3; + } } else { fprintf(stderr, "%s: extract_subimage undefined for %s\n", @@ -175,6 +184,9 @@ int main(int argc, char **argv) * image type. Returns the error code if not matched */ retval = dumpimage_extract_subimage(tparams, ptr, &sbuf); + if (retval) + fprintf(stderr, "%s: Can't extract subimage from %s\n", + params.cmdname, params.imagefile); } else { /* * Print the image information for matched image type From patchwork Tue Sep 17 21:09:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 1163607 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=quarantine dis=none) header.from=ti.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="ehqQuDke"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46Xwkj5vZnz9sP3 for ; Wed, 18 Sep 2019 07:10:53 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 8247DC21DFB; Tue, 17 Sep 2019 21:10:00 +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=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 5CD09C21EA1; Tue, 17 Sep 2019 21:09:59 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 78C99C21DFB; Tue, 17 Sep 2019 21:09:49 +0000 (UTC) Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by lists.denx.de (Postfix) with ESMTPS id 06C10C21E0F for ; Tue, 17 Sep 2019 21:09:46 +0000 (UTC) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id x8HL9iqD029496; Tue, 17 Sep 2019 16:09:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1568754584; bh=EpIOcp+Z4sXGBPV5mlBZgYbuzHE3gP/rqx09JhesbWg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ehqQuDkeEJfUe+CyCLK5fbMA6sBi4+4NAkpF7ySLt8L1654Oo4g/lAHbvBDamIZ5g iBGNAY1Gu8KpX2rsZfOyCEZGq0KNVRY0i7hBkoXZUr8CsLBcYPsXRGBOkyvZTzWzuV yuXPyiyaguy+3EsiJ+62x8UdTz9feurvLvTu/Wx4= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id x8HL9iCX031720; Tue, 17 Sep 2019 16:09:44 -0500 Received: from DLEE104.ent.ti.com (157.170.170.34) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 17 Sep 2019 16:09:41 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 16:09:41 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id x8HL9ic9128277; Tue, 17 Sep 2019 16:09:44 -0500 Received: from localhost ([10.250.95.88]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id x8HL9hZ11618; Tue, 17 Sep 2019 16:09:43 -0500 (CDT) From: "Andrew F. Davis" To: Tom Rini , Lokesh Vutla Date: Tue, 17 Sep 2019 17:09:34 -0400 Message-ID: <20190917210935.3666-2-afd@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190917210935.3666-1-afd@ti.com> References: <20190917210935.3666-1-afd@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 2/3] tools: fit_image: Use fit_image_get_data_and_size for getting offset/size 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This is very similar to fit_image_get_data but has the benefit of working on FIT images with external data unlike fit_image_get_data. This is useful for extracting sub-images from type of FIT image as this would previously just silently fail. Add an error message also so if this still fails it is easier to find out why. Signed-off-by: Andrew F. Davis Reviewed-by: Lokesh Vutla --- tools/fit_image.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/fit_image.c b/tools/fit_image.c index 5aca634b5e..0e4c2271ce 100644 --- a/tools/fit_image.c +++ b/tools/fit_image.c @@ -738,9 +738,14 @@ static int fit_image_extract( { const void *file_data; size_t file_size = 0; + int ret; - /* get the "data" property of component at offset "image_noffset" */ - fit_image_get_data(fit, image_noffset, &file_data, &file_size); + /* get the data address and size of component at offset "image_noffset" */ + ret = fit_image_get_data_and_size(fit, image_noffset, &file_data, &file_size); + if (ret) { + fprintf(stderr, "Could not get component information\n"); + return ret; + } /* save the "file_data" into the file specified by "file_name" */ return imagetool_save_subimage(file_name, (ulong) file_data, file_size); From patchwork Tue Sep 17 21:09:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 1163606 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=quarantine dis=none) header.from=ti.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="yTYl+8Lp"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46Xwkc2jPrz9sP3 for ; Wed, 18 Sep 2019 07:10:48 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id CA46AC21E60; Tue, 17 Sep 2019 21:10:11 +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=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 ED720C21E68; Tue, 17 Sep 2019 21:10:09 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 2CB0FC21E57; Tue, 17 Sep 2019 21:09:50 +0000 (UTC) Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by lists.denx.de (Postfix) with ESMTPS id 7BE7EC21E31 for ; Tue, 17 Sep 2019 21:09:47 +0000 (UTC) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x8HL9jvL122421; Tue, 17 Sep 2019 16:09:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1568754586; bh=X+SYPAqbBHnw4GnQicwgp5pVa1iKJ4inFx0eYhRmEh0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=yTYl+8LpX7+b535aIS4GXa2RmqDf+nx8mqPX82uJ2HHTMIDxjvWcPwuW8rtXDrhzq e8z8U6G15KXGG9F2nXdOLnC5nviVm2erwZUSxtN3QUoWHb1VFU3aOPnjG54zqPrMZB 2WtRgRyEpyKbWWbUHcHLAd7K4NQpE6gBjE16nOmY= Received: from DLEE107.ent.ti.com (dlee107.ent.ti.com [157.170.170.37]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x8HL9jE0085462 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 17 Sep 2019 16:09:45 -0500 Received: from DLEE111.ent.ti.com (157.170.170.22) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 17 Sep 2019 16:09:45 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE111.ent.ti.com (157.170.170.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 16:09:42 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id x8HL9jB8083440; Tue, 17 Sep 2019 16:09:45 -0500 Received: from localhost ([10.250.95.88]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id x8HL9iZ11638; Tue, 17 Sep 2019 16:09:44 -0500 (CDT) From: "Andrew F. Davis" To: Tom Rini , Lokesh Vutla Date: Tue, 17 Sep 2019 17:09:35 -0400 Message-ID: <20190917210935.3666-3-afd@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190917210935.3666-1-afd@ti.com> References: <20190917210935.3666-1-afd@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 3/3] tools: dumpimage: Fall-though to print usage for help command 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This has the same result but some compilers will warn about this fall-through if there are statements as part of the label block. Signed-off-by: Andrew F. Davis Reviewed-by: Lokesh Vutla --- tools/dumpimage.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/dumpimage.c b/tools/dumpimage.c index d5f893daf1..e5481435a7 100644 --- a/tools/dumpimage.c +++ b/tools/dumpimage.c @@ -104,7 +104,6 @@ int main(int argc, char **argv) printf("dumpimage version %s\n", PLAIN_VERSION); exit(EXIT_SUCCESS); case 'h': - usage(); default: usage(); break;