[PATCH] tools: kwboot: Check if baudrate value is supported before sending image

Tony Dinh mibodhi at gmail.com
Sun Mar 6 23:38:57 CET 2022


Hi Pali,

I have an observation, which is not related to this patch. But about
the kwboot options changes in general, I hope it is OK to mention it
here.

Before the changes you've made to solve the problem with the -b
option, I can do this:

kwboot -t  -B 115200 /dev/ttyUSB0 -b uboot.kwb

But now, the -b option can not be used after the tty device name. All
options must appear before the tty device.

Is this the actual intention? it did break some of my existing
aliases/scripts (It is not a big deal to retrofit them). Just want to
make sure I understand the reason to make the tty device a positional
argument for kwboot.

Thanks,
Tony

On Sun, Mar 6, 2022 at 4:39 AM Pali Rohár <pali at kernel.org> wrote:
>
> Call kwboot_open_tty() which baudrate value which was specified at the
> command line by option -B. This function returns error if baudrate is not
> supported by selected tty device.
>
> Initial baudrate for image transfer is always 115200, so call
> kwboot_tty_change_baudrate() with value 115200 immediately after
> kwboot_open_tty() if baudrate specified by option -B is different than
> 115200.
>
> This help user to see error message about unsupported baudrate value by
> local tty device immediately after starting kwboot.
>
> Before this change, kwboot sent kwbimage header (at 115200 Bd) and then
> validated that selected baudrate if is supported by tty device. It consumed
> too much time (need to send kwbimage again and again) until some supported
> baudrate by local tty device was guessed.
>
> Signed-off-by: Pali Rohár <pali at kernel.org>
> ---
>  tools/kwboot.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/tools/kwboot.c b/tools/kwboot.c
> index f975c4a6c6ca..d9498af8fc02 100644
> --- a/tools/kwboot.c
> +++ b/tools/kwboot.c
> @@ -2137,12 +2137,24 @@ main(int argc, char **argv)
>         if (optind != argc)
>                 goto usage;
>
> -       tty = kwboot_open_tty(ttypath, imgpath ? 115200 : baudrate);
> +       tty = kwboot_open_tty(ttypath, baudrate);
>         if (tty < 0) {
>                 perror(ttypath);
>                 goto out;
>         }
>
> +       /*
> +        * initial baudrate for image transfer is always 115200,
> +        * change to different baudrate is done after sending header
> +        */
> +       if (imgpath && baudrate != 115200) {
> +               rc = kwboot_tty_change_baudrate(tty, 115200);
> +               if (rc) {
> +                       perror(ttypath);
> +                       goto out;
> +               }
> +       }
> +
>         if (baudrate == 115200)
>                 /* do not change baudrate during Xmodem to the same value */
>                 baudrate = 0;
> --
> 2.20.1
>


More information about the U-Boot mailing list