[U-Boot] Environment "image" tool

Mike Frysinger vapier at gentoo.org
Mon Jul 18 19:59:31 CEST 2011


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


More information about the U-Boot mailing list