From: Wolfgang Denk Date: Tue, 08 Jan 2013 18:39:47 +0100 Subject: [U-Boot] [PATCH 2/2] calimain: Generate random MAC address for factory tests In-Reply-To: <6cc4810c-1e2e-4ebf-912a-96936f035c0e@mary.at.omicron.at> References: <1357653279-29635-1-git-send-email-christian.riesch@omicron.at> <6cc4810c-1e2e-4ebf-912a-96936f035c0e@mary.at.omicron.at> Message-ID: <20130108173947.5B123202B69@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Christian Riesch, In message <6cc4810c-1e2e-4ebf-912a-96936f035c0e@mary.at.omicron.at> you wrote: > Signed-off-by: Christian Riesch > --- > 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); > +} Note that your "uninitialized" SRAM content is probably not so much random at all - I guess, it is much less random than the originally used timer value. What exactly is your justification for such a change? Please elucidate... > +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; > +} NAK! You are but duplicating the code already present in net/eth.c This makes no sense. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de It is dangerous to be right on a subject on which the established authorities are wrong. -- Voltaire