]> www.infradead.org Git - users/rw/ppcboot.git/commitdiff
* Fix problem with TFTP server in different subnet, or with
authorwdenk <wdenk>
Fri, 23 Nov 2001 15:48:15 +0000 (15:48 +0000)
committerwdenk <wdenk>
Fri, 23 Nov 2001 15:48:15 +0000 (15:48 +0000)
  "gatewayip" set when not needed.
  Patch by Nye Liu, 21 Nov 2001

* Fix bug in I2C uCode-Patch Handling
  Patch by David Petersen, 19 Nov 2001

CHANGELOG
README
common/board.c
common/cmd_elf.c
include/net.h
net/arp.c
net/net.c
net/tftp.c
tools/Makefile

index 93f0e8f3ddd37545e12efb6b2c76843fee1b5d14..6d7b918c7e59045ff8b9c6e7b66a0b28f5106fc4 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -56,6 +56,10 @@ To do:
 Modifications for 1.1.1:
 ======================================================================
 
+* Fix problem with TFTP server in different subnet, or with
+  "gatewayip" set when not needed.
+  Patch by Nye Liu, 21 Nov 2001
+
 * Fix bug in I2C uCode-Patch Handling
   Patch by David Petersen, 19 Nov 2001
 
diff --git a/README b/README
index b1965972850eacf6b8fdfe59d8f56c8a7445bf73..c28db45d4c27a27c6cba20385a13c3cf6f59c654 100644 (file)
--- a/README
+++ b/README
@@ -964,7 +964,7 @@ Low Level (hardware related) configuration options:
                 memory controller and running certain initialization
                 sequences.
 
-               PPCBoot uses the followinbg memory types:
+               PPCBoot uses the following memory types:
                 - MPC8xx and MPC8260: IMMR (internal memory of the CPU)
                - MPC8240: data cache
 
@@ -1073,7 +1073,7 @@ configurations; the following names are supported:
     FPS850L_config        Sandpoint8240_config  sbc8260_config
     GENIETV_config        TQM823L_config       PIP405_config
 
-Note: for some board spacial configuration names may exist; check  if
+Note: for some board special configuration names may exist; check  if
       additional  information is available from the board vendor; for
       instance, the TQM8xxL systems run normally at 50 MHz and use  a
       SCC  for  10baseT  ethernet; there are also systems with 80 MHz
index 4aa73b31b7cc8307a205558ae6d631102e91c6ff..cf155a77d8bbd5afa3ed15bb208f6bab21576ee5 100644 (file)
@@ -40,9 +40,7 @@
 #ifdef CONFIG_STATUS_LED
 #include <status_led.h>
 #endif
-#if (CONFIG_COMMANDS & CFG_CMD_NET)
 #include <net.h>
-#endif
 #if (CONFIG_COMMANDS & CFG_CMD_BEDBUG)
 #include <cmd_bedbug.h>
 #endif
@@ -401,18 +399,6 @@ board_init_f (ulong bootflag)
 
     bd->bi_bootflags   = bootflag;       /* boot / reboot flag (for LynxOS)    */
 
-    /* IP Address */
-    bd->bi_ip_addr = 0;
-    i = getenv_r ("ipaddr", tmp, sizeof(tmp));
-    s = (i > 0) ? tmp : NULL;
-    for (reg=0; reg<4; ++reg) {
-       ulong val = s ? simple_strtoul(s, &e, 10) : 0;
-       bd->bi_ip_addr <<= 8;
-       bd->bi_ip_addr  |= (val & 0xFF);
-       if (s)
-               s = (*e) ? e+1 : e;
-    }
-
 #if defined(CONFIG_WATCHDOG)
     watchdog_reset ();
 #endif /* CONFIG_WATCHDOG */
@@ -633,6 +619,9 @@ void    board_init_r  (bd_t *bd, ulong dest_addr)
     bd->bi_flashoffset = 0;
 #endif
 
+    /* IP Address */
+    bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
+
 #if defined(CONFIG_WATCHDOG)
     watchdog_reset ();
 #endif /* CONFIG_WATCHDOG */
index 4f65b8291f1d4467c767c97d697d20ed83801510..322d7c9356d6e4eb25079c927c3db4df0b6085d5 100644 (file)
@@ -82,20 +82,16 @@ int do_bootvx( cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[] )
   /* Check the loadaddr variable.  If we don't know where the image is
      then we're done. */
   
-  if(( tmp = getenv( "loadaddr" )) != NULL )
-  {
+  if(( tmp = getenv( "loadaddr" )) != NULL ) {
     addr = simple_strtoul( tmp, NULL, 16 );
-  }
-  else
-  {
+  } else {
     printf( "No load address provided\n" );
     return 1;
   }
 
   /* Check to see if we need to tftp the image ourselves before starting */
   
-  if(( argc == 2 ) && ( strcmp( argv[ 1 ], "tftp" ) == 0 ))
-  {
+  if(( argc == 2 ) && ( strcmp( argv[ 1 ], "tftp" ) == 0 )) {
     if( NetLoop( bd, TFTP ) == 0 )
       return 1;
     printf( "Automatic boot of VxWorks image at address 0x%08lx ... \n",
@@ -131,43 +127,32 @@ int do_bootvx( cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[] )
   /* Check to see if the bootline is defined in the 'bootargs' parameter.
      If it is not defined, we may be able to construct the info */
   
-  if(( bootline = getenv( "bootargs" )) != NULL )
-  {
+  if(( bootline = getenv( "bootargs" )) != NULL ) {
     memcpy( (void *)bootaddr, bootline, MAX( strlen( bootline ), 255 ));
-  }
-  else
-  {
+  } else {
 #if defined(CONFIG_4xx)
     sprintf( build_buf, "ibmEmac(0,0)" );
 
-    if(( tmp = getenv( "hostname" )) != NULL )
-    {
+    if(( tmp = getenv( "hostname" )) != NULL ) {
       sprintf( &build_buf[ strlen( build_buf - 1 ) ], "host:%s ", tmp );
-    }
-    else
-    {
+    } else {
       sprintf( &build_buf[ strlen( build_buf - 1 ) ], ": " );
     }
 
-    if(( tmp = getenv( "ipaddr" )) != NULL )
-    {
+    if(( tmp = getenv( "ipaddr" )) != NULL ) {
       sprintf( &build_buf[ strlen( build_buf - 1 ) ], "e=%s ", tmp );
     }
     memcpy( (void *)bootaddr, build_buf, MAX( strlen( build_buf ), 255 ));
 #elif defined(CONFIG_IOP480)
     sprintf( build_buf, "dc(0,0)" );
 
-    if(( tmp = getenv( "hostname" )) != NULL )
-    {
+    if(( tmp = getenv( "hostname" )) != NULL ) {
       sprintf( &build_buf[ strlen( build_buf - 1 ) ], "host:%s ", tmp );
-    }
-    else
-    {
+    } else {
       sprintf( &build_buf[ strlen( build_buf - 1 ) ], ": " );
     }
 
-    if(( tmp = getenv( "ipaddr" )) != NULL )
-    {
+    if(( tmp = getenv( "ipaddr" )) != NULL ) {
       sprintf( &build_buf[ strlen( build_buf - 1 ) ], "e=%s ", tmp );
     }
     memcpy( (void *)bootaddr, build_buf, MAX( strlen( build_buf ), 255 ));
@@ -184,12 +169,9 @@ int do_bootvx( cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[] )
   /* If the data at the load address is an elf image, then treat it like
      an elf image.  Otherwise, assume that it is a binary image */
   
-  if( valid_elf_image( addr ))
-  {
+  if( valid_elf_image( addr )) {
     addr = load_elf_image( addr );
-  }
-  else
-  {
+  } else {
     printf( "## Not an ELF image, assuming binary\n" );
     /* leave addr as load_addr */
   }
index 068fd0faeba15fc8031eb2d4af5426d9af8d02ca..81fa76f968628ce3c496630af48d08bc6dac2b80 100644 (file)
@@ -272,9 +272,12 @@ extern void        NetReceive(volatile uchar *, int);
 /* Print an IP address on the console */
 extern void    print_IPaddr (IPaddr_t);
 
-/* Convert a IP address to a string */
+/* Convert an IP address to a string */
 extern void    ip_to_string (IPaddr_t x, char *s);
 
+/* read an IP address from a environment variable */
+extern IPaddr_t getenv_IPaddr (char *);
+
 /* copy a filename (allow for "..." notation, limit length) */
 extern void    copy_filename (uchar *dst, uchar *src, int size);
 
index dcb512af710dc5fa6e5255e57845c715e247d801..c36bda4c30c021f9c55afecceb652abb57f8d63f 100644 (file)
--- a/net/arp.c
+++ b/net/arp.c
@@ -85,9 +85,13 @@ ArpRequest (void)
        for (i=10; i<16; ++i) {
                arp->ar_data[i] = 0;                    /* dest ET addr = 0     */
        }
-       *(IPaddr_t *)(&arp->ar_data[16]) =              /* dest IP addr         */
-               (NetOurGatewayIP) ? NetOurGatewayIP     /* => Gateway           */
-                                 : NetServerIP;        /* => TFTP server       */
+
+       if((NetServerIP & NetOurSubnetMask) != (NetOurIP & NetOurSubnetMask)) {
+           *(IPaddr_t *)(&arp->ar_data[16]) = NetOurGatewayIP;
+       } else {
+           *(IPaddr_t *)(&arp->ar_data[16]) = NetServerIP;     
+       }
+
 
        NetSendPacket(NetTxPacket, ETHER_HDR_SIZE + ARP_HDR_SIZE);
 
index b3943c3c42d94bfb9bc2dbff6143da806d9a35e7..b3e615fbcf42b0356136829640182701a4d62ab9 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -118,9 +118,6 @@ static int net_check_prereq (proto_t protocol);
 int
 NetLoop(bd_t *bis, proto_t protocol)
 {
-       char    *s, *e;
-       ulong   reg;
-
        if (!NetTxPacket) {
                int     i;
 
@@ -149,15 +146,10 @@ restart:
         */
 
        if (protocol == TFTP) {                 /* TFTP */
-               NetOurIP = bis->bi_ip_addr;
-               NetServerIP = 0;
-               s = getenv ("serverip");
-               for (reg=0; reg<4; ++reg) {
-                       ulong val = s ? simple_strtoul(s, &e, 10) : 0;
-                       NetServerIP <<= 8;
-                       NetServerIP |= (val & 0xFF);
-                       if (s) s = (*e) ? e+1 : e;
-               }
+               NetOurIP        = bis->bi_ip_addr;
+               NetServerIP     = getenv_IPaddr ("serverip");
+               NetOurGatewayIP = getenv_IPaddr ("gatewayip");
+               NetOurSubnetMask= getenv_IPaddr ("netmask");
 
                if (net_check_prereq (protocol) != 0) {
                        return 0;
@@ -659,3 +651,23 @@ void print_IPaddr (IPaddr_t x)
 
     puts(tmp);
 }
+
+IPaddr_t getenv_IPaddr (char *var)
+{
+       IPaddr_t addr;
+       char *s, *e;
+       int i;
+
+       s = getenv (var);
+
+       for (addr=0, i=0; i<4; ++i) {
+               ulong val = s ? simple_strtoul(s, &e, 10) : 0;
+               addr <<= 8;
+               addr |= (val & 0xFF);
+               if (s) {
+                       s = (*e) ? e+1 : e;
+               }
+       }
+
+       return (addr);
+}
index 4ee42f67e2d67908ee179d6f929e35ac6387a77f..369647cbadab5f347d89d68d394e6f7f343b8262 100644 (file)
@@ -297,7 +297,7 @@ TftpStart (void)
            IPaddr_t ServerNet  = NetServerIP & NetOurSubnetMask;
 
            if (OurNet != ServerNet) {
-               puts ("; sending throught gateway ");
+               puts ("; sending through gateway ");
                print_IPaddr (NetOurGatewayIP) ;
            }
        }
index 1541598a9bd60f51dfb644b1144ff761ed22f19e..e157113e5d3d224b8ce2d9c0dde96a279bebc7fa 100644 (file)
@@ -25,7 +25,8 @@ include $(TOPDIR)/config.mk
 
 BINS   = img2srec mkimage envcrc gen_eth_addr bmp_logo
 
-OBJS   = img2srec.o mkimage.o crc32.o envcrc.o gen_eth_addr.o bmp_logo.o
+AOBJS  = environment.o
+COBJS  = img2srec.o mkimage.o crc32.o envcrc.o gen_eth_addr.o bmp_logo.o
 
 LOGO_H = $(TOPDIR)/include/bmp_logo.h
 
@@ -111,8 +112,8 @@ $(LOGO_H):  bmp_logo $(LOGO_BMP)
 
 #########################################################################
 
-.depend:       Makefile $(OBJS:.o=.c)
-               $(CC) -M $(CPPFLAGS) $(OBJS:.o=.c) > $@
+.depend:       Makefile $(COBJS:.o=.c) $(AOBJS:.o=.S)
+               $(CC) -M $(CPPFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
 
 sinclude .depend