aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTushar Behera <tushar.behera@linaro.org>2013-02-05 10:34:56 +0530
committerTushar Behera <tushar.behera@linaro.org>2013-02-05 10:39:13 +0530
commitce520b570699ddfc741eebeb4d0ecb436124ec24 (patch)
tree52e0c683c4e745600e8dc7425f07698ebe508b3f
parent616ce94ce413a5122f8ffa26318a36226c9231e7 (diff)
downloadu-boot-linaro-stable-ce520b570699ddfc741eebeb4d0ecb436124ec24.tar.gz
cmd_bootm: Add support to append MAC address to bootargs
Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
-rw-r--r--common/cmd_bootm.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 717e9a821..7181634c2 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -579,6 +579,33 @@ static int do_bootm_subcommand(cmd_tbl_t *cmdtp, int flag, int argc,
return ret;
}
+#ifdef CONFIG_BOOTM_BOOTARGS_APPEND_MAC
+static void append_mac_addr()
+{
+ char *bootarg, *ethaddr;
+ size_t bootarg_len, ethaddr_len;
+
+ ethaddr = getenv("ethaddr");
+
+ if (!ethaddr)
+ ethaddr = getenv("usbethaddr");
+
+ if (!ethaddr)
+ return;
+
+ ethaddr_len = strlen(ethaddr);
+
+ bootarg_len = strlen(getenv("bootargs")) + ethaddr_len + 6;
+
+ bootarg = malloc(bootarg_len);
+ if (!bootarg)
+ return;
+
+ sprintf(bootarg, "%s mac=%s", getenv("bootargs"), ethaddr);
+ setenv("bootargs", bootarg);
+}
+#endif
+
/*******************************************************************/
/* bootm - boot application image from image in memory */
/*******************************************************************/
@@ -602,6 +629,9 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
}
#endif
+#ifdef CONFIG_BOOTM_BOOTARGS_APPEND_MAC
+ append_mac_addr();
+#endif
/* determine if we have a sub command */
if (argc > 1) {
char *endp;