[U-Boot-Users] Accessing U-Boot ENV variables from Linux

Greg Lopp lopp at pobox.com
Wed Jul 25 21:13:18 CEST 2007


You would need to..
1) Have mtd (memory technology device) support in your kernel
2) Know the blocksize of your device
3) Know the offset to the environmental variables block
4) Write a program that..
4.1) open() the mtd device node
4.2) lseek() to the environmental block
4.3) read() the environmental block
4.4) Skip over the first 4 bytes (it's the checksum)
4.5) Parse through the series of \0 terminated strings until you find the
env var you are interested in
Stop here, if you only need to read vars. To write one....
4.6) Insert/update your variable's value
4.7) Use the checksum calculation table from the u-boot source to recalc the
chksum
4.8) Copy the checksum to the first four bytes of your new copy of the env
block
4.9) erase the env block on the device (ioctl(fd, MEMERASE, &erase_info)
4.A) lseek() to the env block
4.B) write() your new copy of the env block

I wrote one of these for our NOR device.  Should be the same for NAND,
right?  All the differences should be handled by the MTD layer.

On 7/25/07, Raghu <raghu_dk at yahoo.com> wrote:
>
> Hello All,
>
> I have a serial number and a MAC address stored as the
> U-Boot environment variables. A block of NAND flash
> device of size 128K is assigned for persistance.
>
> Is there a way that I can modify or change these
> variables from Linux kernel, OR what would I have to
> do to get this done.
>
> Warm Regards,
> Raghu
>
>
>
>
> ____________________________________________________________________________________
> Get the Yahoo! toolbar and be alerted to new email wherever you're
> surfing.
> http://new.toolbar.yahoo.com/toolbar/features/mail/index.php
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >>  http://get.splunk.com/
> _______________________________________________
> U-Boot-Users mailing list
> U-Boot-Users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/u-boot-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.denx.de/pipermail/u-boot/attachments/20070725/89c2b92f/attachment.htm 


More information about the U-Boot mailing list