"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
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
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
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
#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
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 */
bd->bi_flashoffset = 0;
#endif
+ /* IP Address */
+ bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
+
#if defined(CONFIG_WATCHDOG)
watchdog_reset ();
#endif /* CONFIG_WATCHDOG */
/* 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",
/* 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 ));
/* 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 */
}
/* 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);
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);
int
NetLoop(bd_t *bis, proto_t protocol)
{
- char *s, *e;
- ulong reg;
-
if (!NetTxPacket) {
int i;
*/
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;
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);
+}
IPaddr_t ServerNet = NetServerIP & NetOurSubnetMask;
if (OurNet != ServerNet) {
- puts ("; sending throught gateway ");
+ puts ("; sending through gateway ");
print_IPaddr (NetOurGatewayIP) ;
}
}
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
#########################################################################
-.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