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 B81A5C433F5 for ; Sun, 13 Feb 2022 21:15:18 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1545883B99; Sun, 13 Feb 2022 22:15:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz 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; secure) header.d=nic.cz header.i=@nic.cz header.b="k23iXZwr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D260383B88; Sun, 13 Feb 2022 22:15:14 +0100 (CET) Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) (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 39E3B83B99 for ; Sun, 13 Feb 2022 22:15:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from thinkpad (unknown [172.20.6.87]) by mail.nic.cz (Postfix) with ESMTPSA id ADAF71409CF; Sun, 13 Feb 2022 22:15:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1644786909; bh=74mGxAPa4G7U8PaEmfEJutPIIKG6gsvyHhPPZ4wGSZs=; h=Date:From:To; b=k23iXZwr4UqDug0R/lOPB2/vku2P0nX/3Z6GZaYYYX119PWWEjEw2EWnwQNYfS5PE /TNVHb1guc7Y9d/w9iotfXUVni3+SvcR4/lYBHGTAz4kgb6NR/1aj+yoIXAfWls/o4 Y4G0HZyN61k6jjEqGmY7JXj2V8iZ49vRUaCetf9Y= Date: Sun, 13 Feb 2022 22:15:09 +0100 From: Marek =?UTF-8?B?QmVow7pu?= To: Pali =?UTF-8?B?Um9ow6Fy?= Cc: Tony Dinh , U-Boot Mailing List , Stefan Roese , Tom Rini Subject: Re: kwboot: Marvell Dove UART booting Message-ID: <20220213221509.70e93cfd@thinkpad> In-Reply-To: <20220213194108.g6dwbbrwdsg2xa5d@pali> References: <20220213161642.ez37c3csppqvh7ca@pali> <20220213194108.g6dwbbrwdsg2xa5d@pali> X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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.5 at phobos.denx.de X-Virus-Status: Clean On Sun, 13 Feb 2022 20:41:08 +0100 Pali Roh=C3=A1r wrote: > On Sunday 13 February 2022 17:16:42 Pali Roh=C3=A1r wrote: > > On Wednesday 22 December 2021 20:08:56 Tony Dinh wrote: =20 > > > *** Run kwboot > > >=20 > > > # kwboot -t -p -B 115200 /dev/ttyUSB0 -D /localdisk/mtd0.t5335z > > > Patching image boot signature to UART > > > Aligning image header to Xmodem block size > > > Waiting 2s and flushing tty > > > Sending boot image header (512 bytes)... > > > 25 % [.... = ] > > > Done > > > Sending boot image data (607664 bytes)... > > > 0 % [..............................................................= ........] > > > 1 % [..............................................................= ........] > > > 2 % [..............................................................= ........] > > > > > > 95 % [..............................................................= ........] > > > 97 % [..............................................................= ........] > > > 98 % [.......................................................... = ] > > > Done > > > Finishing transfer > > > [Type Ctrl-\ + c to quit] > > >=20 > > > *** Hung here! BootROM did not execute the image payload. > > > *** > > > *** The file mtd0.t5335z is a dd dump from the SPI flash mtd0 with > > > *** this command: > > > *** # dd if=3D/dev/mtd0 of=3Dmtd0.t5335z bs=3D768k conv=3Dsync > > >=20 > > > > > >=20 > > >=20 > > > - Pali's observation: > > >=20 > > > It looks like Dove uses kwbimage v0 format with extensions, at > > > least according to Function Spec. See 'Binary Code Extension' and > > > 'Header Extension'. Currently kwboot and kwbimage supports v0 image o= nly > > > with one extension. =20 > >=20 > > I quickly looked at it. Could you try following patch? > >=20 > > diff --git a/tools/kwbimage.h b/tools/kwbimage.h > > index 74e5d87a4fef..15e83ececc76 100644 > > --- a/tools/kwbimage.h > > +++ b/tools/kwbimage.h > > @@ -61,14 +64,46 @@ struct ext_hdr_v0_reg { > > uint32_t rdata; > > } __packed; > > =20 > > -#define EXT_HDR_V0_REG_COUNT ((0x1dc - 0x20) / sizeof(struct ext_hdr_v= 0_reg)) > > - > > +/* Structure of the extension header, version 0 (Kirkwood, Dove) */ > > struct ext_hdr_v0 { > > - uint32_t offset; > > - uint8_t reserved[0x20 - sizeof(uint32_t)]; > > - struct ext_hdr_v0_reg rcfg[EXT_HDR_V0_REG_COUNT]; > > - uint8_t reserved2[7]; > > - uint8_t checksum; > > + /* > > + * Beware that extension header offsets specified in 88AP510 Function= al > > + * Specifications are relative to the start of the main header, not to > > + * the start of the extension header itself. > > + */ > > + uint32_t offset; /* 0x0-0x3 */ > > + uint8_t rsvd1[8]; /* 0x4-0xB */ > > + uint32_t ddrinitdelay; /* 0xC-0xF */ > > + uint32_t match_addr; /* 0x10-0x13 */ > > + uint32_t match_mask; /* 0x14-0x17 */ > > + uint32_t match_value; /* 0x18-0x1B */ > > + uint8_t ddrwritetype; /* 0x1C */ > > + uint8_t ddrresetmpp; /* 0x1D */ > > + uint8_t ddrclkenmpp; /* 0x1E */ > > + uint8_t ddrmppdelay; /* 0x1F */ > > + struct ext_hdr_v0_reg rcfg[55]; /* 0x20-0x1D7 */ > > + uint8_t rsvd2[7]; /* 0x1D8-0x1DE */ > > + uint8_t checksum; /* 0x1DF */ > > +} __packed; > > + > > +/* Structure of the binary code header, version 0 (Dove) */ > > +struct binext_hdr_v0 { > > + uint32_t match_addr; /* 0x00-0x03 */ > > + uint32_t match_mask; /* 0x04-0x07 */ > > + uint32_t match_value; /* 0x08-0x0B */ > > + uint32_t offset; /* 0x0C-0x0F */ > > + uint32_t destaddr; /* 0x10-0x13 */ > > + uint32_t size; /* 0x14-0x17 */ > > + uint32_t execaddr; /* 0x18-0x1B */ > > + uint32_t param1; /* 0x1C-0x1F */ > > + uint32_t param2; /* 0x20-0x23 */ > > + uint32_t param3; /* 0x24-0x27 */ > > + uint32_t param4; /* 0x28-0x2B */ > > + uint8_t params; /* 0x2C */ > > + uint8_t rsvd1; /* 0x2D */ > > + uint8_t rsvd2; /* 0x2E */ > > + uint8_t checksum; /* 0x2F */ > > + uint8_t code[2000]; /* 0x30-0x7FF */ > > } __packed; > > =20 > > /* Structure of the main header, version 1 (Armada 370/XP/375/38x/39x)= */ > > @@ -213,8 +248,20 @@ static inline size_t kwbheader_size(const void *he= ader) > > if (kwbimage_version(header) =3D=3D 0) { > > const struct main_hdr_v0 *hdr =3D header; > > =20 > > + /* > > + * First extension header starts immediately after the main > > + * header without any padding. Between extension headers is > > + * 0x20 byte padding. There is no padding after the last > > + * extension header. First binary code header starts immediately > > + * after the last extension header (or immediately after the > > + * main header if there is no extension header) without any > > + * padding. There is no padding between binary code headers and > > + * neither after the last binary code header. > > + */ > > return sizeof(*hdr) + > > - hdr->ext ? sizeof(struct ext_hdr_v0) : 0; > > + hdr->ext * sizeof(struct ext_hdr_v0) + > > + ((hdr->ext > 1) ? (hdr->ext * 0x20) : 0) + =20 >=20 > ^^^^^^^^^^^^^^^^^ > Ou.. there is a mistake. It should be: "((hdr->ext - 1) * 0x20)" > as number of paddings in between is number of headers minus one. In that case the whole ternary operator can be dropped, i.e. instead of ((hdr->ext > 1) ? (hdr->ext * 0x20) : 0) you can have ((hdr->ext - 1) * 0x20) if I interpret this correctly. Marek