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 X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CE1DC07E9B for ; Wed, 21 Jul 2021 09:35:24 +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 9FCCC61181 for ; Wed, 21 Jul 2021 09:35:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9FCCC61181 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0327482039; Wed, 21 Jul 2021 11:35:21 +0200 (CEST) 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=1626860121; bh=jsGhkGLaLPjz4cUkG7d/5QguahbGXAcemr9v+DjZr64=; h=Subject:To:Cc:References:From:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=TOqtPMOuesLcKbf3mxTT+vLAjYFmxxc6whHCXNWEIS0qSXfhfNxX1brlJIRuQq03E ulbRbjRAZL+cMHYmmTD8TR0KJLu+ZN+0ypfizPdtwY+rgiJ5GY0XePe/imX14qYNUd iCgrGyHYs8ezv9IbqW9+WPteMEHEBrMPccekegPuBPjGfUh8bGNz3UkPZY3yCQPvDK dxoZgjzkBysYmEZ1dewBDLNC89S1qYUZNFAzIoll+pSgvyXrwGXIs9ZwevikQP+O+j fg9Z/ruNPhLSKGawtOuy/fiHSwAoK8P33mJ/K10ugGUnY+8Okb8zVJhZdavO7u+fN2 Tgop6ABGlBWlw== Received: by phobos.denx.de (Postfix, from userid 109) id 12C2682BDF; Wed, 21 Jul 2021 11:35:19 +0200 (CEST) Received: from mout-u-205.mailbox.org (mout-u-205.mailbox.org [IPv6:2001:67c:2050:1::465:205]) (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 C8BFD82039 for ; Wed, 21 Jul 2021 11:35:15 +0200 (CEST) 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 smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (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-205.mailbox.org (Postfix) with ESMTPS id 4GV9RR4JWVzQk2X; Wed, 21 Jul 2021 11:35:15 +0200 (CEST) Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter05.heinlein-hosting.de (spamfilter05.heinlein-hosting.de [80.241.56.123]) (amavisd-new, port 10030) with ESMTP id 4rECmxaTcXlb; Wed, 21 Jul 2021 11:35:11 +0200 (CEST) Subject: Re: [PATCH u-boot-mvebu v2 17/41] tools: kwbimage: Add support for DATA command also for v1 images To: =?UTF-8?Q?Marek_Beh=c3=ban?= , u-boot@lists.denx.de, Chris Packham , Baruch Siach , Dirk Eibach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?UTF-8?Q?Pali_Roh=c3=a1r?= References: <20210719122104.29698-1-marek.behun@nic.cz> <20210719122104.29698-18-marek.behun@nic.cz> From: Stefan Roese Message-ID: <1e2b6fe1-7fbf-386e-e10f-36afa45cd4cb@denx.de> Date: Wed, 21 Jul 2021 11:35:09 +0200 MIME-Version: 1.0 In-Reply-To: <20210719122104.29698-18-marek.behun@nic.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de-DE Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 9EF6F1858 X-Rspamd-UID: 135ee3 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 19.07.21 14:20, Marek Behún wrote: > From: Pali Rohár > > The DATA command is already supported by mkimage for v0 images, but not > for v1 images. > > BootROM code which executes v1 images also supports DATA command via an > optional extended v1 header OPT_HDR_V1_REGISTER_TYPE. > > Implement support for DATA command for v1 images. > > Signed-off-by: Pali Rohár > Reviewed-by: Marek Behún > Reviewed-by: Chris Packham > Tested-by: Chris Packham Reviewed-by: Stefan Roese Thanks, Stefan > --- > tools/kwbimage.c | 32 +++++++++++++++++++++++++++++++- > tools/kwbimage.h | 27 +++++++++++++++++++++++++++ > 2 files changed, 58 insertions(+), 1 deletion(-) > > diff --git a/tools/kwbimage.c b/tools/kwbimage.c > index 74a77412d7..b585f49180 100644 > --- a/tools/kwbimage.c > +++ b/tools/kwbimage.c > @@ -933,6 +933,7 @@ static void *image_create_v0(size_t *imagesz, struct image_tool_params *params, > static size_t image_headersz_v1(int *hasext) > { > struct image_cfg_element *binarye; > + unsigned int count; > size_t headersz; > int cfgi; > > @@ -942,6 +943,10 @@ static size_t image_headersz_v1(int *hasext) > */ > headersz = sizeof(struct main_hdr_v1); > > + count = image_count_options(IMAGE_CFG_DATA); > + if (count > 0) > + headersz += sizeof(struct register_set_hdr_v1) + 8 * count + 4; > + > for (cfgi = 0; cfgi < cfgn; cfgi++) { > int ret; > struct stat s; > @@ -1188,6 +1193,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 register_set_hdr_v1 *register_set_hdr; > #if defined(CONFIG_KWB_SECURE) > struct secure_hdr_v1 *secure_hdr = NULL; > #endif > @@ -1195,7 +1201,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, > uint8_t *image, *cur; > int hasext = 0; > uint8_t *next_ext = NULL; > - int cfgi; > + int cfgi, datai, size; > > /* > * Calculate the size of the header and the size of the > @@ -1279,6 +1285,30 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, > } > #endif > > + datai = 0; > + register_set_hdr = (struct register_set_hdr_v1 *)cur; > + for (cfgi = 0; cfgi < cfgn; cfgi++) { > + e = &image_cfg[cfgi]; > + if (e->type != IMAGE_CFG_DATA) > + continue; > + register_set_hdr->data[datai].entry.address = > + cpu_to_le32(e->regdata.raddr); > + register_set_hdr->data[datai].entry.value = > + cpu_to_le32(e->regdata.rdata); > + datai++; > + } > + if (datai != 0) { > + size = sizeof(struct register_set_hdr_v1) + 8 * datai + 4; > + register_set_hdr->headertype = OPT_HDR_V1_REGISTER_TYPE; > + register_set_hdr->headersz_lsb = cpu_to_le16(size & 0xFFFF); > + register_set_hdr->headersz_msb = size >> 16; > + /* Set delay to the smallest possible value 1ms. */ > + register_set_hdr->data[datai].last_entry.delay = 1; > + cur += size; > + *next_ext = 1; > + next_ext = ®ister_set_hdr->data[datai].last_entry.next; > + } > + > for (cfgi = 0; cfgi < cfgn; cfgi++) { > e = &image_cfg[cfgi]; > if (e->type != IMAGE_CFG_BINARY) > diff --git a/tools/kwbimage.h b/tools/kwbimage.h > index cab3d95d13..9f86da46e8 100644 > --- a/tools/kwbimage.h > +++ b/tools/kwbimage.h > @@ -148,6 +148,33 @@ struct secure_hdr_v1 { > uint16_t reserved5; /* 0x25E2 - 0x25E3 */ > }; > > +/* > + * Structure of register set > + */ > +struct register_set_hdr_v1 { > + uint8_t headertype; /* 0x0 */ > + uint8_t headersz_msb; /* 0x1 */ > + uint16_t headersz_lsb; /* 0x2 - 0x3 */ > + union { > + struct { > + uint32_t address; /* 0x4+8*N - 0x7+8*N */ > + uint32_t value; /* 0x8+8*N - 0xB+8*N */ > + } entry; > + struct { > + uint8_t next; /* 0xC+8*N */ > + uint8_t delay; /* 0xD+8*N */ > + uint16_t reserved; /* 0xE+8*N - 0xF+8*N */ > + } last_entry; > + } data[]; > +}; > + > +/* > + * Value 0 in register_set_hdr_v1 delay field is special. > + * Instead of delay it setup SDRAM Controller. > + */ > +#define REGISTER_SET_HDR_OPT_DELAY_SDRAM_SETUP 0 > +#define REGISTER_SET_HDR_OPT_DELAY_MS(val) ((val) ?: 1) > + > /* > * Various values for the opt_hdr_v1->headertype field, describing the > * different types of optional headers. The "secure" header contains > Viele Grüße, Stefan -- 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