[U-Boot] [PATCH 2/2] calimain: Generate random MAC address for factory tests
Christian Riesch
christian.riesch at omicron.at
Tue Jan 8 14:54:39 CET 2013
Signed-off-by: Christian Riesch <christian.riesch at omicron.at>
---
board/omicron/calimain/calimain.c | 31 ++++++++++++++++++++++++++++++-
include/configs/calimain.h | 2 ++
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/board/omicron/calimain/calimain.c b/board/omicron/calimain/calimain.c
index 1060a1f..80e3893 100644
--- a/board/omicron/calimain/calimain.c
+++ b/board/omicron/calimain/calimain.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 OMICRON electronics GmbH
+ * Copyright (C) 2011-2013 OMICRON electronics GmbH
*
* Based on da850evm.c. Original Copyrights follow:
*
@@ -136,6 +136,35 @@ int board_init(void)
return 0;
}
+/* seed random number generator with uninitialized SRAM content */
+static void srand_sram(void)
+{
+ int *p;
+ int seed = 0;
+
+ for (p = (int *) 0x80000000; p < (int *) 0x8001ffff; p++)
+ seed ^= *p;
+
+ srand(seed);
+}
+
+int board_late_init(void)
+{
+ uchar enetaddr[6];
+
+ if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+ srand_sram();
+ eth_random_enetaddr(enetaddr);
+ if (eth_setenv_enetaddr("ethaddr", enetaddr)) {
+ printf("Failed to set random ethernet address\n");
+ } else {
+ printf("Setting random ethernet address %pM.\n",
+ enetaddr);
+ }
+ }
+ return 0;
+}
+
#ifdef CONFIG_DRIVER_TI_EMAC
/*
* Initializes on-board ethernet controllers.
diff --git a/include/configs/calimain.h b/include/configs/calimain.h
index 5c2b35d..8cea0d9 100644
--- a/include/configs/calimain.h
+++ b/include/configs/calimain.h
@@ -30,6 +30,7 @@
#define CONFIG_DRIVER_TI_EMAC
#define MACH_TYPE_CALIMAIN 3528
#define CONFIG_MACH_TYPE MACH_TYPE_CALIMAIN
+#define CONFIG_BOARD_LATE_INIT
/*
* SoC Configuration
@@ -202,6 +203,7 @@
#define CONFIG_BOOTP_DNS2
#define CONFIG_BOOTP_SEND_HOSTNAME
#define CONFIG_NET_RETRY_COUNT 10
+#define CONFIG_RANDOM_MACADDR
#endif
/*
--
1.7.9.5
More information about the U-Boot
mailing list