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 E2E89C636D7 for ; Tue, 21 Feb 2023 20:34:40 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D0BB485A72; Tue, 21 Feb 2023 21:25:24 +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="hmwCRXD9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4799285ACB; Tue, 21 Feb 2023 21:24:02 +0100 (CET) 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 BC65085B33 for ; Tue, 21 Feb 2023 21:22: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 015F8611E4; Tue, 21 Feb 2023 20:22:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB2A7C4339E; Tue, 21 Feb 2023 20:22:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677010953; bh=RSHGLVBdlV9Djgrl6sLHbvX3WMl0bmz/3lqXV/Zx0hw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hmwCRXD9XtjdhBMhd2KXwJ6YGgTM/x5XfVtN78iwGsjaY4LdfXg2FKODgdpHJeKiN DiqkGy632mCuLqufixk+V7k7pCS/Xj06w1I+QmEQiOLpblr5BzCJn5QphCYWHzIqeA ZtjJhzi53ljXLOLXwjLvYY6ZdUx5kVMXuPLmvMJzx3oD7IZ1m7d4+dN1m35fLTCnFM 9ZWNEQJT4BKCRCEBHj8ghnohtZuM1F4gPOp3iC8K1E+sh8YnW/GZKJhmL6qLXIj1lm yAytv2fQ8H23XRDMTsumbGRGdeEddtWRK2a2CJWxa1X6ccI5c8NgMEzJX2nuSIA2aF BO5exiujqu/Qg== Received: by pali.im (Postfix) id 69AF1ADB; Tue, 21 Feb 2023 21:22:33 +0100 (CET) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: u-boot@lists.denx.de Cc: Stefan Roese , Tony Dinh , Josua Mayer Subject: [PATCH RFC u-boot-mvebu 34/59] tools: kwbimage: Fix dumping NAND_BLKSZ Date: Tue, 21 Feb 2023 21:19:00 +0100 Message-Id: <20230221201925.9644-35-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230221201925.9644-1-pali@kernel.org> References: <20230221201925.9644-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.6 at phobos.denx.de X-Virus-Status: Clean kwbimage nandblocksize field is in 64 kB unit, but NAND_BLKSZ command expects it in bytes. So do required unit conversion. Also zero value in nandblocksize field has special meaning. When this field is set to zero, the default block size is used. This default size is defined by the NAND flash page size (16 KB for a 512B page or small page NAND and 64 KB for a large page NAND flash). Fixes: 1a8e6b63e24f ("tools: kwbimage: Dump kwbimage config file on '-p -1' option") Signed-off-by: Pali Rohár --- tools/kwbimage.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 4e9ba5ddfae2..b6deb978f611 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -2184,8 +2184,14 @@ 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)le16_to_cpu(mhdr->nandpagesize)); - if (version != 0 && mhdr->blockid == IBR_HDR_NAND_ID) - fprintf(f, "NAND_BLKSZ 0x%x\n", (unsigned)mhdr->nandblocksize); + if (version != 0 && mhdr->blockid == IBR_HDR_NAND_ID) { + if (mhdr->nandblocksize != 0) /* block size explicitly set in 64 kB unit */ + fprintf(f, "NAND_BLKSZ 0x%x\n", (unsigned)mhdr->nandblocksize * 64*1024); + else if (le16_to_cpu(mhdr->nandpagesize) > 512) + fprintf(f, "NAND_BLKSZ 0x10000\n"); /* large page NAND flash = 64 kB block size */ + else + fprintf(f, "NAND_BLKSZ 0x4000\n"); /* small page NAND flash = 16 kB block size */ + } if (mhdr->blockid == IBR_HDR_NAND_ID && (version != 0 || is_v0_ext)) fprintf(f, "NAND_BADBLK_LOCATION 0x%x\n", (unsigned)mhdr->nandbadblklocation); -- 2.20.1