
On 8/16/06, Edward Jubenville edjubenville@adelphia.net wrote:
I've written a standalone app that reads and prints a 48-bit ethernet MAC address from a Dallas/Maxim DS2502-E48 chip on a custom board. I would like the app to directly modify the "ethaddr" environment variable, rather than relying on the user to retype the printed MAC address into a setenv command.
I think the problem you'll find is the the bd->bi_enetaddr structure elements get filled in the boot process, before your code would run. This is what gets pushed into the mac registers that set the ethernet address.
For our board I patched the boot sequence to check if ethaddr is set in the environment or a hardcoded define is in the board config file, if neither of those is set, then call the function that reads the mac address from the 2502 chip and put it into the ethaddr environment variable (but not save it to flash). Then when it gets to the code that fills in bd->bi_enetaddr the address is in place. This lets the user overwrite the ethaddr value if they need to.
You may also want to look at how/whether the mac address gets passed to the linux kernel for your target. We ended up patching mips_linux.c to pass ethaddr, although I don't recall exactly why :-)