This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RedBoot: Use Ymodem's length field and don't eat ^Zs.


Hi,

This RedBoot patch enables the use of Ymodem's length field and causes
^Z's to be discarded only when Xmodem is used or the Ymodem length field
is 0.

Without this patch, binary files containing runs of ^Z's would be
corrupted when transferred.  (Causing much head-scratching when a file
consistantly ends up short.)

David Vrabel
-- 
David Vrabel, Design Engineer

Arcom, Clifton Road           Tel: +44 (0)1223 411200 ext. 3233
Cambridge CB1 7EA, UK         Web: http://www.arcom.com/
%status
pending
%patch
Index: ecos-working/packages/redboot/current/src/xyzModem.c
===================================================================
--- ecos-working.orig/packages/redboot/current/src/xyzModem.c	2005-06-09 17:24:59.000000000 +0100
+++ ecos-working/packages/redboot/current/src/xyzModem.c	2005-06-09 17:25:33.000000000 +0100
@@ -68,7 +68,7 @@
 #define CAN 0x18
 #define EOF 0x1A  // ^Z for DOS officionados
 
-#define nUSE_YMODEM_LENGTH
+#define USE_YMODEM_LENGTH
 
 // Data & state local to the protocol
 static struct {
@@ -416,13 +416,14 @@
                         xyz.tx_ack = true;
                         ZM_DEBUG(zm_dprintf("ACK block %d (%d)\n", xyz.blk, __LINE__));
                         xyz.next_blk = (xyz.next_blk + 1) & 0xFF;
-                        // Data blocks can be padded with ^Z (EOF) characters
-                        // This code tries to detect and remove them
-#ifdef xyzModem_zmodem
-                        if (xyz.mode != xyzModem_zmodem) {
+
+#if defined(xyzModem_zmodem) || defined(USE_YMODEM_LENGTH)
+                        if (xyz.mode == xyzModem_xmodem || xyz.file_length == 0) {
 #else
                         if (1) {
 #endif
+                            // Data blocks can be padded with ^Z (EOF) characters
+                            // This code tries to detect and remove them
                             if ((xyz.bufp[xyz.len-1] == EOF) &&
                                 (xyz.bufp[xyz.len-2] == EOF) &&
                                 (xyz.bufp[xyz.len-3] == EOF)) {
Index: ecos-working/packages/redboot/current/ChangeLog
===================================================================
--- ecos-working.orig/packages/redboot/current/ChangeLog	2005-05-31 14:45:19.000000000 +0100
+++ ecos-working/packages/redboot/current/ChangeLog	2005-06-09 17:29:44.000000000 +0100
@@ -1,3 +1,11 @@
+2005-06-09  David Vrabel  <dvrabel@arcom.com>
+
+	* src/xyzModem.c: Use the Ymodem length field by #define'ing
+	USE_YMODEM_LENGTH.
+	(xyzModem_stream_read): Only discard runs of ^Z's if we're using
+	Xmodem or the Ymodem length field is 0.  This allows binary files
+	with runs of ^Z's to be transferred.
+
 2005-05-27  David Vrabel  <dvrabel@arcom.com>
 
 	* src/main.c (cyg_start): Expand aliases even if

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]