From patchwork Tue Feb 15 18:59:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1593210 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=nqvK8qHs; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jyr4g0pKfz9s0B for ; Wed, 16 Feb 2022 06:00:01 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B2F7183A3F; Tue, 15 Feb 2022 19:59:50 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="nqvK8qHs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E8D1083A34; Tue, 15 Feb 2022 19:59:48 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4D55581F9A for ; Tue, 15 Feb 2022 19:59:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A251FB8124E; Tue, 15 Feb 2022 18:59:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50B05C340EC; Tue, 15 Feb 2022 18:59:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644951583; bh=72meb7rwoS+R+e1KEl2FYqeDWCs0XgWVv+SCyhOLO+Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nqvK8qHsjDD1Gx6y9FxRqd/oVQ1716uXuA6S3wKlIA+OTEhfbfRvPrQb7/sEIbE56 mbPaAnqqUdUtuV3oB7q4d39/AZKb0DEayJCYRAq9cmAI5yzAFSCoRSaGuYlSvb/0BA RABYcNwey2ulpJ+YeH04yiLiOKfhZ2cLHLZgaYXu15KJjfxU9NWRQ2s5w/h7vZeCx8 bhSeXklxlBGOsvX0lpgvhnAw1mgw8TzY/LVTUFgAC/kRu0UWzA+y6fCYRGn70DS3to WSfDakKnvjZNDoCSVLM/hkUC+39dp6GLdgYgcbJKg/0OwRz8Pp8Ks4HoXrRR/wpoEB IB8lRQ+BleJbQ== Received: by pali.im (Postfix) id 1AC7613D7; Tue, 15 Feb 2022 19:59:41 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Stefan Roese , =?utf-8?q?Marek_Beh=C3=BAn?= , Tony Dinh Cc: u-boot@lists.denx.de Subject: [PATCH u-boot-marvell 1/7] tools: kwbimage: Define structures for extended kwbimage v0 headers Date: Tue, 15 Feb 2022 19:59:19 +0100 Message-Id: <20220215185925.16060-2-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220215185925.16060-1-pali@kernel.org> References: <20220215185925.16060-1-pali@kernel.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean They are used by Marvell Dove 88AP510 BootROM. After the main header is a list of optional extended headers and after that is a list of optional binary executable headers. Between each two extended headers is additional 0x20 byte long padding. Original Kirkwood SoCs support only one extended header and no binary executable header. Extension of struct ext_hdr_v0 is backward compatible with the old definition. Only reserved[] fields are changed. Signed-off-by: Pali Rohár Reviewed-by: Stefan Roese --- tools/kwbimage.h | 51 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/tools/kwbimage.h b/tools/kwbimage.h index 9ebc7d72d363..706bebddf4fa 100644 --- a/tools/kwbimage.h +++ b/tools/kwbimage.h @@ -48,9 +48,13 @@ struct main_hdr_v0 { uint32_t destaddr; /* 0x10-0x13 */ uint32_t execaddr; /* 0x14-0x17 */ uint8_t satapiomode; /* 0x18 */ - uint8_t rsvd3; /* 0x19 */ + uint8_t nandblocksize; /* 0x19 */ + union { + uint8_t nandbadblklocation; /* 0x1A */ uint16_t ddrinitdelay; /* 0x1A-0x1B */ - uint16_t rsvd2; /* 0x1C-0x1D */ + }; + uint8_t rsvd2; /* 0x1C */ + uint8_t bin; /* 0x1D */ uint8_t ext; /* 0x1E */ uint8_t checksum; /* 0x1F */ } __packed; @@ -60,14 +64,43 @@ struct ext_hdr_v0_reg { uint32_t rdata; } __packed; -#define EXT_HDR_V0_REG_COUNT ((0x1dc - 0x20) / sizeof(struct ext_hdr_v0_reg)) - +/* Structure of the extension header, version 0 (Kirkwood, Dove) */ struct ext_hdr_v0 { - uint32_t offset; - uint8_t reserved[0x20 - sizeof(uint32_t)]; - struct ext_hdr_v0_reg rcfg[EXT_HDR_V0_REG_COUNT]; - uint8_t reserved2[7]; - uint8_t checksum; + /* + * Beware that extension header offsets specified in 88AP510 Functional + * Specifications are relative to the start of the main header, not to + * the start of the extension header itself. + */ + uint32_t offset; /* 0x0-0x3 */ + uint8_t rsvd1[8]; /* 0x4-0xB */ + uint32_t enddelay; /* 0xC-0xF */ + uint32_t match_addr; /* 0x10-0x13 */ + uint32_t match_mask; /* 0x14-0x17 */ + uint32_t match_value; /* 0x18-0x1B */ + uint8_t ddrwritetype; /* 0x1C */ + uint8_t ddrresetmpp; /* 0x1D */ + uint8_t ddrclkenmpp; /* 0x1E */ + uint8_t ddrinitdelay; /* 0x1F */ + struct ext_hdr_v0_reg rcfg[55]; /* 0x20-0x1D7 */ + uint8_t rsvd2[7]; /* 0x1D8-0x1DE */ + uint8_t checksum; /* 0x1DF */ +} __packed; + +/* Structure of the binary code header, version 0 (Dove) */ +struct bin_hdr_v0 { + uint32_t match_addr; /* 0x00-0x03 */ + uint32_t match_mask; /* 0x04-0x07 */ + uint32_t match_value; /* 0x08-0x0B */ + uint32_t offset; /* 0x0C-0x0F */ + uint32_t destaddr; /* 0x10-0x13 */ + uint32_t size; /* 0x14-0x17 */ + uint32_t execaddr; /* 0x18-0x1B */ + uint32_t params[4]; /* 0x1C-0x2B */ + uint8_t params_flags; /* 0x2C */ + uint8_t rsvd1; /* 0x2D */ + uint8_t rsvd2; /* 0x2E */ + uint8_t checksum; /* 0x2F */ + uint8_t code[2000]; /* 0x30-0x7FF */ } __packed; /* Structure of the main header, version 1 (Armada 370/XP/375/38x/39x) */ From patchwork Tue Feb 15 18:59:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1593215 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=tEdDSEpq; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jyr5M2974z9s0B for ; Wed, 16 Feb 2022 06:00:39 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CA612839E8; Tue, 15 Feb 2022 20:00:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="tEdDSEpq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 46D00836A8; Tue, 15 Feb 2022 19:59:55 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 204DC83845 for ; Tue, 15 Feb 2022 19:59:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id ACE1661731; Tue, 15 Feb 2022 18:59:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CBDCC340EB; Tue, 15 Feb 2022 18:59:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644951584; bh=7Xv27Ih/7Ze9VoAj8FIHUR2aQ35pCYnmO26LYEG1Buo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tEdDSEpqYitnfOcfG46NwebTHl8mf8AT2Sii7OnscULIYiYCZ3psdnWoH9W3MXoT8 IeDpxMBVaQbVxXVzlJr3FKTUgAg1kNyuEWoiIYXsJQbG6HbsjnlyaiFHn1aGP3Wns/ /cMs+p7dBK5TYb23TRI2Bo2jAAM/nkzzSeMcxC7zbq5J7ZlKj+/ibGvyEQw0FlqfkJ wqkijRqfSh91y3eR3eNcCYE7GDjh8k4VRVtpLGCwkuGouynROwdqT12h1tpy5319Cc TPifqa67wtGO5bnirrAtLjYJGvh6OpnY+9YdbAD96VAv1oP3xAP+tXherIRqrQyk6J 0TMauh1K/UHtw== Received: by pali.im (Postfix) id 295AD2B24; Tue, 15 Feb 2022 19:59:42 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Stefan Roese , =?utf-8?q?Marek_Beh=C3=BAn?= , Tony Dinh Cc: u-boot@lists.denx.de Subject: [PATCH u-boot-marvell 2/7] tools: kwbimage: Fix calculating size of kwbimage v0 header Date: Tue, 15 Feb 2022 19:59:20 +0100 Message-Id: <20220215185925.16060-3-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220215185925.16060-1-pali@kernel.org> References: <20220215185925.16060-1-pali@kernel.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Extended and binary headers are optional and are part of the image header. Fixes kwboot to determinate correct length of Dove images. Signed-off-by: Pali Rohár Reviewed-by: Stefan Roese --- tools/kwbimage.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/kwbimage.h b/tools/kwbimage.h index 706bebddf4fa..502b6d503305 100644 --- a/tools/kwbimage.h +++ b/tools/kwbimage.h @@ -240,8 +240,20 @@ static inline size_t kwbheader_size(const void *header) if (kwbimage_version(header) == 0) { const struct main_hdr_v0 *hdr = header; + /* + * First extension header starts immediately after the main + * header without any padding. Between extension headers is + * 0x20 byte padding. There is no padding after the last + * extension header. First binary code header starts immediately + * after the last extension header (or immediately after the + * main header if there is no extension header) without any + * padding. There is no padding between binary code headers and + * neither after the last binary code header. + */ return sizeof(*hdr) + - hdr->ext ? sizeof(struct ext_hdr_v0) : 0; + hdr->ext * sizeof(struct ext_hdr_v0) + + ((hdr->ext > 1) ? ((hdr->ext - 1) * 0x20) : 0) + + hdr->bin * sizeof(struct bin_hdr_v0); } else { const struct main_hdr_v1 *hdr = header; From patchwork Tue Feb 15 18:59:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1593213 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=TQ0S2Da8; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jyr513r0Rz9s0B for ; Wed, 16 Feb 2022 06:00:21 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C4B7382F5E; Tue, 15 Feb 2022 19:59:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="TQ0S2Da8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 135BE81DB4; Tue, 15 Feb 2022 19:59:53 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8E2BD82DB7 for ; Tue, 15 Feb 2022 19:59:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4A8B761738; Tue, 15 Feb 2022 18:59:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69AF7C340F0; Tue, 15 Feb 2022 18:59:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644951583; bh=rwBNu+DKJ8b/RESlIgts+SMrjuPJExHaYnhi1dXJcV4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TQ0S2Da8WvAkxupcsuT+xOoYhYLSA6Me0oo/OGQY0uxVfxinFDAdN5NmMcFdJXjuZ kyQzi9s+bmJ8LI57uWiTjiLhgs17R7/7tHC/EGcvS5mHO1QNfT/ueKxmvGbjTmN6wN mAIg5+NXYPh62bXMuFf+7m175RwludsInkTOKZ1S97JZ8kvSxetMkHazSiUZezUSa2 EFfyJQtVlTAAewRbVWddpUjfmA3qp0pTQUQoRCG5hbqWCiINetKPfK4oc/lfr3k3I1 agS+th92GG1U1AGDYs5x0Ekz0pd82oBjhRw/0c00w+Pfjlqmg4WlnxvMLxJWQ8lNUe xAnB6lvi2SFoA== Received: by pali.im (Postfix) id 23EC6F13; Tue, 15 Feb 2022 19:59:43 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Stefan Roese , =?utf-8?q?Marek_Beh=C3=BAn?= , Tony Dinh Cc: u-boot@lists.denx.de Subject: [PATCH u-boot-marvell 3/7] tools: kwbimage: Add support for dumping extended and binary v0 headers Date: Tue, 15 Feb 2022 19:59:21 +0100 Message-Id: <20220215185925.16060-4-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220215185925.16060-1-pali@kernel.org> References: <20220215185925.16060-1-pali@kernel.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean dumpimage is now able to successfully parse and dump content of the Dove bootloader image. Note that support for generating these extended parts of v0 images is not included yet. Signed-off-by: Pali Rohár Reviewed-by: Stefan Roese --- tools/kwbimage.c | 127 ++++++++++++++++++++++++++++++++++++++++++----- tools/kwbimage.h | 51 +++++++++++++++++++ 2 files changed, 166 insertions(+), 12 deletions(-) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 99d38cd1cfb2..22e6a44c561c 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -17,6 +17,8 @@ #include #include "kwbimage.h" +#include + #include #include #include @@ -1898,6 +1900,7 @@ static void kwbimage_set_header(void *ptr, struct stat *sbuf, int ifd, static void kwbimage_print_header(const void *ptr) { struct main_hdr_v0 *mhdr = (struct main_hdr_v0 *)ptr; + struct bin_hdr_v0 *bhdr; struct opt_hdr_v1 *ohdr; printf("Image Type: MVEBU Boot from %s Image\n", @@ -1915,6 +1918,13 @@ static void kwbimage_print_header(const void *ptr) } } + for_each_bin_hdr_v0(bhdr, mhdr) { + printf("BIN Img Size: "); + genimg_print_size(le32_to_cpu(bhdr->size)); + printf("BIN Img Addr: %08x\n", le32_to_cpu(bhdr->destaddr)); + printf("BIN Img Entr: %08x\n", le32_to_cpu(bhdr->execaddr)); + } + printf("Data Size: "); genimg_print_size(mhdr->blocksize - sizeof(uint32_t)); printf("Load Address: %08x\n", mhdr->destaddr); @@ -1947,15 +1957,31 @@ static int kwbimage_verify_header(unsigned char *ptr, int image_size, /* Only version 0 extended header has checksum */ if (kwbimage_version(ptr) == 0) { struct main_hdr_v0 *mhdr = (struct main_hdr_v0 *)ptr; + struct ext_hdr_v0 *ext_hdr; + struct bin_hdr_v0 *bhdr; - if (mhdr->ext) { - struct ext_hdr_v0 *ext_hdr = (void *)(mhdr + 1); - + for_each_ext_hdr_v0(ext_hdr, ptr) { csum = image_checksum8(ext_hdr, sizeof(*ext_hdr) - 1); if (csum != ext_hdr->checksum) return -FDT_ERR_BADSTRUCTURE; } + for_each_bin_hdr_v0(bhdr, ptr) { + csum = image_checksum8(bhdr, (uint8_t *)&bhdr->checksum - (uint8_t *)bhdr - 1); + if (csum != bhdr->checksum) + return -FDT_ERR_BADSTRUCTURE; + + if (bhdr->offset > sizeof(*bhdr) || bhdr->offset % 4 != 0) + return -FDT_ERR_BADSTRUCTURE; + + if (bhdr->offset + bhdr->size + 4 > sizeof(*bhdr) || bhdr->size % 4 != 0) + return -FDT_ERR_BADSTRUCTURE; + + if (image_checksum32((uint8_t *)bhdr + bhdr->offset, bhdr->size) != + *(uint32_t *)((uint8_t *)bhdr + bhdr->offset + bhdr->size)) + return -FDT_ERR_BADSTRUCTURE; + } + blockid = mhdr->blockid; offset = le32_to_cpu(mhdr->srcaddr); size = le32_to_cpu(mhdr->blocksize); @@ -2130,8 +2156,11 @@ static int kwbimage_generate_config(void *ptr, struct image_tool_params *params) struct register_set_hdr_v1 *regset_hdr; struct ext_hdr_v0_reg *regdata; struct ext_hdr_v0 *ehdr0; + struct bin_hdr_v0 *bhdr0; struct opt_hdr_v1 *ohdr; + int params_count; unsigned offset; + int is_v0_ext; int cur_idx; int version; FILE *f; @@ -2145,6 +2174,14 @@ static int kwbimage_generate_config(void *ptr, struct image_tool_params *params) version = kwbimage_version(ptr); + is_v0_ext = 0; + if (version == 0) { + if (mhdr0->ext > 1 || mhdr0->bin || + ((ehdr0 = ext_hdr_v0_first(ptr)) && + (ehdr0->match_addr || ehdr0->match_mask || ehdr0->match_value))) + is_v0_ext = 1; + } + if (version != 0) fprintf(f, "VERSION %d\n", version); @@ -2156,10 +2193,11 @@ static int kwbimage_generate_config(void *ptr, struct image_tool_params *params) if (mhdr->blockid == IBR_HDR_NAND_ID) fprintf(f, "NAND_PAGE_SIZE 0x%x\n", (unsigned)mhdr->nandpagesize); - if (version != 0 && mhdr->blockid == IBR_HDR_NAND_ID) { + if (version != 0 && mhdr->blockid == IBR_HDR_NAND_ID) fprintf(f, "NAND_BLKSZ 0x%x\n", (unsigned)mhdr->nandblocksize); + + if (mhdr->blockid == IBR_HDR_NAND_ID && (mhdr->nandbadblklocation != 0 || is_v0_ext)) fprintf(f, "NAND_BADBLK_LOCATION 0x%x\n", (unsigned)mhdr->nandbadblklocation); - } if (version == 0 && mhdr->blockid == IBR_HDR_SATA_ID) fprintf(f, "SATA_PIO_MODE %u\n", (unsigned)mhdr0->satapiomode); @@ -2222,8 +2260,39 @@ static int kwbimage_generate_config(void *ptr, struct image_tool_params *params) } } - if (version == 0 && mhdr0->ext) { - ehdr0 = (struct ext_hdr_v0 *)(mhdr0 + 1); + if (version == 0 && !is_v0_ext && le16_to_cpu(mhdr0->ddrinitdelay)) + fprintf(f, "DDR_INIT_DELAY %u\n", (unsigned)le16_to_cpu(mhdr0->ddrinitdelay)); + + for_each_ext_hdr_v0(ehdr0, ptr) { + if (is_v0_ext) { + fprintf(f, "\nMATCH ADDRESS 0x%08x MASK 0x%08x VALUE 0x%08x\n", + le32_to_cpu(ehdr0->match_addr), + le32_to_cpu(ehdr0->match_mask), + le32_to_cpu(ehdr0->match_value)); + if (ehdr0->rsvd1[0] || ehdr0->rsvd1[1] || ehdr0->rsvd1[2] || + ehdr0->rsvd1[3] || ehdr0->rsvd1[4] || ehdr0->rsvd1[5] || + ehdr0->rsvd1[6] || ehdr0->rsvd1[7]) + fprintf(f, "#DDR_RSVD1 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", + ehdr0->rsvd1[0], ehdr0->rsvd1[1], ehdr0->rsvd1[2], + ehdr0->rsvd1[3], ehdr0->rsvd1[4], ehdr0->rsvd1[5], + ehdr0->rsvd1[6], ehdr0->rsvd1[7]); + if (ehdr0->rsvd2[0] || ehdr0->rsvd2[1] || ehdr0->rsvd2[2] || + ehdr0->rsvd2[3] || ehdr0->rsvd2[4] || ehdr0->rsvd2[5] || + ehdr0->rsvd2[6]) + fprintf(f, "#DDR_RSVD2 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", + ehdr0->rsvd2[0], ehdr0->rsvd2[1], ehdr0->rsvd2[2], + ehdr0->rsvd2[3], ehdr0->rsvd2[4], ehdr0->rsvd2[5], + ehdr0->rsvd2[6]); + if (ehdr0->ddrwritetype) + fprintf(f, "DDR_WRITE_TYPE %u\n", (unsigned)ehdr0->ddrwritetype); + if (ehdr0->ddrresetmpp) + fprintf(f, "DDR_RESET_MPP 0x%x\n", (unsigned)ehdr0->ddrresetmpp); + if (ehdr0->ddrclkenmpp) + fprintf(f, "DDR_CLKEN_MPP 0x%x\n", (unsigned)ehdr0->ddrclkenmpp); + if (ehdr0->ddrinitdelay) + fprintf(f, "DDR_INIT_DELAY %u\n", (unsigned)ehdr0->ddrinitdelay); + } + if (ehdr0->offset) { for (regdata = (struct ext_hdr_v0_reg *)((uint8_t *)ptr + ehdr0->offset); (uint8_t *)regdata < (uint8_t *)ptr + header_size && @@ -2234,10 +2303,38 @@ static int kwbimage_generate_config(void *ptr, struct image_tool_params *params) if ((uint8_t *)regdata != (uint8_t *)ptr + ehdr0->offset) fprintf(f, "DATA 0x0 0x0\n"); } + + if (le32_to_cpu(ehdr0->enddelay)) + fprintf(f, "DATA_DELAY %u\n", le32_to_cpu(ehdr0->enddelay)); + else if (is_v0_ext) + fprintf(f, "DATA_DELAY SDRAM_SETUP\n"); } - if (version == 0 && le16_to_cpu(mhdr0->ddrinitdelay)) - fprintf(f, "DDR_INIT_DELAY %u\n", (unsigned)le16_to_cpu(mhdr0->ddrinitdelay)); + cur_idx = 1; + for_each_bin_hdr_v0(bhdr0, ptr) { + fprintf(f, "\nMATCH ADDRESS 0x%08x MASK 0x%08x VALUE 0x%08x\n", + le32_to_cpu(bhdr0->match_addr), + le32_to_cpu(bhdr0->match_mask), + le32_to_cpu(bhdr0->match_value)); + + fprintf(f, "BINARY binary%d.bin", cur_idx); + params_count = fls(bhdr0->params_flags & 0xF); + for (i = 0; i < params_count; i++) + fprintf(f, " 0x%x", (bhdr0->params[i] & (1 << i)) ? bhdr0->params[i] : 0); + fprintf(f, " LOAD_ADDRESS 0x%08x", le32_to_cpu(bhdr0->destaddr)); + fprintf(f, " EXEC_ADDRESS 0x%08x", le32_to_cpu(bhdr0->execaddr)); + fprintf(f, "\n"); + + fprintf(f, "#BINARY_OFFSET 0x%x\n", le32_to_cpu(bhdr0->offset)); + fprintf(f, "#BINARY_SIZE 0x%x\n", le32_to_cpu(bhdr0->size)); + + if (bhdr0->rsvd1) + fprintf(f, "#BINARY_RSVD1 0x%x\n", (unsigned)bhdr0->rsvd1); + if (bhdr0->rsvd2) + fprintf(f, "#BINARY_RSVD2 0x%x\n", (unsigned)bhdr0->rsvd2); + + cur_idx++; + } /* Undocumented reserved fields */ @@ -2245,9 +2342,6 @@ static int kwbimage_generate_config(void *ptr, struct image_tool_params *params) fprintf(f, "#RSVD1 0x%x 0x%x 0x%x\n", (unsigned)mhdr0->rsvd1[0], (unsigned)mhdr0->rsvd1[1], (unsigned)mhdr0->rsvd1[2]); - if (version == 0 && mhdr0->rsvd3) - fprintf(f, "#RSVD3 0x%x\n", (unsigned)mhdr0->rsvd3); - if (version == 0 && le16_to_cpu(mhdr0->rsvd2)) fprintf(f, "#RSVD2 0x%x\n", (unsigned)le16_to_cpu(mhdr0->rsvd2)); @@ -2266,6 +2360,7 @@ static int kwbimage_extract_subimage(void *ptr, struct image_tool_params *params { struct main_hdr_v1 *mhdr = (struct main_hdr_v1 *)ptr; size_t header_size = kwbheader_size(ptr); + struct bin_hdr_v0 *bhdr; struct opt_hdr_v1 *ohdr; int idx = params->pflag; int cur_idx; @@ -2312,6 +2407,14 @@ static int kwbimage_extract_subimage(void *ptr, struct image_tool_params *params ++cur_idx; } + for_each_bin_hdr_v0(bhdr, ptr) { + if (idx == cur_idx) { + image = (ulong)bhdr + bhdr->offset; + size = bhdr->size; + break; + } + ++cur_idx; + } if (!image) { fprintf(stderr, "Argument -p %d is invalid\n", idx); diff --git a/tools/kwbimage.h b/tools/kwbimage.h index 502b6d503305..505522332bd4 100644 --- a/tools/kwbimage.h +++ b/tools/kwbimage.h @@ -270,6 +270,57 @@ static inline size_t kwbheader_size_for_csum(const void *header) return kwbheader_size(header); } +static inline struct ext_hdr_v0 *ext_hdr_v0_first(void *img) +{ + struct main_hdr_v0 *mhdr; + + if (kwbimage_version(img) != 0) + return NULL; + + mhdr = img; + if (mhdr->ext) + return (struct ext_hdr_v0 *)(mhdr + 1); + else + return NULL; +} + +static inline void *_ext_hdr_v0_end(struct main_hdr_v0 *mhdr) +{ + return (uint8_t *)mhdr + kwbheader_size(mhdr) - mhdr->bin * sizeof(struct bin_hdr_v0); +} + +static inline struct ext_hdr_v0 *ext_hdr_v0_next(void *img, struct ext_hdr_v0 *cur) +{ + if ((void *)(cur + 1) < _ext_hdr_v0_end(img)) + return (struct ext_hdr_v0 *)((uint8_t *)(cur + 1) + 0x20); + else + return NULL; +} + +#define for_each_ext_hdr_v0(ehdr, img) \ + for ((ehdr) = ext_hdr_v0_first((img)); \ + (ehdr) != NULL; \ + (ehdr) = ext_hdr_v0_next((img), (ehdr))) + +static inline struct bin_hdr_v0 *bin_hdr_v0_first(void *img) +{ + struct main_hdr_v0 *mhdr; + + if (kwbimage_version(img) != 0) + return NULL; + + mhdr = img; + if (mhdr->bin) + return _ext_hdr_v0_end(mhdr); + else + return NULL; +} + +#define for_each_bin_hdr_v0(bhdr, img) \ + for ((bhdr) = bin_hdr_v0_first((img)); \ + (bhdr) && (void *)(bhdr) < (void *)((uint8_t *)img + kwbheader_size(img)); \ + (bhdr) = (struct bin_hdr_v0 *)((bhdr))+1) + static inline uint32_t opt_hdr_v1_size(const struct opt_hdr_v1 *ohdr) { return (ohdr->headersz_msb << 16) | le16_to_cpu(ohdr->headersz_lsb); From patchwork Tue Feb 15 18:59:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1593214 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=WEeGz7oM; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jyr5B32M7z9s0B for ; Wed, 16 Feb 2022 06:00:30 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ED99483909; Tue, 15 Feb 2022 20:00:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="WEeGz7oM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0260983845; Tue, 15 Feb 2022 19:59:56 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5AD2F83909 for ; Tue, 15 Feb 2022 19:59:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1F8A06173E; Tue, 15 Feb 2022 18:59:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62C2BC340F2; Tue, 15 Feb 2022 18:59:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644951584; bh=8UPGJu2/j+SM8qAyKgpXUHJ0X7/BIoQ5TvWtGmkBW2g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WEeGz7oM+GaQk8clKZ05ut3UopuX3SHN+fyRNDmxvkuamY0U5jpfFgmAyY0H0f3sE 2XQty+sfA0zROSJ+6f4DiILFvKls+EYQHdNqnDtcleJM8Fz50BHjFibMqGNkeNZcxE pUXkYwSAfBu1kiRBDGBtSyeFfCux6HTIEd8NA6kiJCjCd1rZCqNtRA5dBZbU7B0w1j KrGkIx1G1+KkV/YefAhqGD8AfHyP0dzB+eqPDri4kQ81w82aKwkgSxtzHVZWn8cAF/ 9ahOBmI6xVvYtZth3Lrgd0Ugv51JewH3sJJogZ5IVMK+wz8fWJYk5B1B10TzTANYK+ fXidPP9tJ1rOw== Received: by pali.im (Postfix) id 1C365F13; Tue, 15 Feb 2022 19:59:44 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Stefan Roese , =?utf-8?q?Marek_Beh=C3=BAn?= , Tony Dinh Cc: u-boot@lists.denx.de Subject: [PATCH u-boot-marvell 4/7] tools: kwbimage: Do not show mkimage error message in dumpimage Date: Tue, 15 Feb 2022 19:59:22 +0100 Message-Id: <20220215185925.16060-5-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220215185925.16060-1-pali@kernel.org> References: <20220215185925.16060-1-pali@kernel.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean When pflag is set then kwbimage was invoked by dumpimage and not mkimage. So do not show mkimage error message in this case. Signed-off-by: Pali Rohár Reviewed-by: Stefan Roese --- tools/kwbimage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 22e6a44c561c..8fd30516c9d4 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -2436,7 +2436,7 @@ static int kwbimage_extract_subimage(void *ptr, struct image_tool_params *params */ static int kwbimage_check_params(struct image_tool_params *params) { - if (!params->lflag && !params->iflag && + if (!params->lflag && !params->iflag && !params->pflag && (!params->imagename || !strlen(params->imagename))) { char *msg = "Configuration file for kwbimage creation omitted"; From patchwork Tue Feb 15 18:59:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1593217 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=qjXAOEat; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jyr5X1hqXz9s0B for ; Wed, 16 Feb 2022 06:00:48 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D528283A51; Tue, 15 Feb 2022 20:00:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="qjXAOEat"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1074881DDF; Tue, 15 Feb 2022 19:59:58 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 68B42839E8 for ; Tue, 15 Feb 2022 19:59:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1ED9D61741; Tue, 15 Feb 2022 18:59:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 644AEC340EB; Tue, 15 Feb 2022 18:59:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644951585; bh=3I7ZZpbWc0rxND240vnDa776xhZogM5tWbmXEALKG2c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qjXAOEatGTyiziguTkFXi/wLW6l19W1Nt2tx5TMsWeYIy04KZnDMd5itFNXYibczU iZDsfdKEcdp3I//ITuhRQBMLSUVlQLBT/OEugfgiuRlWeKLyflvuvp67kg/cD2pPXr ZUYtdCCt3f8E+MWwbQyKqxKIVibY9Ltz2hXhJT2ZvT1bUghT3t6lQ1FLXyi9VCXQFf QL83ErBwuSGnDF8H6XU8SLQdDc1F+gsHV+h/1/Al3JROWj0zi9VDhInGC9jsl9jQ/g vvTkI6yz13UGJVI3uvbMq4zci8GYaYomssZaUnmQThYpEq+2yCgRcRnFO0GRldpG6f brZNn/KX5eFTQ== Received: by pali.im (Postfix) id 1DED3F13; Tue, 15 Feb 2022 19:59:45 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Stefan Roese , =?utf-8?q?Marek_Beh=C3=BAn?= , Tony Dinh Cc: u-boot@lists.denx.de Subject: [PATCH u-boot-marvell 5/7] tools: kwbimage: Add support for NAND_BLKSZ and NAND_BADBLK_LOCATION for v0 images Date: Tue, 15 Feb 2022 19:59:23 +0100 Message-Id: <20220215185925.16060-6-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220215185925.16060-1-pali@kernel.org> References: <20220215185925.16060-1-pali@kernel.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean These two commands are currently not processed when generating v0 images. Signed-off-by: Pali Rohár Reviewed-by: Stefan Roese --- tools/kwbimage.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 8fd30516c9d4..e455c10dc744 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -985,9 +985,15 @@ static void *image_create_v0(size_t *imagesz, struct image_tool_params *params, e = image_find_option(IMAGE_CFG_NAND_ECC_MODE); if (e) main_hdr->nandeccmode = e->nandeccmode; + e = image_find_option(IMAGE_CFG_NAND_BLKSZ); + if (e) + main_hdr->nandblocksize = e->nandblksz / (64 * 1024); e = image_find_option(IMAGE_CFG_NAND_PAGESZ); if (e) main_hdr->nandpagesize = cpu_to_le16(e->nandpagesz); + e = image_find_option(IMAGE_CFG_NAND_BADBLK_LOCATION); + if (e) + main_hdr->nandbadblklocation = e->nandbadblklocation; main_hdr->checksum = image_checksum8(image, sizeof(struct main_hdr_v0)); From patchwork Tue Feb 15 18:59:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1593218 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=rT0Nh0Ch; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jyr5j2qGdz9s0B for ; Wed, 16 Feb 2022 06:00:57 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1A459838F0; Tue, 15 Feb 2022 20:00:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="rT0Nh0Ch"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0DF7281DDF; Tue, 15 Feb 2022 19:59:59 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E9FD183A35 for ; Tue, 15 Feb 2022 19:59:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A3B8F61743; Tue, 15 Feb 2022 18:59:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5762FC340EB; Tue, 15 Feb 2022 18:59:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644951586; bh=aG6Oa8E+itbpMjxT4ZMTQxyA3vPPr01Aq35pQfqUibg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rT0Nh0Ch+ygKfMjdZ8ffFQVX15pENZccj0AvSrNNvJBMHgTFuS0hiENuQs2rRpWct Sorty0GiX5ttUjUQ9yR3C3F4NVjviydr7wGCbwM8lAMiUOsm/7HFJCO8XxGtmXWWMX FEhY8EZvC+Tgqjcyl6Wmhpfa7844aqpZhE9tBAntMVXy8CzUgBN8AhARgU+yYUJseM nJRhliQ21qhDgOxvtHSM/lBo5pikpflYzEPY0Myp0+QONn4Fu9ZgoNngHYhroUa0UL /tMiOuT6kg3i5Tko1q7mo0loFqGxUzQLBKGXs4VX27+M/3G/iYkO2MyVmNS/jiyLHY MoJvO4n8YU/3A== Received: by pali.im (Postfix) id 1126BF13; Tue, 15 Feb 2022 19:59:46 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Stefan Roese , =?utf-8?q?Marek_Beh=C3=BAn?= , Tony Dinh Cc: u-boot@lists.denx.de Subject: [PATCH u-boot-marvell 6/7] tools: kwbimage: Fix help how to extract DDR3 training code Date: Tue, 15 Feb 2022 19:59:24 +0100 Message-Id: <20220215185925.16060-7-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220215185925.16060-1-pali@kernel.org> References: <20220215185925.16060-1-pali@kernel.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean First binary executable header is extracted by '-p 1' argument. Signed-off-by: Pali Rohár Reviewed-by: Stefan Roese --- tools/kwbimage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index e455c10dc744..d82f04bea7c3 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -1102,7 +1102,7 @@ static size_t image_headersz_v1(int *hasext) fprintf(stderr, "Didn't find the file '%s' in '%s' which is mandatory to generate the image\n" "This file generally contains the DDR3 training code, and should be extracted from an existing bootable\n" - "image for your board. Use 'dumpimage -T kwbimage -p 0' to extract it from an existing image.\n", + "image for your board. Use 'dumpimage -T kwbimage -p 1' to extract it from an existing image.\n", e->binary.file, dir); return 0; } From patchwork Tue Feb 15 18:59:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1593219 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=PxoQrqqd; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jyr5v6fS1z9s0B for ; Wed, 16 Feb 2022 06:01:07 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 30204839E2; Tue, 15 Feb 2022 20:00:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="PxoQrqqd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 51F5182AA3; Tue, 15 Feb 2022 19:59:59 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 484C582F5E for ; Tue, 15 Feb 2022 19:59:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0345661742; Tue, 15 Feb 2022 18:59:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DE79C36AE2; Tue, 15 Feb 2022 18:59:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644951587; bh=xM76Lm/ab6GMZCv2I7S2pDQ39zSNDOmf32AKiTM1Y7E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PxoQrqqdMWKXgL0sk2yJ++bX0UufML/PJLBbh8c8RMc1BJzWGxw4dW78IbhHm3q2C sqRZJBkKGqqiyiyyBxdEFyyG/xueHb/s8Tk5OGrL2Vh4mNVX59/ude0c4qE5jcRkIA rdh2lK5i32icdFExQUquKSYiEi34C4c/n+U21fBSxAWJPtN4WyHERG/Gcj98Va6lxO MS6VwIn+RJzxK9eVx8n+zy5LD6SZkvBoBwF+iQexFpo82VRgGxzHd/8Gxo5wACpVTk Xd7bqQmj+wYULMaZcuacjlMvpNaE1RpvjZiE5yhUhBPH1bm4zEJvd0f/AYYHlUbojE n4KJlmr3GshYQ== Received: by pali.im (Postfix) id 06E3AF13; Tue, 15 Feb 2022 19:59:47 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Stefan Roese , =?utf-8?q?Marek_Beh=C3=BAn?= , Tony Dinh Cc: u-boot@lists.denx.de Subject: [PATCH u-boot-marvell 7/7] tools: kwbimage: Add me as an author of kwbimage Date: Tue, 15 Feb 2022 19:59:25 +0100 Message-Id: <20220215185925.16060-8-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220215185925.16060-1-pali@kernel.org> References: <20220215185925.16060-1-pali@kernel.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Signed-off-by: Pali Rohár Reviewed-by: Stefan Roese --- tools/kwbimage.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index d82f04bea7c3..a3c1592b8140 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -6,6 +6,8 @@ * * (C) Copyright 2013 Thomas Petazzoni * + * + * (C) Copyright 2022 Pali Rohár */ #define OPENSSL_API_COMPAT 0x10101000L