All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] How to random my mac in u-boot
@ 2010-02-08  5:47 Peter Pan
  2010-02-08  7:58 ` Wolfgang Denk
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Pan @ 2010-02-08  5:47 UTC (permalink / raw)
  To: u-boot

Recently, we had a issue that we need to start more than one board at
a time. The problem
we are facing is that every board is using the same u-boot, which
makes them all have the
same mac address.

Firstly, I think I can gives out a random MAC as we need, but I can
not find any rand() or srand()
function in U-Boot.

My U-Boot version is 2009.11 and my board is based on MPC8247.

Is there a chance that I can do this random job when U-Boot starts?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [U-Boot] How to random my mac in u-boot
  2010-02-08  5:47 [U-Boot] How to random my mac in u-boot Peter Pan
@ 2010-02-08  7:58 ` Wolfgang Denk
  2010-02-08 11:30   ` Peter Pan
  0 siblings, 1 reply; 9+ messages in thread
From: Wolfgang Denk @ 2010-02-08  7:58 UTC (permalink / raw)
  To: u-boot

Dear Peter Pan,

In message <48abf2c21002072147t7e67ba44i4298b39acc5d7380@mail.gmail.com> you wrote:
> Recently, we had a issue that we need to start more than one board at
> a time. The problem
> we are facing is that every board is using the same u-boot, which
> makes them all have the
> same mac address.

This means that you have a serious configuration problem in ypur
U-Boot port: the U-Boot binary should never contain any MAN accress at
all. I recommend to fix this now.

> Firstly, I think I can gives out a random MAC as we need, but I can
> not find any rand() or srand()
> function in U-Boot.

Instead of doing random things you should read the FAQ, especially
here:

http://www.denx.de/wiki/view/DULG/WhereCanIGetAValidMACAddress

> Is there a chance that I can do this random job when U-Boot starts?

You are not supposed to  do  that.  For  testing,  you  can  use  the
gen_eth_addr  program  in  the  tools/ directory to generate "locally
administered"  MAC  addresses,  but  these  are  NOT   suitable   for
productions boards.

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
Objects in mirror are closer than they appear.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [U-Boot] How to random my mac in u-boot
  2010-02-08  7:58 ` Wolfgang Denk
@ 2010-02-08 11:30   ` Peter Pan
  2010-02-08 12:27     ` Wolfgang Denk
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Pan @ 2010-02-08 11:30 UTC (permalink / raw)
  To: u-boot

I understand what your mean. But we need to setup the boards' information
including the MAC address through ethernet. With the same MAC address,
only one board can be configured at a time, which is not efficient enough.

Because of the quantity of the boards comparing with the number of workers,
we can not set the MAC address by hand. So what I means is to make the
u-boot generate a temporarily random local-administration MAC and get the
correct information later.

May I know how other set their boards' MAC address. Is there any trick to
do this job.

2010/2/8 Wolfgang Denk <wd@denx.de>:
> Dear Peter Pan,
>
> In message <48abf2c21002072147t7e67ba44i4298b39acc5d7380@mail.gmail.com> you wrote:
>> Recently, we had a issue that we need to start more than one board at
>> a time. The problem
>> we are facing is that every board is using the same u-boot, which
>> makes them all have the
>> same mac address.
>
> This means that you have a serious configuration problem in ypur
> U-Boot port: the U-Boot binary should never contain any MAN accress at
> all. I recommend to fix this now.
>
>> Firstly, I think I can gives out a random MAC as we need, but I can
>> not find any rand() or srand()
>> function in U-Boot.
>
> Instead of doing random things you should read the FAQ, especially
> here:
>
>
>http://www.denx.de/wiki/view/DULG/WhereCanIGetAValidMACAddress
>> Is there a chance that I can do this random job when U-Boot starts?
>
> You are not supposed to ?do ?that. ?For ?testing, ?you ?can ?use ?the
> gen_eth_addr ?program ?in ?the ?tools/ directory to generate "locally
> administered" ?MAC ?addresses, ?but ?these ?are ?NOT ? suitable ? for
> productions boards.
>
> 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
> Objects in mirror are closer than they appear.
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [U-Boot] How to random my mac in u-boot
  2010-02-08 11:30   ` Peter Pan
@ 2010-02-08 12:27     ` Wolfgang Denk
  2010-02-08 12:46       ` Peter Pan
  0 siblings, 1 reply; 9+ messages in thread
From: Wolfgang Denk @ 2010-02-08 12:27 UTC (permalink / raw)
  To: u-boot

Dear Peter Pan,

In message <48abf2c21002080330k285f07b2y8b55f978a28cd6f8@mail.gmail.com> you wrote:
> I understand what your mean. But we need to setup the boards' information
> including the MAC address through ethernet. With the same MAC address,
> only one board can be configured at a time, which is not efficient enough.

There are many ways to install a MAC into your hardware -without
hard-conding one into your image code.

> Because of the quantity of the boards comparing with the number of workers,
> we can not set the MAC address by hand. So what I means is to make the

Of course you cannot do that. Keep in mind that you are _required_
(and note that this is not an option, but a mandatory requirement) to
provide a unique (!) MAC address with each piece of your hardware.

> u-boot generate a temporarily random local-administration MAC and get the
> correct information later.

This is one option, but probably not a good one.

How would you then know which board was provided what MAC? Typically
you want to also put a sticker with the printed serial number, MAC
address etc. on your hardware, i. e. there is some interaction with
your production database needed, and you need to know exactly which
board has been assigned which addresses. This prevents using "random"
addresses.

> May I know how other set their boards' MAC address. Is there any trick to
> do this job.

There are many different ways to do that. Just to give you one
example: have a look at board/tqc/tqm8xx/load_sernum_ethaddr.c
In this case, during production (when the software gets installed to
flash), a special information block (containing among other things the
board's unique serial number and MAC address) gets programmed to a
special, otherwise unused location in flash. U-Boot will pick up the
information there and auto-initialize the respective variables.

I don't want to suggest that this is the optimal approach -  but it is
one of the working solutions.

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
Randal said it would be tough to do in sed. He didn't say  he  didn't
understand  sed.  Randal  understands sed quite well. Which is why he
uses Perl. :-)         - Larry Wall in <7874@jpl-devvax.JPL.NASA.GOV>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [U-Boot] How to random my mac in u-boot
  2010-02-08 12:27     ` Wolfgang Denk
@ 2010-02-08 12:46       ` Peter Pan
  2010-02-08 22:39         ` Aras Vaichas
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Pan @ 2010-02-08 12:46 UTC (permalink / raw)
  To: u-boot

Thank you very much. I will check their approach.

2010/2/8 Wolfgang Denk <wd@denx.de>:
> Dear Peter Pan,
>
> In message <48abf2c21002080330k285f07b2y8b55f978a28cd6f8@mail.gmail.com> you wrote:
>> I understand what your mean. But we need to setup the boards' information
>> including the MAC address through ethernet. With the same MAC address,
>> only one board can be configured at a time, which is not efficient enough.
>
> There are many ways to install a MAC into your hardware -without
> hard-conding one into your image code.
>
>> Because of the quantity of the boards comparing with the number of workers,
>> we can not set the MAC address by hand. So what I means is to make the
>
> Of course you cannot do that. Keep in mind that you are _required_
> (and note that this is not an option, but a mandatory requirement) to
> provide a unique (!) MAC address with each piece of your hardware.
>
>> u-boot generate a temporarily random local-administration MAC and get the
>> correct information later.
>
> This is one option, but probably not a good one.
>
> How would you then know which board was provided what MAC? Typically
> you want to also put a sticker with the printed serial number, MAC
> address etc. on your hardware, i. e. there is some interaction with
> your production database needed, and you need to know exactly which
> board has been assigned which addresses. This prevents using "random"
> addresses.
>
>> May I know how other set their boards' MAC address. Is there any trick to
>> do this job.
>
> There are many different ways to do that. Just to give you one
> example: have a look at board/tqc/tqm8xx/load_sernum_ethaddr.c
> In this case, during production (when the software gets installed to
> flash), a special information block (containing among other things the
> board's unique serial number and MAC address) gets programmed to a
> special, otherwise unused location in flash. U-Boot will pick up the
> information there and auto-initialize the respective variables.
>
> I don't want to suggest that this is the optimal approach - ?but it is
> one of the working solutions.
>
> 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
> Randal said it would be tough to do in sed. He didn't say ?he ?didn't
> understand ?sed. ?Randal ?understands sed quite well. Which is why he
> uses Perl. :-) ? ? ? ? - Larry Wall in <7874@jpl-devvax.JPL.NASA.GOV>
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [U-Boot] How to random my mac in u-boot
  2010-02-08 12:46       ` Peter Pan
@ 2010-02-08 22:39         ` Aras Vaichas
  2010-02-09  0:20           ` Peter Pan
  0 siblings, 1 reply; 9+ messages in thread
From: Aras Vaichas @ 2010-02-08 22:39 UTC (permalink / raw)
  To: u-boot

>> There are many ways to install a MAC into your hardware -without
>> hard-conding one into your image code.
>>
>>> Because of the quantity of the boards comparing with the number of workers,
>>> we can not set the MAC address by hand. So what I means is to make the

Our Linux devices all have an I2C EEPROM memory chip on board.

Once the production electrical/smoke test is complete, this memory
chip is programmed with SDRAM timings, SDRAM bus width, a unique MAC
address and a unique serial number for the board. We use an external
programming device to achieve this.

This way we have a log of every MAC address and the serial number of
the device to which it belongs.

The first stage bootloader reads the SDRAM timings from the EEPROM,
sets up the SDRAM, then copies U-Boot into SDRAM and then executes it.

U-Boot then reads the MAC address from the EEPROM and programs it into the PHY.

Aras

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [U-Boot] How to random my mac in u-boot
  2010-02-08 22:39         ` Aras Vaichas
@ 2010-02-09  0:20           ` Peter Pan
  2010-02-09  6:29             ` Wolfgang Denk
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Pan @ 2010-02-09  0:20 UTC (permalink / raw)
  To: u-boot

Thank you very much for your advice. That's a very nice approach.
We will try this in our next version.

2010/2/9 Aras Vaichas <arasv@magellan-technology.com>:
>>> There are many ways to install a MAC into your hardware -without
>>> hard-conding one into your image code.
>>>
>>>> Because of the quantity of the boards comparing with the number of workers,
>>>> we can not set the MAC address by hand. So what I means is to make the
>
> Our Linux devices all have an I2C EEPROM memory chip on board.
>
> Once the production electrical/smoke test is complete, this memory
> chip is programmed with SDRAM timings, SDRAM bus width, a unique MAC
> address and a unique serial number for the board. We use an external
> programming device to achieve this.
>
> This way we have a log of every MAC address and the serial number of
> the device to which it belongs.
>
> The first stage bootloader reads the SDRAM timings from the EEPROM,
> sets up the SDRAM, then copies U-Boot into SDRAM and then executes it.
>
> U-Boot then reads the MAC address from the EEPROM and programs it into the PHY.
>
> Aras
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [U-Boot] How to random my mac in u-boot
  2010-02-09  0:20           ` Peter Pan
@ 2010-02-09  6:29             ` Wolfgang Denk
  2010-02-18  2:48               ` Aras Vaichas
  0 siblings, 1 reply; 9+ messages in thread
From: Wolfgang Denk @ 2010-02-09  6:29 UTC (permalink / raw)
  To: u-boot

Dear Peter Pan,

please read http://www.netmeister.org/news/learn2quote.html

Do not top post / full quote.

In message <48abf2c21002081620j32c09d82qf61e55bc5426ef60@mail.gmail.com> you wrote:
> Thank you very much for your advice. That's a very nice approach.
> We will try this in our next version.
...
> > Our Linux devices all have an I2C EEPROM memory chip on board.

In this case make sure to provide hardware write protection for these
EEPROMs to prevent data loss through effects like described here:
doc/I2C_Edge_Conditions etc.


In general, such a solution is not needed at all. When you can
automate writes to an EEPROM, you can do the same for writes to flash
memory (which is what I pointed out in my posting refering to the
tqm8xx boards).

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
God runs electromagnetics by wave theory on  Monday,  Wednesday,  and
Friday,  and the Devil runs them by quantum theory on Tuesday, Thurs-
day, and Saturday.                                   -- William Bragg

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [U-Boot] How to random my mac in u-boot
  2010-02-09  6:29             ` Wolfgang Denk
@ 2010-02-18  2:48               ` Aras Vaichas
  0 siblings, 0 replies; 9+ messages in thread
From: Aras Vaichas @ 2010-02-18  2:48 UTC (permalink / raw)
  To: u-boot

On 9 February 2010 17:29, Wolfgang Denk <wd@denx.de> wrote:
> In general, such a solution is not needed at all. When you can
> automate writes to an EEPROM, you can do the same for writes to flash
> memory (which is what I pointed out in my posting refering to the
> tqm8xx boards).

True, but not for our case.

We put the same EEPROMs and an I2C bus on all sub-boards in our
products. These EEPROMs contain detailed version and build number
information about each board.

At startup the application scans the system for each EEPROM and builds
a configuration profile of everything in the system. This allows our
main application to load the correct FPGA image, configure GPIO ports,
etc.

The main requirement was to allow a technician, with minimal
equipment, to completely audit every board in our product
(e.g.retrieve the serial numbers for RMA and warranty purposes)
without cracking open the case.

Since the I2C bus can be powered externally, we don't need to power up
the system in order to read the memory device.  So it will still work
on a broken sub-board - assuming the I2C bus is still intact.

Aras

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-02-18  2:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-08  5:47 [U-Boot] How to random my mac in u-boot Peter Pan
2010-02-08  7:58 ` Wolfgang Denk
2010-02-08 11:30   ` Peter Pan
2010-02-08 12:27     ` Wolfgang Denk
2010-02-08 12:46       ` Peter Pan
2010-02-08 22:39         ` Aras Vaichas
2010-02-09  0:20           ` Peter Pan
2010-02-09  6:29             ` Wolfgang Denk
2010-02-18  2:48               ` Aras Vaichas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.