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 2D768C00140 for ; Mon, 8 Aug 2022 03:24:05 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 01DC8849AA; Mon, 8 Aug 2022 05:24:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=mediatek.com header.i=@mediatek.com header.b="s4ANmAcu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 25128849AA; Mon, 8 Aug 2022 05:24:01 +0200 (CEST) Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (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 B85D9849A6 for ; Mon, 8 Aug 2022 05:23:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=weijie.gao@mediatek.com X-UUID: dfd8900ad5684a0688a59357295e578f-20220808 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:MIME-Version:Content-Type:References:In-Reply-To:Date:CC:To:From:Subject:Message-ID; bh=wChnIQCst6NezGMn1pktfj0yaS08tkdVTmqYvoWKVkg=; b=s4ANmAcuzu1Z/bU3jhgMhNyRVWoPX1aOAt91876ZeAx1d8cHtQnRrqh31vQiGjmKfrrL1qPJ4L+E9uxox1OuZnp27GtJSlpdU8rFFjEvKkuq7lqJzNnWZ0scnVlZ0G88pL4pAkj6tcXQO8Mgt+JQrXOtmUhE0TDJQ2NzaQjPPY8=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.8, REQID:566810ef-2c7e-4978-8abe-e7d0ac970aed, OB:0, LO B:0,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:22,FILE:0,RULE:Release_Ham,ACT ION:release,TS:22 X-CID-INFO: VERSION:1.1.8, REQID:566810ef-2c7e-4978-8abe-e7d0ac970aed, OB:0, LOB: 0,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:22,FILE:0,RULE:Release_Ham,ACTIO N:release,TS:22 X-CID-META: VersionHash:0f94e32, CLOUDID:b33f2cae-9535-44a6-aa9b-7f62b79b6ff6, C OID:IGNORED,Recheck:0,SF:28|100|17|19|48|101,TC:nil,Content:0,EDM:-3,IP:ni l,URL:0,File:nil,QS:nil,BEC:nil,COL:0 X-UUID: dfd8900ad5684a0688a59357295e578f-20220808 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 24946251; Mon, 08 Aug 2022 11:23:49 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.15; Mon, 8 Aug 2022 11:23:48 +0800 Received: from mcddlt001.gcn.mediatek.inc (10.19.240.15) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 8 Aug 2022 11:23:47 +0800 Message-ID: <0afd239714e4107f4cae14ffb39fa3604f78da95.camel@mediatek.com> Subject: Re: [PATCH 29/31] tools: mtk_image: split the code of generating NAND header into a new file From: Weijie Gao To: Simon Glass CC: U-Boot Mailing List , GSS_MTK_Uboot_upstream , AKASHI Takahiro , Pali =?ISO-8859-1?Q?Roh=E1r?= , Stefan Roese , Andre Przywara , Samuel Holland Date: Mon, 8 Aug 2022 11:23:47 +0800 In-Reply-To: References: <229679cb5bf2e96cd0d046b560a30d5e81227ef9.1659581119.git.weijie.gao@mediatek.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.1-2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-MTK: N 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 On Thu, 2022-08-04 at 07:57 -0600, Simon Glass wrote: > Hi Weijie, > > On Wed, 3 Aug 2022 at 21:37, Weijie Gao > wrote: > > > > The predefined NAND headers take too much spaces in the > > mtk_image.c. > > Moving them into a new file can significantly improve the > > readability of > > both mtk_image.c and the new mtk_nand_headers.c. > > > > This is a preparation for adding more NAND headers. > > > > Signed-off-by: Weijie Gao > > --- > > tools/Makefile | 1 + > > tools/mtk_image.c | 304 ++++++----------------------------- > > ---- > > tools/mtk_image.h | 25 ---- > > tools/mtk_nand_headers.c | 286 > > ++++++++++++++++++++++++++++++++++++ > > tools/mtk_nand_headers.h | 52 +++++++ > > 5 files changed, 379 insertions(+), 289 deletions(-) > > create mode 100644 tools/mtk_nand_headers.c > > create mode 100644 tools/mtk_nand_headers.h > > Reviewed-by: Simon Glass > > [..] > > > new file mode 100644 > > index 0000000000..691db85005 > > --- /dev/null > > +++ b/tools/mtk_nand_headers.h > > @@ -0,0 +1,52 @@ > > +/* SPDX-License-Identifier: GPL-2.0+ */ > > +/* > > + * MediaTek BootROM NAND header definitions > > + * > > + * Copyright (C) 2022 MediaTek Inc. > > + * Author: Weijie Gao > > + */ > > + > > +#ifndef _MTK_NAND_HEADERS_H > > +#define _MTK_NAND_HEADERS_H > > + > > +#include > > +#include > > + > > +struct nand_header_info { > > + uint32_t page_size; > > + uint32_t spare_size; > > + uint32_t gfh_offset; > > +}; > > + > > +/* AP BROM Header for NAND */ > > Where is this documented? This wasn't documented. The bootrom doesn't know the configuration of the nand device. It has to read the first page to retrive necessary information from this header. > > > +union nand_boot_header { > > + struct { > > + char name[12]; > > + char version[4]; > > + char id[8]; > > + uint16_t ioif; > > + uint16_t pagesize; > > + uint16_t addrcycles; > > + uint16_t oobsize; > > + uint16_t pages_of_block; > > + uint16_t numblocks; > > + uint16_t writesize_shift; > > + uint16_t erasesize_shift; > > + uint8_t dummy[60]; > > + uint8_t ecc_parity[28]; > > + }; > > + > > + uint8_t data[0x80]; > > +}; > > + > > +#define NAND_BOOT_NAME "BOOTLOADER!" > > +#define NAND_BOOT_VERSION "V006" > > +#define NAND_BOOT_ID "NFIINFO" > > + > > +const union nand_boot_header *mtk_nand_header_find(const char > > *name); > > +uint32_t mtk_nand_header_size(const union nand_boot_header > > *hdr_nand); > > +int mtk_nand_header_info(const void *ptr, struct nand_header_info > > *info); > > +bool is_mtk_nand_header(const void *ptr); > > +uint32_t mtk_nand_header_put(const union nand_boot_header > > *hdr_nand, void > > *ptr); > > Please comment each of these. OK. > > > + > > +#endif /* _MTK_NAND_HEADERS_H */ > > -- > > 2.17.1 > > > > Regards, > SImon