Re: [PATCH u-boot-marvell 13/13] tools: kwboot: Resend first 3 xmodem retry packets immediately

Stefan Roese
2021-10-26T05:50:22Z

On 25.10.21 15:13, Marek Behún wrote:
> From: Pali Rohár <pali@kernel.org>
>
> Currently when kwboot receive some garbage reply which does not understand,
> it waits 1s before it tries to resend packet again.
>
> The most common error on UART is that receiver sees some bit flipped which
> results in invalid reply.
>
> This behavior slows down xmodem transfer over UART as basically on every
> error kwboot is waiting one second.
>
> To fix this, try to resend xmodem packet for first 3 attempts immediately
> without any delay. If broken reply is received also after the 3 attempts,
> continue retrying with 1s delay like it was before.
>
> Signed-off-by: Pali Rohár <pali@kernel.org>
> Reviewed-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
> tools/kwboot.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/tools/kwboot.c b/tools/kwboot.c
> index 16c5a84825..bb7cae9f05 100644
> --- a/tools/kwboot.c
> +++ b/tools/kwboot.c
> @@ -851,7 +851,8 @@ kwboot_baud_magic_handle(int fd, char c, int baudrate)
> }
>
> static int
> -kwboot_xm_recv_reply(int fd, char *c, int allow_non_xm, int *non_xm_print,
> +kwboot_xm_recv_reply(int fd, char *c, int nak_on_non_xm,
> + int allow_non_xm, int *non_xm_print,
> int baudrate, int *baud_changed)
> {
> int timeout = allow_non_xm ? KWBOOT_HDR_RSP_TIMEO : blk_rsp_timeo;
> @@ -904,6 +905,10 @@ kwboot_xm_recv_reply(int fd, char *c, int allow_non_xm, int *non_xm_print,
> *non_xm_print = 1;
> }
> } else {
> + if (nak_on_non_xm) {
> + *c = NAK;
> + break;
> + }
> timeout = recv_until - _now();
> if (timeout < 0) {
> errno = ETIMEDOUT;
> @@ -937,7 +942,8 @@ kwboot_xm_sendblock(int fd, struct kwboot_block *block, int allow_non_xm,
> *done_print = 1;
> }
>
> - rc = kwboot_xm_recv_reply(fd, &c, allow_non_xm, &non_xm_print,
> + rc = kwboot_xm_recv_reply(fd, &c, retries < 3,
> + allow_non_xm, &non_xm_print,
> baudrate, &baud_changed);
> if (rc)
> goto can;
> @@ -979,7 +985,8 @@ kwboot_xm_finish(int fd)
> if (rc)
> return rc;
>
> - rc = kwboot_xm_recv_reply(fd, &c, 0, NULL, 0, NULL);
> + rc = kwboot_xm_recv_reply(fd, &c, retries < 3,
> + 0, NULL, 0, NULL);
> if (rc)
> return rc;
> } while (c == NAK && retries++ < 16);
>

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