From: "Pali Rohár" <pali@kernel.org>
To: "Simon Glass" <sjg@chromium.org>,
"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
"Michal Simek" <michal.simek@xilinx.com>,
"Marek Behún" <marek.behun@nic.cz>
Cc: u-boot@lists.denx.de
Subject: [PATCH 5/7] xyz-modem: Properly abort/terminate transfer on error
Date: Tue, 3 Aug 2021 16:28:42 +0200 [thread overview]
Message-ID: <20210803142844.19455-6-pali@kernel.org> (raw)
In-Reply-To: <20210803142844.19455-1-pali@kernel.org>
Transfer termination tries to instruct sender that transfer was terminated.
Print error message and indicates aborted transfer in return value.
Signed-off-by: Pali Rohár <pali@kernel.org>
---
cmd/load.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/cmd/load.c b/cmd/load.c
index fb8c191fb64f..1ed05a9cd21e 100644
--- a/cmd/load.c
+++ b/cmd/load.c
@@ -975,6 +975,7 @@ static ulong load_serial_ymodem(ulong offset, int mode)
res = xyzModem_stream_open(&info, &err);
if (!res) {
+ err = 0;
while ((res =
xyzModem_stream_read(ymodemBuf, 1024, &err)) > 0) {
store_addr = addr + offset;
@@ -987,6 +988,9 @@ static ulong load_serial_ymodem(ulong offset, int mode)
rc = flash_write((char *) ymodemBuf,
store_addr, res);
if (rc != 0) {
+ xyzModem_stream_terminate(true, &getcxmodem);
+ xyzModem_stream_close(&err);
+ printf("\n");
flash_perror(rc);
return (~0);
}
@@ -998,12 +1002,20 @@ static ulong load_serial_ymodem(ulong offset, int mode)
}
}
+ if (err) {
+ xyzModem_stream_terminate((err == xyzModem_cancel) ? false : true, &getcxmodem);
+ xyzModem_stream_close(&err);
+ printf("\n%s\n", xyzModem_error(err));
+ return (~0); /* Download aborted */
+ }
+
if (IS_ENABLED(CONFIG_CMD_BOOTEFI))
efi_set_bootdev("Uart", "", "",
map_sysmem(offset, 0), size);
} else {
- printf("%s\n", xyzModem_error(err));
+ printf("\n%s\n", xyzModem_error(err));
+ return (~0); /* Download aborted */
}
xyzModem_stream_terminate(false, &getcxmodem);
--
2.20.1
next prev parent reply other threads:[~2021-08-03 14:29 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-03 14:28 [PATCH 0/7] xyz-modem: Fix cancelling and closing transfers Pali Rohár
2021-08-03 14:28 ` [PATCH 1/7] xyz-modem: Fix crash after cancelling transfer Pali Rohár
2021-08-04 8:50 ` Heinrich Schuchardt
2021-09-03 21:29 ` Tom Rini
2021-08-03 14:28 ` [PATCH 2/7] xyz-modem: Fix x-modem "xyzModem_eof error" at the end of file Pali Rohár
2021-08-12 21:46 ` Simon Glass
2021-08-03 14:28 ` [PATCH 3/7] xyz-modem: Put xyzModem_stream_close debug diagnostic message into ZM_DEBUG() Pali Rohár
2021-08-04 9:30 ` Heinrich Schuchardt
2021-08-06 16:20 ` Pali Rohár
2021-08-03 14:28 ` [PATCH 4/7] xyz-modem: Close stream after processing/sending terminate sequence Pali Rohár
2021-08-04 8:59 ` Heinrich Schuchardt
2021-08-06 16:27 ` Pali Rohár
2021-08-03 14:28 ` Pali Rohár [this message]
2021-08-12 21:46 ` [PATCH 5/7] xyz-modem: Properly abort/terminate transfer on error Simon Glass
2021-08-12 21:48 ` Pali Rohár
2021-08-03 14:28 ` [PATCH 6/7] xyz-modem: Show information about finished transfer Pali Rohár
2021-08-04 9:15 ` Heinrich Schuchardt
2021-08-06 16:16 ` Pali Rohár
2021-08-03 14:28 ` [PATCH 7/7] xyz-modem: Allow to cancel transfer also by CTRL+C Pali Rohár
2021-08-12 21:46 ` Simon Glass
2021-08-27 8:40 ` [PATCH 0/7] xyz-modem: Fix cancelling and closing transfers Pali Rohár
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210803142844.19455-6-pali@kernel.org \
--to=pali@kernel.org \
--cc=marek.behun@nic.cz \
--cc=michal.simek@xilinx.com \
--cc=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox