[U-boot:
V2012.04]
[Author: Bo Shen <voice.shen@gmail.com>]
In normal times, we use U-boot to download the Linux kernel through the network. Our usual practice is to manually set serverip and ipaddr, and then download the Linux kernel to the specified address through the tftpboot command, finally, run the bootm command to start the Linux kernel.
In fact, all of this can be achieved through the DHCP Command provided by U-boot. Add config_cmd_dhcp to the configure file. The specific implementation of this command is in <Common/cmd_net.c> and <net/Bootp. c>.
DHCP commands are used as follows:
DHCP
[Loadaddress] [[hostipaddr:] bootfilename]
For example, DHCP 0x20000000 192.168.1.10: uimage
Using this command, you do not need to set serverip, ipaddr, and gateway (if cross-network segment.
After DHCP successfully obtains the IP address from the DHCP server, it obtains the uimage file from 192.168.1.10 and TFTP.
However, you must note that the command fails to be executed if the DHCP server ack package contains bootfilename.
Serverip uses the IP address of the DHCP service, and bootfilename uses the command returned by the DHCP server.
Therefore, this is a bug. Refer to the following patch to solve this problem.
Http://article.gmane.org/gmane.comp.boot-loaders.u-boot/130743
------------------------------------------------------------------------------
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
------------------------------------------------------------------------------