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 91421C4332F for ; Wed, 10 Nov 2021 08:29:08 +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 E51B8610CB for ; Wed, 10 Nov 2021 08:29:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E51B8610CB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de 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 F3CAF839BD; Wed, 10 Nov 2021 09:29:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1636532946; bh=4de5D43unnHl2g3sEbuf/UcMZILuf3ag2GkwuMdwFNo=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=MJwIGY86W5fVc44C0VzRs7hgrSYL1jUpnMwkA6KN7R/FF4W91bMTbYeSp+jj1rxo7 wzrrLDWpu+0UNPwaNLstAOH8qj0Nd20TwT/pxww4FcHKgB+j5L24iGLxgJ/ogPhyVp ePscaOVGT6a2yPV/wMOoOBG33fZovoi5ZoMKkQk0r4lrgroUU4TGrWuzmDvhVmTpSn V5vEJQY7wWmXEAbg6WmMiV8Fec2xkA8ZBFXIWllZGK0qKftcRxwSr0GRV3dNtpK01S CrdW2lC3Hh+MP6V1KicV+O/3df1oxz8j05B58/fXtkvT5QlGxxcPCURd/Ijx0nmDrU ifKRwiibNxdNQ== Received: by phobos.denx.de (Postfix, from userid 109) id 49B26839BC; Wed, 10 Nov 2021 09:29:03 +0100 (CET) Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [IPv6:2001:67c:2050:1::465:204]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 63C1983983 for ; Wed, 10 Nov 2021 09:29:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp202.mailbox.org (unknown [91.198.250.118]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4HpygJ2JDLzQkd7; Wed, 10 Nov 2021 09:29:00 +0100 (CET) Message-ID: Date: Wed, 10 Nov 2021 09:28:56 +0100 MIME-Version: 1.0 Subject: Re: [PATCH u-boot-marvell 08/11] tools: kwbimage: Align kwbimage header to proper size Content-Language: en-US To: =?UTF-8?Q?Marek_Beh=c3=ban?= Cc: u-boot@lists.denx.de, =?UTF-8?Q?Pali_Roh=c3=a1r?= , =?UTF-8?Q?Marek_Beh=c3=ban?= References: <20211108171251.25382-1-kabel@kernel.org> <20211108171251.25382-9-kabel@kernel.org> From: Stefan Roese In-Reply-To: <20211108171251.25382-9-kabel@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed 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 On 08.11.21 18:12, Marek Behún wrote: > From: Pali Rohár > > Currently kwbimage header is always aligned to 4096 bytes. But it does not > have to be aligned to such a high value. > > The header needs to be just 4-byte aligned, while some image types have > additional alignment restrictions. > > This change reduces size of kwbimage binaries by removing extra padding > between header and data part. > > Signed-off-by: Pali Rohár > Signed-off-by: Marek Behún Reviewed-by: Stefan Roese Thanks, Stefan > --- > tools/kwbimage.c | 27 ++++++++++++++++++++++----- > 1 file changed, 22 insertions(+), 5 deletions(-) > > diff --git a/tools/kwbimage.c b/tools/kwbimage.c > index a6f2659ab4..8dcfebcb57 100644 > --- a/tools/kwbimage.c > +++ b/tools/kwbimage.c > @@ -858,6 +858,27 @@ done: > return ret; > } > > +static size_t image_headersz_align(size_t headersz, uint8_t blockid) > +{ > + /* > + * Header needs to be 4-byte aligned, which is already ensured by code > + * above. Moreover UART images must have header aligned to 128 bytes > + * (xmodem block size), NAND images to 256 bytes (ECC calculation), > + * and SATA and SDIO images to 512 bytes (storage block size). > + * Note that SPI images do not have to have header size aligned > + * to 256 bytes because it is possible to read from SPI storage from > + * any offset (read offset does not have to be aligned to block size). > + */ > + if (blockid == IBR_HDR_UART_ID) > + return ALIGN(headersz, 128); > + else if (blockid == IBR_HDR_NAND_ID) > + return ALIGN(headersz, 256); > + else if (blockid == IBR_HDR_SATA_ID || blockid == IBR_HDR_SDIO_ID) > + return ALIGN(headersz, 512); > + else > + return headersz; > +} > + > static void *image_create_v0(size_t *imagesz, struct image_tool_params *params, > int payloadsz) > { > @@ -994,11 +1015,7 @@ static size_t image_headersz_v1(int *hasext) > *hasext = 1; > } > > - /* > - * The payload should be aligned on some reasonable > - * boundary > - */ > - return ALIGN(headersz, 4096); > + return image_headersz_align(headersz, image_get_bootfrom()); > } > > int add_binary_header_v1(uint8_t **cur, uint8_t **next_ext, > Viele Grüße, Stefan Roese -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de