Skip to contentSkip to conversation

crc32 checksum header in bootvars section of flash

U-Boot-Users u-boot user 2 participants 2 messages Jan 8, 2008 – Jan 9, 2008

lore
Share & tools
lore
#0 lore raw

Hello all,

Can anybody tell me where in u-boot source code and how is the crc32 checksum generated for the bootvars
section in flash? I edited the bootvars and have saved it to a file. The crc32 checksum header needs to be appended at the beginning of bootvars. I need to load the bootvars file and change it according for different board configurations. I put printf statements in env_common.c in u-boot source code in function env_crc_update() to print the crc32 checksum it calculates. But the values in the bootvars section in flash do not match with the printf values? There is a crc32 command in the u-boot bootloader as well. Is that used to calculate the checksum in the bootvars section? If yes, then what option is it used with and can we replicate the same code in user space so we can edit our own files and append checksums to it at the beginning?

I look forward to your replies.

Thanks and Regards

Signature · 2 lines
View this message in context: http://www.nabble.com/crc32-checksum-header-in-bootvars-section-of-flash-tp14702144p14702144.html
Sent from the Uboot - Users mailing list archive at Nabble.com.
#1 lore raw
Quoted 3 lines · In message <[email protected]> you wrote:

Can anybody tell me where in u-boot source code and how is the crc32 checksum generated for the bootvars

This should be trivial to find in the source code, shouldn't it?

Quoted 5 lines

But the values in the bootvars section in flash do not match with the printf values? There is a crc32 command in the u-boot bootloader as well. Is that used to calculate the checksum in the bootvars section? If yes, then what option is it used with and can we replicate the same code in user space so we can edit our own files and append checksums to it at the beginning?

I think what you're trying to do is broken by design. Instead of trying to rely on internal information of U-Boot (how it stores the
environment variables) you should instead use the official,
documented interfaces to do what you want to do.

Instead of crafting some binary blob that holds the environment variables in some undocumented internal format, you should simply write a text file which sontains the wanted variable settings in form of "setenv" commands, then convert this text file into a script image, and finally use the U-Boot "autoscr" command to apply these settings.

Thius way you can be sure that U-Boot will compute the correct checksum itself.

Also, you have simple text files which are much easier to maintain than binary blobs.

Best regards,

Wolfgang Denk

Signature · 5 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
He had quite a powerful intellect, but it  was  as  powerful  like  a
locomotive,  and  ran on rails and was therefore almost impossible to
steer.                          - Terry Pratchett, _Lords and Ladies_