cmd_bootm: Add support to append MAC address to bootargs
Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 717e9a8..7181634 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -579,6 +579,33 @@
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 @@
}
#endif
+#ifdef CONFIG_BOOTM_BOOTARGS_APPEND_MAC
+ append_mac_addr();
+#endif
/* determine if we have a sub command */
if (argc > 1) {
char *endp;