[U-Boot-Users] Can a standalone app modify an environment variable?

Is it possible to modify environment variables from a standalone application in u-boot?
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 looked at the standalone section of the readme, and at the exports.h file, but I didn't see any explicit hooks to read or write environment variables. I saw the secion on accessing u-boot environment variables in Linux, but that does seem to be applicable. Are environment variables somehow accessible through the "global_data" pointer declared in exports.h?
I'm using u-boot 1.1.4.
Ed Jubenville

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 :-)

On Wed, Aug 16, 2006 at 09:00:13AM -0700, Edward Jubenville wrote:
Is it possible to modify environment variables from a standalone application in u-boot?
Hi - have you checked out
u-boot/tools/env/fw_env*
Might be what you are looking for.
Cheers,
Kelsey

Dear Ed,
in message GPECLCIGPLHEOMGPMCPAEEIIDOAA.edjubenville@adelphia.net you wrote:
Is it possible to modify environment variables from a standalone application in u-boot?
Yes, of course. You will have to add the getenv / setenv functions to the list of exported interfaces.
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.
Note that this may not be possible - in most configurations the "ethaddr" environment variable is read-only, i. e. it cannot be modified or deleted once set.
that does seem to be applicable. Are environment variables somehow accessible through the "global_data" pointer declared in exports.h?
No.
Best regards,
Wolfgang Denk
participants (4)
-
Andrew Dyer
-
Edward Jubenville
-
Kelsey Dawes
-
Wolfgang Denk