public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] Environment "image" tool
@ 2011-07-16 23:18 Alessio Sangalli
  2011-07-16 23:31 ` Wolfgang Denk
  2011-07-18 17:38 ` Mike Frysinger
  0 siblings, 2 replies; 9+ messages in thread
From: Alessio Sangalli @ 2011-07-16 23:18 UTC (permalink / raw)
  To: u-boot

Hi, is there a tool to create an "environemnt image" that I can flash to
my NAND?

I think I've seen a tool that takes a text file with an environment
setting per line, calculates the CRC and generates a binary that can be
transferred to the board (via tftp or other means) to be written with
"nand write".

Alternatively, is there a description of how the environment is read, my
U-Boot, so that I can write my own program to create such image?

Thanks!
bye
as

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

* [U-Boot] Environment "image" tool
  2011-07-16 23:18 [U-Boot] Environment "image" tool Alessio Sangalli
@ 2011-07-16 23:31 ` Wolfgang Denk
  2011-07-17  5:19   ` Alessio Sangalli
  2011-07-18 17:38 ` Mike Frysinger
  1 sibling, 1 reply; 9+ messages in thread
From: Wolfgang Denk @ 2011-07-16 23:31 UTC (permalink / raw)
  To: u-boot

Dear Alessio Sangalli,

In message <4E221C41.1080900@manoweb.com> you wrote:
> Hi, is there a tool to create an "environemnt image" that I can flash to
> my NAND?
> 
> I think I've seen a tool that takes a text file with an environment
> setting per line, calculates the CRC and generates a binary that can be
> transferred to the board (via tftp or other means) to be written with
> "nand write".
> 
> Alternatively, is there a description of how the environment is read, my
> U-Boot, so that I can write my own program to create such image?

Just load the text file into U-Boot (for example using TFTP or reading
from some file system) and use "env import -t" on it.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
If you're not part of the solution, you're part of the problem.

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

* [U-Boot] Environment "image" tool
  2011-07-16 23:31 ` Wolfgang Denk
@ 2011-07-17  5:19   ` Alessio Sangalli
  2011-07-18 16:22     ` Alessio Sangalli
  0 siblings, 1 reply; 9+ messages in thread
From: Alessio Sangalli @ 2011-07-17  5:19 UTC (permalink / raw)
  To: u-boot

On 07/16/2011 04:31 PM, Wolfgang Denk wrote:
> Dear Alessio Sangalli,

> Just load the text file into U-Boot (for example using TFTP or reading
> from some file system) and use "env import -t" on it.

Hi Wolfgang!

Thanks this is a very interesting way but in this application it'd be
easier to just flash what is needed on the NAND, so that I won't need an
interactive session with U-Boot on the board.

I am writing a "flashing tool" for my NAND chip.

Is the format that U-Boot uses to write the environment "stable" or it
could change?

Thanks!
bye
as

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

* [U-Boot] Environment "image" tool
  2011-07-17  5:19   ` Alessio Sangalli
@ 2011-07-18 16:22     ` Alessio Sangalli
  0 siblings, 0 replies; 9+ messages in thread
From: Alessio Sangalli @ 2011-07-18 16:22 UTC (permalink / raw)
  To: u-boot

On 07/16/2011 10:19 PM, Alessio Sangalli wrote:

> I am writing a "flashing tool" for my NAND chip.
> 
> Is the format that U-Boot uses to write the environment "stable" or it
> could change?


So I have written in my application some code that:

1) takes an area equivalent in size to ENV_SIZE and places a series of
'\0' terminated strings
2) calculates the CRC32 and places it in the first 4 bytes

This is written to the NAND and used by U-Boot, no problems at all.

My application is GLP-3 and available at:

https://gitorious.org/microflasher

bye
as

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

* [U-Boot] Environment "image" tool
  2011-07-16 23:18 [U-Boot] Environment "image" tool Alessio Sangalli
  2011-07-16 23:31 ` Wolfgang Denk
@ 2011-07-18 17:38 ` Mike Frysinger
  2011-07-18 17:47   ` Alessio Sangalli
  1 sibling, 1 reply; 9+ messages in thread
From: Mike Frysinger @ 2011-07-18 17:38 UTC (permalink / raw)
  To: u-boot

On Sat, Jul 16, 2011 at 19:18, Alessio Sangalli wrote:
> Hi, is there a tool to create an "environemnt image" that I can flash to
> my NAND?

tools/envcrc will output the binary env blob if you give it the
--binary option.  but it does not take arbitrary env inputs.
./tools/envcrc --binary > env.bin

> I think I've seen a tool that takes a text file with an environment
> setting per line, calculates the CRC and generates a binary that can be
> transferred to the board (via tftp or other means) to be written with
> "nand write".

sounds like it might be a useful addition to tools/envcrc

> Alternatively, is there a description of how the environment is read, my
> U-Boot, so that I can write my own program to create such image?

<4 byte crc><var=value>\0[<var=value>\0]...\0
-mike

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

* [U-Boot] Environment "image" tool
  2011-07-18 17:38 ` Mike Frysinger
@ 2011-07-18 17:47   ` Alessio Sangalli
  2011-07-18 17:59     ` Mike Frysinger
  0 siblings, 1 reply; 9+ messages in thread
From: Alessio Sangalli @ 2011-07-18 17:47 UTC (permalink / raw)
  To: u-boot

On 07/18/2011 10:38 AM, Mike Frysinger wrote:
> On Sat, Jul 16, 2011 at 19:18, Alessio Sangalli wrote:
>> Hi, is there a tool to create an "environemnt image" that I can flash to
>> my NAND?
> 
> tools/envcrc will output the binary env blob if you give it the
> --binary option.  but it does not take arbitrary env inputs.
> ./tools/envcrc --binary > env.bin

In the meanwhile I've written my own utility, but I do not understand
the "it does not take arbitrary env inputs".

> sounds like it might be a useful addition to tools/envcrc

I could not find it so I rewrote such functionality. If you want, I
could extract the relevant part of the code and send it to you. It's
quite trivial once I figured out how the U-Boot environment works.

>> Alternatively, is there a description of how the environment is read, my
>> U-Boot, so that I can write my own program to create such image?
> 
> <4 byte crc><var=value>\0[<var=value>\0]...\0

Yes, and the environment has a size specified by ENV_SIZE

bye
as

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

* [U-Boot] Environment "image" tool
  2011-07-18 17:47   ` Alessio Sangalli
@ 2011-07-18 17:59     ` Mike Frysinger
  2011-07-18 19:52       ` Alessio Sangalli
  0 siblings, 1 reply; 9+ messages in thread
From: Mike Frysinger @ 2011-07-18 17:59 UTC (permalink / raw)
  To: u-boot

On Mon, Jul 18, 2011 at 13:47, Alessio Sangalli wrote:
> On 07/18/2011 10:38 AM, Mike Frysinger wrote:
>> On Sat, Jul 16, 2011 at 19:18, Alessio Sangalli wrote:
>>> Hi, is there a tool to create an "environemnt image" that I can flash to
>>> my NAND?
>>
>> tools/envcrc will output the binary env blob if you give it the
>> --binary option. ?but it does not take arbitrary env inputs.
>> ./tools/envcrc --binary > env.bin
>
> In the meanwhile I've written my own utility, but I do not understand
> the "it does not take arbitrary env inputs".

tools/envcrc atm only outputs the default env that the board is
configured for.  you cant give it a text representation of the env and
have it calc things.

although thinking about it a bit more, you probably could do it in shell.
(cat <env file> | tr '\n' '\0' ; dd if=/dev/zero count=1 ibs=1) > env.bin
env_size=8192
pad_size=$(( env_size - $(set -- $(du -b env.bin); echo $1) - 4))
dd if=/dev/zero ibs=$pad_size count=1 | tr '\0' '\377' >> env.bin

and then you get the crc and prepend the 4 bytes
crc env.bin

>> sounds like it might be a useful addition to tools/envcrc
>
> I could not find it so I rewrote such functionality. If you want, I
> could extract the relevant part of the code and send it to you. It's
> quite trivial once I figured out how the U-Boot environment works.

extending tools/envcrc to take a --file option and use that rather
than the linked in default would be cool imo.
-mike

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

* [U-Boot] Environment "image" tool
  2011-07-18 17:59     ` Mike Frysinger
@ 2011-07-18 19:52       ` Alessio Sangalli
  2011-07-18 19:56         ` Mike Frysinger
  0 siblings, 1 reply; 9+ messages in thread
From: Alessio Sangalli @ 2011-07-18 19:52 UTC (permalink / raw)
  To: u-boot

On 07/18/2011 10:59 AM, Mike Frysinger wrote:

> although thinking about it a bit more, you probably could do it in shell.
> (cat <env file> | tr '\n' '\0' ; dd if=/dev/zero count=1 ibs=1) > env.bin
> env_size=8192
> pad_size=$(( env_size - $(set -- $(du -b env.bin); echo $1) - 4))
> dd if=/dev/zero ibs=$pad_size count=1 | tr '\0' '\377' >> env.bin
> 
> and then you get the crc and prepend the 4 bytes
> crc env.bin

Hi! I am not sure here how you would calculate the crc in the shell
script. Are you suggesting there is a command "crc(1)"?

> extending tools/envcrc to take a --file option and use that rather
> than the linked in default would be cool imo.

I will have a look at that prgram.

bye!!!
as

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

* [U-Boot] Environment "image" tool
  2011-07-18 19:52       ` Alessio Sangalli
@ 2011-07-18 19:56         ` Mike Frysinger
  0 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2011-07-18 19:56 UTC (permalink / raw)
  To: u-boot

On Mon, Jul 18, 2011 at 15:52, Alessio Sangalli wrote:
> On 07/18/2011 10:59 AM, Mike Frysinger wrote:
>> although thinking about it a bit more, you probably could do it in shell.
>> (cat <env file> | tr '\n' '\0' ; dd if=/dev/zero count=1 ibs=1) > env.bin
>> env_size=8192
>> pad_size=$(( env_size - $(set -- $(du -b env.bin); echo $1) - 4))
>> dd if=/dev/zero ibs=$pad_size count=1 | tr '\0' '\377' >> env.bin
>>
>> and then you get the crc and prepend the 4 bytes
>> crc env.bin
>
> Hi! I am not sure here how you would calculate the crc in the shell
> script. Are you suggesting there is a command "crc(1)"?

there is indeed such a command.  the "xc" program suite provides one.
i'm sure there are others as well like `crc32`.

$ crc env.bin
5473921d    8188  env.bin
-mike

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

end of thread, other threads:[~2011-07-18 19:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-16 23:18 [U-Boot] Environment "image" tool Alessio Sangalli
2011-07-16 23:31 ` Wolfgang Denk
2011-07-17  5:19   ` Alessio Sangalli
2011-07-18 16:22     ` Alessio Sangalli
2011-07-18 17:38 ` Mike Frysinger
2011-07-18 17:47   ` Alessio Sangalli
2011-07-18 17:59     ` Mike Frysinger
2011-07-18 19:52       ` Alessio Sangalli
2011-07-18 19:56         ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox