Skip to contentSkip to conversation

loadb: Properly indicate aborted kermit transfer

PATCH In review Pali Rohár 3 participants 5 messages Aug 6, 2021 – Sep 2, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 loadb: Properly indicate aborted kermit transfer

When k_recv() returns zero it indicates that kermit transfer was aborted. Function do_load_serial_bin() (caller of load_serial_bin()) interprets value ~0 as aborted transfer, so properly propagates information about aborted transfer from k_recv() to do_load_serial_bin().

---
 cmd/load.c | 3 +++
 1 file changed, 3 insertions(+)
cmd/load.c +3 -0
index 462340ad2cde..249ebd4ae078 100644
@@ -551,6 +551,9 @@ static ulong load_serial_bin(ulong offset)
 		udelay(1000);
 	}
 
+	if (size == 0)
+		return ~0; /* Download aborted */
+
 	flush_cache(offset, size);
 
 	printf("## Total Size      = 0x%08x = %d Bytes\n", size, size);
Signature · 1 line
2.20.1
#1 lore raw
Quoted 15 lines · Pali Rohár

When k_recv() returns zero it indicates that kermit transfer was aborted. Function do_load_serial_bin() (caller of load_serial_bin()) interprets value ~0 as aborted transfer, so properly propagates information about aborted transfer from k_recv() to do_load_serial_bin().

---
  cmd/load.c | 3 +++
  1 file changed, 3 insertions(+)
cmd/load.c +0 -0
index 462340ad2cde..249ebd4ae078 100644

cmd/load.c static ulong load_serial_bin(ulong offset) · line 556

Quoted 6 lines
cmd/load.c +3 -0
@@ -551,6 +551,9 @@ static ulong load_serial_bin(ulong offset)
  		udelay(1000);
  	}
 
+	if (size == 0)
+		return ~0; /* Download aborted */
+

I cannot see where k_recv() sets the return value to 0 if the download is interrupted after transferring the first packages. So isn't some logic in k_recv() missing to identify an abort?

Best regards

Heinrich

Quoted 4 lines
cmd/load.c +0 -0
  	flush_cache(offset, size);
 
  	printf("## Total Size      = 0x%08x = %d Bytes\n", size, size);
#2 lore raw
Quoted 19 lines · On Friday 06 August 2021 18:23:49 Heinrich Schuchardt wrote:
Quoted 18 lines · Pali Rohár

When k_recv() returns zero it indicates that kermit transfer was aborted. Function do_load_serial_bin() (caller of load_serial_bin()) interprets value ~0 as aborted transfer, so properly propagates information about aborted transfer from k_recv() to do_load_serial_bin().

---
  cmd/load.c | 3 +++
  1 file changed, 3 insertions(+)
cmd/load.c +0 -0
index 462340ad2cde..249ebd4ae078 100644
@@ -551,6 +551,9 @@ static ulong load_serial_bin(ulong offset)
  		udelay(1000);
  	}
 
Quoted 6 lines

cmd/load.c static ulong load_serial_bin(ulong offset) · line 556

Quoted 3 lines
cmd/load.c +3 -0
+	if (size == 0)
+		return ~0; /* Download aborted */
+

I cannot see where k_recv() sets the return value to 0 if the download is interrupted after transferring the first packages.

I must admit that I have not decoded whole kermit protocol. But by testing show that ETX (CTRL+C) is transferred when I abort kermit upload. And this ETX is handled in switch(getchar()) where is return 0; and also after sending more kermit packets (not only at beginning).

Quoted 1 line

So isn't some logic in k_recv() missing to identify an abort?

This is a good question. I would guess that "yes". But to answer it I need to fully decode kermit protocol...

But at least at this one place it really returns zero on aborted file transfer.

Quoted 8 lines

Best regards

Heinrich

Quoted 4 lines
cmd/load.c +0 -0
  	flush_cache(offset, size);
 
  	printf("## Total Size      = 0x%08x = %d Bytes\n", size, size);
#3 lore raw
Quoted 27 lines · On Friday 06 August 2021 18:37:15 Pali Rohár wrote:
Quoted 19 lines · On Friday 06 August 2021 18:23:49 Heinrich Schuchardt wrote:
Quoted 18 lines · Pali Rohár

When k_recv() returns zero it indicates that kermit transfer was aborted. Function do_load_serial_bin() (caller of load_serial_bin()) interprets value ~0 as aborted transfer, so properly propagates information about aborted transfer from k_recv() to do_load_serial_bin().

---
  cmd/load.c | 3 +++
  1 file changed, 3 insertions(+)
cmd/load.c +0 -0
index 462340ad2cde..249ebd4ae078 100644
@@ -551,6 +551,9 @@ static ulong load_serial_bin(ulong offset)
  		udelay(1000);
  	}
 
Quoted 6 lines

cmd/load.c static ulong load_serial_bin(ulong offset) · line 556

Quoted 3 lines
cmd/load.c +3 -0
+	if (size == 0)
+		return ~0; /* Download aborted */
+

I cannot see where k_recv() sets the return value to 0 if the download is interrupted after transferring the first packages.

Quoted 4 lines

I must admit that I have not decoded whole kermit protocol. But by testing show that ETX (CTRL+C) is transferred when I abort kermit upload. And this ETX is handled in switch(getchar()) where is return 0; and also after sending more kermit packets (not only at beginning).

So in any case, this patch fixes handling of kermit termination by pressing CTRL+C key. Simple test is to run 'loadb' and then press CTRL+C. Other option for testing is to run 'loadb' then start kermit transfer by ckermit, terminate ckermit transfer and then press CTRL+C. And this patch fixes also handling of this scenario.

Quoted 16 lines
Quoted 1 line

So isn't some logic in k_recv() missing to identify an abort?

This is a good question. I would guess that "yes". But to answer it I need to fully decode kermit protocol...

But at least at this one place it really returns zero on aborted file transfer.

Quoted 8 lines

Best regards

Heinrich

Quoted 4 lines
cmd/load.c +0 -0
  	flush_cache(offset, size);
 
  	printf("## Total Size      = 0x%08x = %d Bytes\n", size, size);
#4 lore raw
In reply to Pali Rohár
Quoted 6 lines · Pali Rohár

When k_recv() returns zero it indicates that kermit transfer was aborted. Function do_load_serial_bin() (caller of load_serial_bin()) interprets value ~0 as aborted transfer, so properly propagates information about aborted transfer from k_recv() to do_load_serial_bin().

Applied to u-boot/next, thanks!

Signature · 1 line
Tom