aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2021-08-03 16:28:42 +0200
committerTom Rini <trini@konsulko.com>2021-09-03 14:32:41 -0400
commit081bd249d119ecad114fd2560974688d8a5ce059 (patch)
tree95e8da65003a4195953e10e5c93c7a4e1cca2dcb /cmd
parent1f26c49ea1d968ff59abe804af14314d5f5dc8de (diff)
downloadu-boot-081bd249d119ecad114fd2560974688d8a5ce059.zip
u-boot-081bd249d119ecad114fd2560974688d8a5ce059.tar.gz
u-boot-081bd249d119ecad114fd2560974688d8a5ce059.tar.bz2
xyz-modem: Properly abort/terminate transfer on error
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> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/load.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/cmd/load.c b/cmd/load.c
index e0c896b..549e563 100644
--- a/cmd/load.c
+++ b/cmd/load.c
@@ -978,6 +978,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;
@@ -990,6 +991,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);
}
@@ -1001,12 +1005,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);