Skip to contentSkip to conversation

loadb and loady do not work

PATCH In review Alexey Galakhov 3 participants 4 messages May 13, 2011 – May 16, 2011

lore
Share & tools
lore
#0 lore raw

Hi,

I just switched from u-boot to barebox on a MINI2440 board and found that I'm unable to use both loadb and loady. I used loady with u-boot and it worked fine. Looks like barebox does not listen to the incoming data.

mini2440:/ loady -c
## Ready for binary (ymodem) download to 0x00000000 offset on image.bin device at 115200 bps...
C
*** file: uImage
sb -vv uImage
Sending: uImage
Ymodem sectors/kbytes sent: 0/ 0kRetry 0: NAK on sector
Retry 0: NAK on sector
Retry 0: NAK on sector
Retry 0: NAK on sector
(etc up to timeout)

mini2440:/ loadb -c
## Ready for binary (kermit) download to 0x00000000 offset on image.bin device at 115200 bps...

*** file: uImage
gkermit -iXvs uImage
G-Kermit CU-1.00, Columbia University, 1999-12-25 Escape back to your local Kermit and give a RECEIVE command.

KERMIT READY TO SEND...
-
*** exit status: 1

I tried to debug it by adding a simple echo test and I think I found the problem. tstc() may return false even if there are bytes in input buffer. Thus getc() may sleep even if the buffer is full!

--
Alex

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#1 lore raw

PATCH 1/1 fix console fifo (and loadb/loady commands)

This patch fixes loadb and loady commands. tstc() should return true if console_input_buffer is not empty.

common/console.c 2011-05-13 19:42:12.000000000 +0600 renamed from common/console.c.orig 2011-05-06 13:30:20.000000000 +0600 +16 -11
diff -udp ./common/console.c.orig ./common/console.c
@@ -195,6 +195,20 @@ static int getc_raw(void)
     }
 }
 
+static int tstc_raw(void)
+{
+    struct console_device *cdev;
+
+    for_each_console(cdev) {
+        if (!(cdev->f_active & CONSOLE_STDIN))
+            continue;
+        if (cdev->tstc(cdev))
+            return 1;
+    }
+
+    return 0;
+}
+
 int getc(void)
 {
     unsigned char ch;
@@ -209,7 +223,7 @@ int getc(void)
     while (1) {
         poller_call();
 
-        if (tstc()) {
+        if (tstc_raw()) {
             kfifo_putc(console_input_buffer, getc_raw());
 
             start = get_time_ns();
@@ -236,16 +250,7 @@ EXPORT_SYMBOL(fgetc);
 
 int tstc(void)
 {
-    struct console_device *cdev;
-
-    for_each_console(cdev) {
-        if (!(cdev->f_active & CONSOLE_STDIN))
-            continue;
-        if (cdev->tstc(cdev))
-            return 1;
-    }
-
-    return 0;
+    return kfifo_len(console_input_buffer) || tstc_raw();
 }
 EXPORT_SYMBOL(tstc);
 

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#2 lore raw

Re: [PATCH] fix console fifo (and loadb/loady commands)

Hi Alexey,

Quoted 2 lines · Alexey Galakhov

This patch fixes loadb and loady commands. tstc() should return true if console_input_buffer is not empty.

The patch is fine, thanks.

Your mailer converts tabs into whitespaces. Also you forgot to add a signed-off-by to your patch. I fixed this up manually this time.

Sascha

Quoted 59 lines

diff -udp ./common/console.c.orig ./common/console.c

common/console.c 2011-05-13 19:42:12.000000000 +0600 renamed from common/console.c.orig 2011-05-06 13:30:20.000000000 +0600 +16 -11
@@ -195,6 +195,20 @@ static int getc_raw(void)
     }
 }
 
+static int tstc_raw(void)
+{
+    struct console_device *cdev;
+
+    for_each_console(cdev) {
+        if (!(cdev->f_active & CONSOLE_STDIN))
+            continue;
+        if (cdev->tstc(cdev))
+            return 1;
+    }
+
+    return 0;
+}
+
 int getc(void)
 {
     unsigned char ch;
@@ -209,7 +223,7 @@ int getc(void)
     while (1) {
         poller_call();
 
-        if (tstc()) {
+        if (tstc_raw()) {
             kfifo_putc(console_input_buffer, getc_raw());
 
             start = get_time_ns();
@@ -236,16 +250,7 @@ EXPORT_SYMBOL(fgetc);
 
 int tstc(void)
 {
-    struct console_device *cdev;
-
-    for_each_console(cdev) {
-        if (!(cdev->f_active & CONSOLE_STDIN))
-            continue;
-        if (cdev->tstc(cdev))
-            return 1;
-    }
-
-    return 0;
+    return kfifo_len(console_input_buffer) || tstc_raw();
 }
 EXPORT_SYMBOL(tstc);
 

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

Re: [PATCH] fix console fifo (and loadb/loady commands)

Quoted 11 lines · Sascha Hauer

Hi Alexey,

Quoted 2 lines · Alexey Galakhov

This patch fixes loadb and loady commands. tstc() should return true if console_input_buffer is not empty.

The patch is fine, thanks.

Your mailer converts tabs into whitespaces. Also you forgot to add a signed-off-by to your patch. I fixed this up manually this time.

Sascha

Thank you! I'll check my mailer.

I'm preparing some more patches: s3c framebuffer support (originally written by Juergen Beisert but broken and outdated), mini2440 framebuffer support and JPEG image decoding (takes about 20kB of space by itself but reduces overall size significantly due to smaller image files).

--
Alex

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox