[U-Boot] [PATCH] DHCP: fix dhcp command parameters overwrite issue

Bo Shen voice.shen at gmail.com
Thu May 3 11:21:55 CEST 2012


when using dhcp command with parameters as usage message,
if DHCP server response contains bootfilename, it will overwrite
the dhcp command parameters. So the dhcp command parameters
can not be used.
 
Using this patch to fix it.

Signed-off-by: Bo Shen <voice.shen at gmail.com>
---
 common/cmd_net.c |    1 +
 net/bootp.c      |    3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/cmd_net.c b/common/cmd_net.c
index 65f32bc..9b1e650 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -221,6 +221,7 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc,
 
 	case 3:	load_addr = simple_strtoul(argv[1], NULL, 16);
 		copy_filename (BootFile, argv[2], sizeof(BootFile));
+		setenv ("bootfile", BootFile);
 
 		break;
 
diff --git a/net/bootp.c b/net/bootp.c
index 9e32476..df9f5eb 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -116,7 +116,8 @@ static void BootpCopyNetParams(Bootp_t *bp)
 	memcpy (NetServerEther, ((Ethernet_t *)NetRxPacket)->et_src, 6);
 #endif
 	if (strlen(bp->bp_file) > 0)
-		copy_filename (BootFile, bp->bp_file, sizeof(BootFile));
+		if (!getenv("bootfile"))
+			copy_filename (BootFile, bp->bp_file, sizeof(BootFile));
 
 	debug("Bootfile: %s\n", BootFile);
 
-- 
1.7.9.5



More information about the U-Boot mailing list