All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: "Marek Behún" <kabel@kernel.org>
Cc: "Stefan Roese" <sr@denx.de>,
	u-boot@lists.denx.de, "Marek Behún" <marek.behun@nic.cz>
Subject: Re: [PATCH u-boot-marvell 00/13] Yet another kwboot improvements
Date: Wed, 27 Oct 2021 17:13:31 +0200	[thread overview]
Message-ID: <20211027151331.yss64d25vexffli5@pali> (raw)
In-Reply-To: <20211027170835.7c584981@thinkpad>

On Wednesday 27 October 2021 17:08:35 Marek Behún wrote:
> On Wed, 27 Oct 2021 16:10:21 +0200
> Pali Rohár <pali@kernel.org> wrote:
> 
> > On Wednesday 27 October 2021 15:52:47 Pali Rohár wrote:
> > > On Wednesday 27 October 2021 07:09:42 Stefan Roese wrote:  
> > > > On 26.10.21 20:48, Pali Rohár wrote:  
> > > > > On Tuesday 26 October 2021 16:21:02 Stefan Roese wrote:  
> > > > > > On 26.10.21 14:40, Pali Rohár wrote:  
> > > > > > > My another guess there could be a problem is usage of stack. Maybe it is
> > > > > > > possible that register with stack pointer is not initialized after the
> > > > > > > full transfer when going to execute main image. Same arm baudrate change
> > > > > > > code is used after the SPL and before main U-Boot, and the first
> > > > > > > instruction is "push". Maybe modifying the arm code to not use stack
> > > > > > > when switching the baudrate back to 115200 could also help. I will look
> > > > > > > at it.  
> > > > > > 
> > > > > > Thanks.  
> > > > > 
> > > > > Here is dirty hack patch which completely disable calling code for
> > > > > changing baudrate back to 115200 on ARM side:
> > > > > 
> > > > > diff --git a/tools/kwboot.c b/tools/kwboot.c
> > > > > index 5f4ff673972e..00d58a239c71 100644
> > > > > --- a/tools/kwboot.c
> > > > > +++ b/tools/kwboot.c
> > > > > @@ -1070,17 +1070,17 @@ kwboot_xmodem(int tty, const void *_img, size_t size, int baudrate)
> > > > >   		return rc;
> > > > >   	if (baudrate) {
> > > > > -		char buf[sizeof(kwb_baud_magic)];
> > > > > -
> > > > > -		kwboot_printv("Waiting 1s for baudrate change magic\n");
> > > > > -		rc = kwboot_tty_recv(tty, buf, sizeof(buf), 1000);
> > > > > -		if (rc)
> > > > > -			return rc;
> > > > > -
> > > > > -		if (memcmp(buf, kwb_baud_magic, sizeof(buf))) {
> > > > > -			errno = EPROTO;
> > > > > -			return -1;
> > > > > -		}
> > > > > +//		char buf[sizeof(kwb_baud_magic)];
> > > > > +//
> > > > > +//		kwboot_printv("Waiting 1s for baudrate change magic\n");
> > > > > +//		rc = kwboot_tty_recv(tty, buf, sizeof(buf), 1000);
> > > > > +//		if (rc)
> > > > > +//			return rc;
> > > > > +//
> > > > > +//		if (memcmp(buf, kwb_baud_magic, sizeof(buf))) {
> > > > > +//			errno = EPROTO;
> > > > > +//			return -1;
> > > > > +//		}
> > > > >   		kwboot_printv("\nChanging baudrate back to 115200 Bd\n\n");
> > > > >   		rc = kwboot_tty_change_baudrate(tty, 115200);
> > > > > @@ -1551,8 +1551,8 @@ kwboot_img_patch(void *img, size_t *size, int baudrate)
> > > > >   		 * This code is appended after the data part of the image and
> > > > >   		 * execaddr is changed to execute this code before U-Boot proper.
> > > > >   		 */
> > > > > -		kwboot_printv("Injecting code for changing baudrate back\n");
> > > > > -		_copy_baudrate_change_code(hdr, size, 1, baudrate, 115200);
> > > > > +//		kwboot_printv("Injecting code for changing baudrate back\n");
> > > > > +//		_copy_baudrate_change_code(hdr, size, 1, baudrate, 115200);  
> > > > 
> > > > I do have this here in my version as well:
> > > > 
> > > > 		/* Update the 32-bit data checksum */
> > > > 		*kwboot_img_csum32_ptr(img) = kwboot_img_csum32(img);
> > > > 
> > > > 		/* recompute header size */
> > > > 		hdrsz = kwbheader_size(hdr);
> > > > 
> > > > So I'm using the newer version, just to be sure.  
> > > 
> > > Ok, I probably generated diff against older version, but you have
> > > figured out how to apply it.
> > >   
> > > > >   		/* recompute header size */
> > > > >   		hdrsz = kwbheader_size(hdr);
> > > > > 
> > > > > As main U-Boot binary on ARM resets UART, it means that baudrate is
> > > > > properly set to 115200. Probably beginning of the U-Boot output could be
> > > > > lost but at least console should start.
> > > > > 
> > > > > Could you try this patch if it starts working now?  
> > > > 
> > > > Okay, applied this patch and and booting with different baudrates works
> > > > on this board again (tested with 230400):
> > > > 
> > > >  96 %
> > > > [......................................................................]
> > > >  98 %
> > > > [......................................................................]
> > > >  99 % [................       ]
> > > > Done
> > > > Finishing transfer
> > > > 
> > > > Changing baudrate back to 115200 Bd
> > > > 
> > > > [Type Ctrl-\ + c to quit]
> > > > 
> > > > 
> > > > U-Boot 2021.10-00908-gc129aa2f173a-dirty (Oct 27 2021 - 07:05:39 +0200)
> > > > 
> > > > SoC:   MV78260-B0 at 1333 MHz
> > > > I2C:   ready
> > > > DRAM:  2 GiB (667 MHz, 64-bit, ECC not enabled)
> > > > Loading Environment from SPIFlash... SF: Detected m25p128 with page size 256
> > > > Bytes, erase size 256 KiB, total 16 MiB
> > > > OK
> > > > Model: Marvell Armada XP theadorable
> > > > ...
> > > > 
> > > > 
> > > > Thanks,
> > > > Stefan  
> > > 
> > > Perfect! So it really looks like that issue is in the code which resets
> > > baudrate back to the value 115200.
> > > 
> > > I have there another diff which removes usage of the stack in code which
> > > resets baudrate back to default value:
> > > 
> > > diff --git a/tools/kwboot.c b/tools/kwboot.c
> > > index b56c9a0c8104..8f0e50501398 100644
> > > --- a/tools/kwboot.c
> > > +++ b/tools/kwboot.c
> > > @@ -1444,6 +1444,11 @@ _inject_baudrate_change_code(void *img, size_t *size, int pre,
> > >  	memcpy(code, kwboot_baud_code, codesz - 8);
> > >  	*(uint32_t *)(code + codesz - 8) = cpu_to_le32(old_baud);
> > >  	*(uint32_t *)(code + codesz - 4) = cpu_to_le32(new_baud);
> > > +
> > > +	if (!pre) {  
> > 
> > Ou, there is a mistake, it should be "if (pre) {"
> > 
> > > +		*(uint32_t *)code = cpu_to_le32(0xe1a00000); /* arm nop */
> > > +		*(uint32_t *)(code + codesz - 4*7) = cpu_to_le32(0xe12fff1e); /* bx lr */
> > > +	}
> 
> This fixes it for me as well, for that one Omnia which didn't work
> which I was debugging a few days ago.
> 
> I guess this can't be done in the binhdr? So we need 2 different
> versions? I don't quite like this ad-hoc change, but I also don't
> like two copies with just a small change between them...
> 
> Marek

I will prepare cleanup / proper patch with one (configurable) version.
Just I need to know if this change fixes issue also for AXP.

  reply	other threads:[~2021-10-27 15:13 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-25 13:12 [PATCH u-boot-marvell 00/13] Yet another kwboot improvements Marek Behún
2021-10-25 13:12 ` [PATCH u-boot-marvell 01/13] tools: kwboot: Initialize rfds to zero Marek Behún
2021-10-26  5:41   ` Stefan Roese
2021-10-25 13:12 ` [PATCH u-boot-marvell 02/13] tools: kwboot: Fix initialization of tty device Marek Behún
2021-10-26  5:41   ` Stefan Roese
2021-10-25 13:12 ` [PATCH u-boot-marvell 03/13] tools: kwboot: Reserve enough space for patching kwbimage in memory Marek Behún
2021-10-26  5:42   ` Stefan Roese
2021-10-25 13:12 ` [PATCH u-boot-marvell 04/13] tools: kwboot: Validate 4-byte image data checksum Marek Behún
2021-10-26  5:43   ` Stefan Roese
2021-10-25 13:12 ` [PATCH u-boot-marvell 05/13] tools: kwboot: Inject baudrate change back code after data part Marek Behún
2021-10-26  5:43   ` Stefan Roese
2021-10-25 13:12 ` [PATCH u-boot-marvell 06/13] tools: kwboot: Recalculate 4-byte data checksum after injecting baudrate code Marek Behún
2021-10-26  5:44   ` Stefan Roese
2021-10-25 13:12 ` [PATCH u-boot-marvell 07/13] tools: kwboot: Correctly set configuration of UART for BootROM messages Marek Behún
2021-10-26  5:45   ` Stefan Roese
2021-10-25 13:12 ` [PATCH u-boot-marvell 08/13] tools: kwboot: Show verbose message when waiting for baudrate change magic Marek Behún
2021-10-26  5:45   ` Stefan Roese
2021-10-25 13:13 ` [PATCH u-boot-marvell 09/13] tools: kwboot: Simplify code for aligning image header Marek Behún
2021-10-26  5:45   ` Stefan Roese
2021-10-25 13:13 ` [PATCH u-boot-marvell 10/13] tools: kwboot: Do not modify kwbimage header before increasing its size Marek Behún
2021-10-26  5:46   ` Stefan Roese
2021-10-25 13:13 ` [PATCH u-boot-marvell 11/13] tools: kwboot: Calculate real used space in kwbimage header when calling kwboot_img_grow_hdr() Marek Behún
2021-10-26  5:48   ` Stefan Roese
2021-10-25 13:13 ` [PATCH u-boot-marvell 12/13] tools: kwboot: Change retry loop from decreasing to increasing Marek Behún
2021-10-26  5:49   ` Stefan Roese
2021-10-25 13:13 ` [PATCH u-boot-marvell 13/13] tools: kwboot: Resend first 3 xmodem retry packets immediately Marek Behún
2021-10-26  5:50   ` Stefan Roese
2021-10-25 14:39 ` [PATCH u-boot-marvell 00/13] Yet another kwboot improvements Stefan Roese
2021-10-25 14:42   ` Pali Rohár
2021-10-25 15:15     ` Stefan Roese
2021-10-26  8:33       ` Pali Rohár
2021-10-26  8:45         ` Stefan Roese
2021-10-26  9:06           ` Pali Rohár
2021-10-26 11:09             ` Stefan Roese
2021-10-26 12:40               ` Pali Rohár
2021-10-26 13:06                 ` Marek Behún
2021-10-26 14:06                   ` Stefan Roese
2021-10-26 14:21                 ` Stefan Roese
2021-10-26 14:48                   ` Pali Rohár
2021-10-26 15:13                     ` Stefan Roese
2021-10-26 15:20                       ` Marek Behún
2021-10-26 15:25                         ` Stefan Roese
2021-10-26 15:34                           ` Marek Behún
2021-10-26 15:40                             ` Stefan Roese
2021-10-26 18:48                   ` Pali Rohár
2021-10-27  5:09                     ` Stefan Roese
2021-10-27 13:52                       ` Pali Rohár
2021-10-27 14:10                         ` Pali Rohár
2021-10-27 15:08                           ` Marek Behún
2021-10-27 15:13                             ` Pali Rohár [this message]
2021-10-27 15:27                           ` Stefan Roese
2021-10-27 15:29                             ` Pali Rohár
2021-10-27 21:03                             ` Pali Rohár
2021-10-28  6:16                               ` Stefan Roese
2021-10-28 11:04                                 ` Pali Rohár
2021-10-28 14:20                                   ` Stefan Roese
2021-10-28 17:00                                     ` Pali Rohár
2021-10-29  4:44                                       ` Stefan Roese
2021-11-03  7:46 ` Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211027151331.yss64d25vexffli5@pali \
    --to=pali@kernel.org \
    --cc=kabel@kernel.org \
    --cc=marek.behun@nic.cz \
    --cc=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.