From: wdenk Date: Fri, 23 Nov 2001 15:48:15 +0000 (+0000) Subject: * Fix problem with TFTP server in different subnet, or with X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=b08b085cbba89bed7047a1fe24bdd296f7c378c2;p=users%2Frw%2Fppcboot.git * 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/CHANGELOG b/CHANGELOG index 93f0e8f..6d7b918 100644 --- 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 b196597..c28db45 100644 --- 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 diff --git a/common/board.c b/common/board.c index 4aa73b3..cf155a7 100644 --- a/common/board.c +++ b/common/board.c @@ -40,9 +40,7 @@ #ifdef CONFIG_STATUS_LED #include #endif -#if (CONFIG_COMMANDS & CFG_CMD_NET) #include -#endif #if (CONFIG_COMMANDS & CFG_CMD_BEDBUG) #include #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 */ diff --git a/common/cmd_elf.c b/common/cmd_elf.c index 4f65b82..322d7c9 100644 --- a/common/cmd_elf.c +++ b/common/cmd_elf.c @@ -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 */ } diff --git a/include/net.h b/include/net.h index 068fd0f..81fa76f 100644 --- a/include/net.h +++ b/include/net.h @@ -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); diff --git a/net/arp.c b/net/arp.c index dcb512a..c36bda4 100644 --- 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); diff --git a/net/net.c b/net/net.c index b3943c3..b3e615f 100644 --- 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); +} diff --git a/net/tftp.c b/net/tftp.c index 4ee42f6..369647c 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -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) ; } } diff --git a/tools/Makefile b/tools/Makefile index 1541598..e157113 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -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