[PATCH 2/2] xyz-modem: Wait infinitely for initial x-modem packet
Pali Rohár
pali at kernel.org
Fri Sep 10 22:46:53 CEST 2021
Implement same thing also for x-modem protocol. As x-modem protocol does
not have header packet, first packet is directly first data packet.
Signed-off-by: Pali Rohár <pali at kernel.org>
---
common/xyzModem.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/common/xyzModem.c b/common/xyzModem.c
index d6be489a174b..39b40071a13b 100644
--- a/common/xyzModem.c
+++ b/common/xyzModem.c
@@ -50,6 +50,7 @@ static struct
int len, mode, total_retries;
int total_SOH, total_STX, total_CAN;
bool crc_mode, at_eof, tx_ack;
+ bool first_xmodem_packet;
unsigned long file_length, read_length;
} xyz;
@@ -439,12 +440,14 @@ xyzModem_stream_open (connection_info_t * info, int *err)
xyz.total_CAN = 0;
xyz.read_length = 0;
xyz.file_length = 0;
+ xyz.first_xmodem_packet = false;
CYGACC_COMM_IF_PUTC (*xyz.__chan, (xyz.crc_mode ? 'C' : NAK));
if (xyz.mode == xyzModem_xmodem)
{
/* X-modem doesn't have an information header - exit here */
+ xyz.first_xmodem_packet = true;
xyz.next_blk = 1;
return 0;
}
@@ -512,6 +515,8 @@ xyzModem_stream_read (char *buf, int size, int *err)
stat = xyzModem_get_hdr ();
if (stat == 0)
{
+ if (xyz.mode == xyzModem_xmodem && xyz.first_xmodem_packet)
+ xyz.first_xmodem_packet = false;
if (xyz.blk == xyz.next_blk)
{
xyz.tx_ack = true;
@@ -589,7 +594,7 @@ xyzModem_stream_read (char *buf, int size, int *err)
xyz.total_retries++;
ZM_DEBUG (zm_dprintf ("NAK (%d)\n", __LINE__));
}
- if (stat < 0)
+ if (stat < 0 && (!xyz.first_xmodem_packet || stat != xyzModem_timeout))
{
*err = stat;
xyz.len = -1;
--
2.20.1
More information about the U-Boot
mailing list