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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 15278C74A5B for ; Thu, 23 Mar 2023 19:59:05 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1540D85867; Thu, 23 Mar 2023 20:58:43 +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="cMFSMt52"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6DBD9858AB; Thu, 23 Mar 2023 20:58:36 +0100 (CET) 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 8C7E5859D6 for ; Thu, 23 Mar 2023 20:58:32 +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 D5B9662876; Thu, 23 Mar 2023 19:58:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14145C4339C; Thu, 23 Mar 2023 19:58:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679601510; bh=nlW445+ZxFdfsihQq5+CcW28FzNpyufJppEdQySTAPE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cMFSMt52Wk5Tkk+vb3Bhvzn0KPEil4As4slmdydVnGk1s0TbC78rW+S3Rz5PXT79+ t4XC+bTtyL22LybyiGPd1C8lRGals2mmVHvfw6B4y9o1AeDaDZ0FkZPTjz0gp2WV1Q jAYEpQcFbrG67BpnNLic3jAEaWICEHmtUj2nEDt8aGy++z+r6CacmnSJyQaJzR+0Px 958agrLq3lc4uOSVG/LM4kEiFhfG7QrqyiAov4n1xOfTRqCCrynqjkUnEBQtH2Aqnw kvFHVX8tOekpYCQk/8kJp76RxFY5mg3/Xpu7fE+psLU0pebvh8dq0oZ8izWnW8Q9vt 1NZJO3pDuFyBg== Received: by pali.im (Postfix) id 94B4B12C0; Thu, 23 Mar 2023 20:58:27 +0100 (CET) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Stefan Roese , Martin Rowe Cc: u-boot@lists.denx.de Subject: [PATCH u-boot-mvebu 2/5] tools: kwboot: Fix invalid UART kwbimage v1 headersz Date: Thu, 23 Mar 2023 20:57:52 +0100 Message-Id: <20230323195755.5131-3-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230323195755.5131-1-pali@kernel.org> References: <20230323195755.5131-1-pali@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.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.8 at phobos.denx.de X-Virus-Status: Clean Ensure that UART aligned header size is always stored into kwbimage v1 header. It is needed for proper UART booting. Calculation of headersz field was broken in commit d656f5a0ee22 ("tools: kwboot: Calculate real used space in kwbimage header when calling kwboot_img_grow_hdr()") which introduced optimization of kwboot_img_grow_hdr() function. Fixes: d656f5a0ee22 ("tools: kwboot: Calculate real used space in kwbimage header when calling kwboot_img_grow_hdr()") Signed-off-by: Pali Rohár --- tools/kwboot.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/kwboot.c b/tools/kwboot.c index c131711444ec..dd894e80db1c 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -2171,6 +2171,17 @@ kwboot_img_patch(void *img, size_t *size, int baudrate) kwboot_printv("Aligning image header to Xmodem block size\n"); kwboot_img_grow_hdr(img, size, grow); + hdrsz += grow; + + /* + * kwbimage v1 contains header size field and for UART type it + * must be set to the aligned xmodem header size because BootROM + * rounds header size down to xmodem block size. + */ + if (kwbimage_version(img) == 1) { + hdr->headersz_msb = hdrsz >> 16; + hdr->headersz_lsb = cpu_to_le16(hdrsz & 0xffff); + } } hdr->checksum = kwboot_hdr_csum8(hdr) - csum; -- 2.20.1