summaryrefslogtreecommitdiff
path: root/common/cmd_pxe.c
diff options
context:
space:
mode:
authorRob Herring <rob.herring@calxeda.com>2012-12-02 21:00:20 -0600
committerJoe Hershberger <joe.hershberger@ni.com>2013-06-24 19:07:32 -0500
commitef034c9d7069f19f9424c98beb9ca2ec027fb18b (patch)
treee8052d1de1e6a9f10d33fd7d19eecd31532f881b /common/cmd_pxe.c
parent0fae25089d9e3303e952a4227bd2c1edccabfa20 (diff)
downloadu-boot-imx-ef034c9d7069f19f9424c98beb9ca2ec027fb18b.zip
u-boot-imx-ef034c9d7069f19f9424c98beb9ca2ec027fb18b.tar.gz
u-boot-imx-ef034c9d7069f19f9424c98beb9ca2ec027fb18b.tar.bz2
pxe: Use ethact setting for pxe
Get the MAC address using eth_getenv_enetaddr_by_index so that the MAC address of ethact is used. This enables using the a NIC other than the first one for PXE boot. Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Diffstat (limited to 'common/cmd_pxe.c')
-rw-r--r--common/cmd_pxe.c34
1 files changed, 9 insertions, 25 deletions
diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c
index 2dbd49c..f785c0e 100644
--- a/common/cmd_pxe.c
+++ b/common/cmd_pxe.c
@@ -55,37 +55,21 @@ static char *from_env(char *envvar)
*/
static int format_mac_pxe(char *outbuf, size_t outbuf_len)
{
- size_t ethaddr_len;
- char *p, *ethaddr;
+ uchar ethaddr[6];
- ethaddr = from_env("ethaddr");
-
- if (!ethaddr)
- return -ENOENT;
-
- ethaddr_len = strlen(ethaddr);
-
- /*
- * ethaddr_len + 4 gives room for "01-", ethaddr, and a NUL byte at
- * the end.
- */
- if (outbuf_len < ethaddr_len + 4) {
- printf("outbuf is too small (%d < %d)\n",
- outbuf_len, ethaddr_len + 4);
+ if (outbuf_len < 21) {
+ printf("outbuf is too small (%d < 21)\n", outbuf_len);
return -EINVAL;
}
- strcpy(outbuf, "01-");
-
- for (p = outbuf + 3; *ethaddr; ethaddr++, p++) {
- if (*ethaddr == ':')
- *p = '-';
- else
- *p = tolower(*ethaddr);
- }
+ if (!eth_getenv_enetaddr_by_index("eth", eth_get_dev_index(),
+ ethaddr))
+ return -ENOENT;
- *p = '\0';
+ sprintf(outbuf, "01-%02x-%02x-%02x-%02x-%02x-%02x",
+ ethaddr[0], ethaddr[1], ethaddr[2],
+ ethaddr[3], ethaddr[4], ethaddr[5]);
return 1;
}