[U-Boot-Users] bootp resetting serverip

Tehn Yit Chin tehn-yit.chin at greyinnovation.com
Wed Nov 23 06:02:35 CET 2005

Hi all,

Our environment is such that the TFTP server is a different machine to 
the DHCP server. So when I use the bootp command, serverip is set to the 
ip address of the DHCP server. This will not as it will attempt to 
transfer the file from the DHCP server instead of the TFTP server.

To overcome this issue, I have modify the BootpCopyNetParams() to check 
if serverip is empty before copying. The patch is below and attached.

--- old_u-boot/net/bootp.c      2005-11-23 15:40:52.000000000 +1100
+++ u-boot/net/bootp.c  2005-11-23 15:26:52.000000000 +1100
@@ -121,8 +121,15 @@

         NetCopyIP(&NetOurIP, &bp->bp_yiaddr);
         NetCopyIP(&tmp_ip, &bp->bp_siaddr);
-       if (tmp_ip != 0)
-               NetCopyIP(&NetServerIP, &bp->bp_siaddr);
+       if (tmp_ip != 0) {
+               /* check that serverip is empty before setting the value as
+               ** the DHCP server could be a different machine.
+               */
+               if (getenv("serverip") == NULL) {
+                       NetCopyIP(&NetServerIP, &bp->bp_siaddr);
+               }
+       }
         memcpy (NetServerEther, ((Ethernet_t *)NetRxPkt)->et_src, 6);
         if (strlen(bp->bp_file) > 0)
                 copy_filename (BootFile, bp->bp_file, sizeof(BootFile));

So if serverip is not empty, u-boot will assume that you know the ip 
address of the server, and have set it explicitly.

Happy for rocks to be thrown if a different solution exits.

Tehn Yit Chin
Software Engineer, Grey Innovation Pty. Ltd.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch.1
Url: http://lists.denx.de/pipermail/u-boot/attachments/20051123/bf8ab7ab/attachment.txt 

More information about the U-Boot mailing list