[U-Boot] [PATCHv2] new tool mkenvimage: generates an env image from an arbitrary config file

Mike Frysinger vapier at gentoo.org
Mon Aug 8 20:53:07 CEST 2011


On Mon, Aug 8, 2011 at 04:16, David Wagner wrote:
> On 08/06/2011 01:18 PM, Mike Frysinger wrote:
>> seems like this should also take a padding byte so people can use a
>> more sensible 0xff rather than 0x00
>
> Thomas told me that when padding with 0xff, his environment image
> wouldn't be taken into account anymore.
> I'll add the option anyway, but do you know what could be happening ?

sorry, but i dont know what you're referring to.  perhaps you wrote
out the padding before calculating the crc ?  ive been using
`tools/envcrc --binary` for a while now and it pads things with 0xff.

> Also, I guess this makes necessary making sure there is a \0 after the
> last configuration line.

two to be exact ... one for the config opt, and one to tell u-boot
that it's the end of the env.

> I wasn't sure whether the proper way of doing it was "read/write 1 byte,
> N times" or "read/write the size of the file, 1 time".  I probably
> changed my mine in between.

dont think of it in terms of bytes.  in fact, forget about that
completely.  think of it in terms of "elements".  in this case, the
element is a "char" which means you want to read a bunch of "char"
elements and the size of each is 1.

you could also do:
fwrite(dataptr, sizeof(*dataptr), datasize, bin_file);
then you dont need to think "how many bytes is one element".
-mike


More information about the U-Boot mailing list