Skip to contentSkip to conversation

Accessing U-Boot ENV variables from Linux

U-Boot-Users Raghu 3 participants 3 messages Jul 25, 2007

lore
Share & tools
lore

Raghu

author
#0 lore raw

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

#1 lore raw

Raghu,

Quoted 6 lines · Raghu

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.

Quoted 6 lines

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

There's source code for a Linux user-space utility in /tools/env called 'fw_printenv' that will allow you to access the U-boot environment through MTD. I use it all the time.

regards,
Ben

#2 lore raw
In reply to Raghu

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.

Quoted 22 lines · Raghu

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

Quoted 10 lines

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