From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7177C433F5 for ; Mon, 8 Nov 2021 17:14:49 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 51F11610A6 for ; Mon, 8 Nov 2021 17:14:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 51F11610A6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0A10283919; Mon, 8 Nov 2021 18:13:53 +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="U9BRHE5p"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F1CD98385E; Mon, 8 Nov 2021 18:13:32 +0100 (CET) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (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 1158B83903 for ; Mon, 8 Nov 2021 18:13:06 +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=kabel@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id D101E61130; Mon, 8 Nov 2021 17:13:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636391585; bh=h3xn05WwxmXtjljA96hlAPoSG5c8MqBRXAftrfXVk+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U9BRHE5pbVh/rgjpC6z/nH46+k1i80EM448v82iJShP436h6dkirAwIyymf15c25/ oNsh8KAraONsel47xS0f6wBisw8ptume2bZa5T66H976o1vLqSvqrX5izSYIJOTvE0 h1VKlAD7UHQFh2g7CD+oThvr2XrV/F/6n9vfu0nbO4gF+w7BfqoPeRYNc4YdCC0SCR 1YeHowQpkVZwkNLL58RszLVGLFk7VtndQ1aMSwxOs723aWp0FIXRh7im6X+xV2nVQZ GfeNunsRdDV4SAwBJ3a2HAfNd9l6hOQTgmqdGzvH1n7W3ITNBApt8LcIGPjmWNfWky mm3TIA1LdBgyQ== From: =?UTF-8?q?Marek=20Beh=C3=BAn?= To: Stefan Roese Cc: u-boot@lists.denx.de, =?UTF-8?q?Pali=20Roh=C3=A1r?= , =?UTF-8?q?Marek=20Beh=C3=BAn?= Subject: [PATCH u-boot-marvell 09/11] tools: kwbimage: Fill the real header size into the main header Date: Mon, 8 Nov 2021 18:12:49 +0100 Message-Id: <20211108171251.25382-10-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211108171251.25382-1-kabel@kernel.org> References: <20211108171251.25382-1-kabel@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár Fill the real header size without padding into the main header This allows to reduce final image when converting image to another format which does not need additional padding. Signed-off-by: Pali Rohár Signed-off-by: Marek Behún --- tools/kwbimage.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 8dcfebcb57..114b313b4d 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -1220,6 +1220,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, { struct image_cfg_element *e; struct main_hdr_v1 *main_hdr; + struct opt_hdr_v1 *ohdr; struct register_set_hdr_v1 *register_set_hdr; struct secure_hdr_v1 *secure_hdr = NULL; size_t headersz; @@ -1370,6 +1371,14 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, main_hdr->checksum = image_checksum8(main_hdr, headersz); *imagesz = headersz; + + /* Fill the real header size without padding into the main header */ + headersz = sizeof(*main_hdr); + for_each_opt_hdr_v1 (ohdr, main_hdr) + headersz += opt_hdr_v1_size(ohdr); + main_hdr->headersz_lsb = cpu_to_le16(headersz & 0xFFFF); + main_hdr->headersz_msb = (headersz & 0xFFFF0000) >> 16; + return image; } -- 2.32.0