All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot-Users] Accessing U-Boot ENV variables from Linux
@ 2007-07-25 18:50 Raghu
  2007-07-25 19:05 ` Ben Warren
  2007-07-25 19:13 ` Greg Lopp
  0 siblings, 2 replies; 4+ messages in thread
From: Raghu @ 2007-07-25 18:50 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot-Users] Accessing U-Boot ENV variables from Linux
  2007-07-25 18:50 [U-Boot-Users] Accessing U-Boot ENV variables from Linux Raghu
@ 2007-07-25 19:05 ` Ben Warren
  2007-07-25 19:13 ` Greg Lopp
  1 sibling, 0 replies; 4+ messages in thread
From: Ben Warren @ 2007-07-25 19:05 UTC (permalink / raw)
  To: u-boot

Raghu,

On Wed, 2007-07-25 at 11:50 -0700, Raghu 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

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot-Users] Accessing U-Boot ENV variables from Linux
  2007-07-25 18:50 [U-Boot-Users] Accessing U-Boot ENV variables from Linux Raghu
  2007-07-25 19:05 ` Ben Warren
@ 2007-07-25 19:13 ` Greg Lopp
  1 sibling, 0 replies; 4+ messages in thread
From: Greg Lopp @ 2007-07-25 19:13 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot-Users] Accessing U-Boot ENV variables from Linux
       [not found] <18315818.19141185529368046.JavaMail.nabble@isper.nabble.com>
@ 2007-07-27 13:59 ` Ben Warren
  0 siblings, 0 replies; 4+ messages in thread
From: Ben Warren @ 2007-07-27 13:59 UTC (permalink / raw)
  To: u-boot

Nethra,

On Fri, 2007-07-27 at 02:42 -0700, nethra_gmit at yahoo.co.in wrote:
> i m not getting 'fw_printenv' after compiling u-boot..
> 
> [nethra at localhost u-boot-1.1.2]$ cd tools/env
> [nethra at localhost env]$ ls
>            fw_env.c  fw_env.config  fw_env.h  fw_env_main.c  Makefile  README
> 
> can i know how to use this proprerly..?

A few things:

1. Please don't e-mail me without including the U-boot list unless it's
something only I would be interested in, such as cheap Cialis or maybe
the chance to help recover millions of dollars from the widow of Saddam
Hussein's cousin-in-law.

2. Please don't top post.

That out of the way...

This tool isn't built by default.  I've attached a couple of patches
that apply cleanly to the latest git tree:

- The first turns on building of the tool.
- The second fixes compile errors and warnings that I came across a few
months ago.  I expect you'll need it if you're using Linux 2.6.  If
you're using a 2.4 kernel, I don't know if this is needed or not.

regards,
Ben
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: build_fw_printenv.patch
Type: text/x-patch
Size: 363 bytes
Desc: not available
Url : http://lists.denx.de/pipermail/u-boot/attachments/20070727/08aabdbf/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fw_printenv.patch
Type: application/mbox
Size: 7128 bytes
Desc: not available
Url : http://lists.denx.de/pipermail/u-boot/attachments/20070727/08aabdbf/attachment-0001.bin 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-07-27 13:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-25 18:50 [U-Boot-Users] Accessing U-Boot ENV variables from Linux Raghu
2007-07-25 19:05 ` Ben Warren
2007-07-25 19:13 ` Greg Lopp
     [not found] <18315818.19141185529368046.JavaMail.nabble@isper.nabble.com>
2007-07-27 13:59 ` Ben Warren

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.