From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wolfgang Denk Date: Wed, 31 Aug 2011 21:15:53 +0200 Subject: [U-Boot] Generating random numbers In-Reply-To: References: <20110830195552.B7B8518C46FE@gemini.denx.de> Message-ID: <20110831191553.D109E18C46FA@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 "elison.niven at gmail.com", In message 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