[patch] remove 32 MByte limit for RedBoot/tftp download

jeroen dobbelaere jeroen.dobbelaere@acunia.com
Wed Jun 18 09:34:00 GMT 2003


Following patch allows you to download images bigger than 32 MByte with RedBoot, using tftp.
(well, only if the tftp server supports this ;) )

(patch against eCos V2.0)

--- ecos-tmp/packages/redboot/current/src/net/tftp_client.c	Wed Jun 18 10:43:19 2003
+++ ecos/packages/redboot/current/src/net/tftp_client.c	Wed Jun 18 10:54:17 2003
@@ -66,7 +66,7 @@
  static struct {
      bool open;
      int  total_timeouts;
-    unsigned short last_good_block;
+    unsigned long last_good_block;
      int  avail, actual_len;
      struct sockaddr_in local_addr, from_addr;
      char data[SEGSIZE+sizeof(struct tftphdr)];
@@ -167,7 +167,7 @@
              if (tftp_stream.last_good_block != 0) {
                  // Send out the ACK
                  hdr->th_opcode = htons(ACK);
-                hdr->th_block = htons(tftp_stream.last_good_block);
+                hdr->th_block = htons((cyg_uint16)(tftp_stream.last_good_block & 0xFFFF));
                  if (__udp_sendto(tftp_stream.data, 4 /* FIXME */,
                                   &tftp_stream.from_addr, &tftp_stream.local_addr) < 0) {
                      // Problem sending ACK
@@ -193,7 +193,7 @@
                  }
              } else {
                  if (ntohs(hdr->th_opcode) == DATA) {
-                    if (ntohs(hdr->th_block) == (tftp_stream.last_good_block+1)) {
+                    if ((cyg_uint16) (ntohs(hdr->th_block)) == (cyg_uint16)((tftp_stream.last_good_block+1) & 0xFFFF)) {
                          // Consume this data
                          data_len -= 4;  /* Sizeof TFTP header */
                          tftp_stream.avail = tftp_stream.actual_len = data_len;

-- 
Jeroen Dobbelaere
Embedded Software Engineer

ACUNIA Embedded Solutions
http://www.acunia.com/aes




More information about the Ecos-patches mailing list