From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10762C433EF for ; Fri, 10 Sep 2021 20:50:25 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 77E4561205 for ; Fri, 10 Sep 2021 20:50:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 77E4561205 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A418383749; Fri, 10 Sep 2021 22:49:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="UfJZDF1T"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 74CAD8370E; Fri, 10 Sep 2021 22:48:50 +0200 (CEST) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3516D83720 for ; Fri, 10 Sep 2021 22:48:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id 587E0610C9; Fri, 10 Sep 2021 20:48:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631306894; bh=3bZsFlG8GDReByiwoSU/kNvFE7zMFsFODeaqFoku/Ok=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UfJZDF1Tbz81cbtJbQvUPtPgub/QqQhW6SJ4LbaVvkoz6bcZKg50m8yUZkZ6GbD9v vHa37dRG25zYjtSAVA3WEjNOml7s3JuYaoh/Zge7bOOrEjzwob2ZMF8ebrughAKRR4 yz3/9gRdM/xbZXNNr3MZRnth2jtDLj0ewdJxOHkZv1AiBkcJd/VGsZ6ZicWqbtFO5t AZeFrdgYJoxr9SAODZ2IF15LGS5bu21FCuKscqP4iupI1lU1UAI5IsG7yH14U2BU8j YiYYZNNSRYPMm8KcOQTaFzigq1VySGvadg4bndWTMyUm31naVlyplu9OaVhMplA0bZ ImrpK2yaQxYjA== Received: by pali.im (Postfix) id 1D3232828; Fri, 10 Sep 2021 22:48:14 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Simon Glass , Heinrich Schuchardt Cc: u-boot@lists.denx.de Subject: [PATCH 2/2] xyz-modem: Wait infinitely for initial x-modem packet Date: Fri, 10 Sep 2021 22:46:53 +0200 Message-Id: <20210910204653.3066-2-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210910204653.3066-1-pali@kernel.org> References: <20210910204653.3066-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean 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 --- 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