tools: kwboot: Improve retrying logic for incomplete xmodem packets
authorPali Rohár <pali@kernel.org>
Tue, 25 Jan 2022 17:13:02 +0000 (18:13 +0100)
committerStefan Roese <sr@denx.de>
Mon, 31 Jan 2022 09:23:38 +0000 (10:23 +0100)
commit82a9e13a9bbedb4ca3b0206619e2e46d764888fd
treeae41ab3ae33acdd9c4c9f57eea65f965c0e536c6
parent8bd15fd1146e13bba4b6d0166e5db4ce10ecf59d
tools: kwboot: Improve retrying logic for incomplete xmodem packets

Sometimes if the first byte of xmodem packet (SOH) is incorrectly
transmitted, BootROM sends NAK for every non-SOH received byte, which
makes BootROM and the host kwboot tool out of sync. BootROM automatically
re-synchronizes after 2s pause by dropping its input queue. So when
attempting retransmit for 9th time or later, ignore NAK reply from BootROM
and either wait for valid ACK or let kwboot timeout, which implies
re-synchronization.

This fixes retransmission of xmodem packets and allows kwboot to work also
without "Waiting ... and flushing tty" code which is at the beginning of
kwboot xmodem transfer.

Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
tools/kwboot.c