From: "Pali Rohár" <pali@kernel.org>
To: Marcel Ziswiler <marcel@ziswiler.com>
Cc: "Stefan Roese" <sr@denx.de>, "Marek Behún" <marek.behun@nic.cz>,
u-boot@lists.denx.de,
"Konstantin Porotchkin" <kostap@marvell.com>,
"Robert Marko" <robimarko@gmail.com>,
"Sergey Sergeev" <adron@yapic.net>
Subject: Re: [PATCH] tools/mrvl_uart.sh: Remove script
Date: Mon, 7 Feb 2022 10:02:25 +0100 [thread overview]
Message-ID: <20220207090225.x7gplhvxtdhemcfp@pali> (raw)
In-Reply-To: <e81c8e87bc9a72e544d2ab73504f082104ad4290.camel@ziswiler.com>
On Monday 07 February 2022 08:20:54 Marcel Ziswiler wrote:
> On Sat, 2022-02-05 at 15:54 +0100, Pali Rohár wrote:
> > On Saturday 05 February 2022 03:07:00 Marcel Ziswiler wrote:
> > > On Sat, 2022-02-05 at 01:54 +0100, Pali Rohár wrote:
> > > > On Saturday 05 February 2022 01:40:23 Marcel Ziswiler wrote:
> > > > > On Sat, 2022-02-05 at 01:25 +0100, Pali Rohár wrote:
> > > > > > $ kwboot -b /dev/ttyUSB0
> > > > >
> > > > > Hm, at least kwboot from today's master does not allow -b without also
> > > > > giving it an image.
> > > >
> > > > This commit is part of master branch and added support for it:
> > > > https://source.denx.de/u-boot/u-boot/-/commit/c513fe47dca24de87a904ce7d71cfd8a390e1154
> > > >
> > > > If it does not work then there is some bug which should be fixed. I have
> > > > tested it and it works on my setup.
> > > >
> > > > Can you check if you have that commit to ensure that we are not going to
> > > > test / debug older version?
> > >
> > > Yes, sure. I debugged it a little and I believe I found the issue. I guess the intention was for it to be
> > > run
> > > giving it a dash '-' as image argument for skipping. (Even though that usually would mean using stdin).
> > > Anyway,
> > > it fails as it then uses such dash as ttypath because optind did not get incremented. The following fixes
> > > it
> > > for me:
> > >
> > > diff --git a/tools/kwboot.c b/tools/kwboot.c
> > > index 2684f0e75a..d490c026e9 100644
> > > --- a/tools/kwboot.c
> > > +++ b/tools/kwboot.c
> > > @@ -1768,7 +1768,8 @@ main(int argc, char **argv)
> > > if (prev_optind == optind)
> > > goto usage;
> > > if (argv[optind] && argv[optind][0] != '-')
> > > - imgpath = argv[optind++];
> > > + imgpath = argv[optind];
> > > + optind++;
> > > break;
> > >
> > > case 'D':
> > >
> > > Let me know if that is indeed the intention and I can send a proper fix for it. Maybe I can also update the
> > > documentation/usage in that respect. Thanks again.
> >
> > Now I see where is the issue. Your fix is incorrect because it breaks
> > other usage (e.g. specifying other options).
> >
> > The issue here is that argv[optind] is used also when it is the last
> > option on the command line -- which is not getopt() at all, as it is
> > parsed after the getopt() processing.
> >
> > So I think that correct fix should be something like this:
> >
> > bootmsg = kwboot_msg_boot;
> > if (prev_optind == optind)
> > goto usage;
> > - if (argv[optind] && argv[optind][0] != '-')
> > + if (optind < argc-1 && argv[optind] && argv[optind][0] != '-')
> > imgpath = argv[optind++];
> > break;
> >
> >
> > This should fix usage of all "kwboot -b /dev/tty", "kwboot -b -t /dev/tty"
> > and "kwboot -b image.kwb /dev/tty" usage.
> >
> > Could you test it?
>
> Yes, this indeed works fine now.
>
> With that, and if we properly document such "standalone" usage, I would be fine with dropping
> tools/mrvl_uart.sh. So you can get my reviewed-by for this one.
>
> Reviewed-by: Marcel Ziswiler <marcel@ziswiler.com>
>
> And you get my tested-by for such patch fixing this as outlined above.
>
> Tested-by: Marcel Ziswiler <marcel@ziswiler.com>
>
> > Seems that I tested only -b -t combination (as I wanted to see that
> > bootrom correctly start sending NAK xmodem bytes).
>
> Yep, now I got you. Thanks!
Ok, thank you for testing, I will send a proper patch to ML.
next prev parent reply other threads:[~2022-02-07 9:02 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-03 16:50 [PATCH] tools/mrvl_uart.sh: Remove script Pali Rohár
2022-02-03 17:05 ` Marek Behún
2022-02-04 5:46 ` Stefan Roese
2022-02-04 23:43 ` Marcel Ziswiler
2022-02-05 0:01 ` Marcel Ziswiler
2022-02-05 0:25 ` Pali Rohár
2022-02-05 0:40 ` Marcel Ziswiler
2022-02-05 0:54 ` Pali Rohár
2022-02-05 2:07 ` Marcel Ziswiler
2022-02-05 14:54 ` Pali Rohár
2022-02-07 7:20 ` Marcel Ziswiler
2022-02-07 9:02 ` Pali Rohár [this message]
2022-02-07 10:36 ` Robert Marko
2022-02-06 9:03 ` Stefan Roese
2022-02-07 7:26 ` Marcel Ziswiler
2022-02-07 8:19 ` Tony Dinh
2022-02-06 6:32 ` [EXT] " Kostya Porotchkin
2022-04-21 13:55 ` 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=20220207090225.x7gplhvxtdhemcfp@pali \
--to=pali@kernel.org \
--cc=adron@yapic.net \
--cc=kostap@marvell.com \
--cc=marcel@ziswiler.com \
--cc=marek.behun@nic.cz \
--cc=robimarko@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox