From dddb05b892f093c4ad6766880190c7c154f0686f Mon Sep 17 00:00:00 2001
From: Federico Vaga <federico.vaga@gmail.com>
Date: Tue, 23 Oct 2012 01:44:59 +0200
Subject: [PATCH 7/8] barebox: add MAC addresses to environment

This patch add to default mac addresses to the barebox evironment. The
first MAC address (eth0.ethaddr) is the one to assign to the ethernet
port on board.
The second MAC address (macaddr) is the base for all switch ports

Signed-off-by: Federico Vaga <federico.vaga@gmail.com>
---
 common/environment.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/common/environment.c b/common/environment.c
index 9f4e098..5013c3a 100644
--- a/common/environment.c
+++ b/common/environment.c
@@ -384,6 +384,18 @@ int envfs_load(const char *filename, const char *dir, unsigned flags)
 	int envfd;
 	int ret = 0;
 	size_t size;
+#ifdef __BAREBOX__
+	char *mac_addr_1="02:34:56:78:9A:BC";
+	char *mac_addr_2="02:34:56:78:9A:00";
+#endif
+
+#ifdef __BAREBOX__
+	/* When the environment is correctly loaded, set the MAC address */
+	setenv("eth0.ethaddr", mac_addr_1);
+	export("eth0.ethaddr");
+	setenv("macaddr", mac_addr_2);
+	export("macaddr");
+#endif
 
 	envfd = open(filename, O_RDONLY);
 	if (envfd < 0) {
-- 
1.7.9.5

