[U-Boot] Generating random numbers

Wolfgang Denk wd at denx.de
Wed Aug 31 21:15:53 CEST 2011


Dear "elison.niven at gmail.com",

In message <CAAO=tycSJgHWdUvYrH5zecHM6L6F4KPeC8qyu8_PzZaCibN7Bw at mail.gmail.com> you wrote:
>
> How am I supposed to set the real MAC in the environment? Build
> separate images for each board? I do not want that.

Not that is finally a good question, and one where answering makes
sense again.

There are many ways, depending on how you organized the production
and/or testing of your boards.

If either of these steps includes to actually boot up U-Boot (for
example, to run some production test software etc.), then it is
usually tricial to use plain standard "env set" + "env save" commands
to set and store the MAC address - and probably the serial number
and/or other vital product data as well.

If you use any specific means to set the serial number of your board
(for example, but using a Silicon Serial Number chip or similar, you
should define a method to derive the MAC address from the serial
number.

If you are doing none of these, you may find other ways to write a
small block with the respective information into flash during your
hardware tests.  This is done on a number of boards.  See for example
function load_sernum_ethaddr() in "board/tqc/tqm8xx/load_sernum_ethaddr.c";
in this case, a small block of data gets written into a predefined
location of the NOR flash during the functional test of these boards,
using directly the PCB test probe.

If you are capable of booting from SDCard, it may be sufficient to
generate respective files (with the environment data) on your SDcards
that get loaded automatically at first boot (for example by using
PREBOOT settings; such a command can even delete itself from the
environment when done, so this is allows for one-time actions.

Of course, you can also pre-program your flashes before even fitting
the chips on the boards. There are programmers that support auto-
incrementing serial numbers or automatic insertion of data blocks
retrieved from some sort of production database.

etc. etc.

There is a zillion of methods to do what you want, you just have to
pick one that fits your board and your productions and test
environment best.  And any of these is way better than using random
MAC addresses.

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
What is mind?  No matter.  What is matter?  Never mind.
                                      -- Thomas Hewitt Key, 1799-1875


More information about the U-Boot mailing list