Bad CRC after saving uboot Environment

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Bad CRC after saving uboot Environment

ソリューションへジャンプ
5,067件の閲覧回数
trongthinh
Contributor IV

I created a uboot environment file by this command:

$ mkenvimage -s 0x4200 -o uEnv.bin uboot-env.txt

Then I load this uboot env file in uboot command line:

=> fatload mmc 3:1 0x12100000 uEnv.bin
16896 bytes read in 15 ms (1.1 MiB/s)
=> env import -c 0x12100000 0x4200
=> env print bootcompleted
bootcompleted=true

It works, because the value of var bootcompleted is correct. Afterthat, I would like to change the value of bootcompleted and save to uEnv.bin

=> setenv bootcompleted false
=> env export -c 0x12100000 -s 0x4200
=> fatwrite mmc 3:1 0x12100000 uEnv.bin 0x4200
16896 bytes written

Then, I reboot the board and import uboot env from uEnv.bin again

=> fatload mmc 3:1 0x12100000 uEnv.bin
16896 bytes read in 18 ms (916 KiB/s)
=> env import -c 0x12100000 0x4200
## Error: bad CRC, import failed

It said that imported failed because bad CRC. how to fix this problem? Please advise! 

ラベル(3)
タグ(2)
1 解決策
4,837件の閲覧回数
kunalkotecha1
Senior Contributor II

Hi trongthinh,

The "mkenvimage" source generates the redundant environment variable from text file based on key-value pairs. It is appending the CRC at the beginning of the generated binary file, to make sure at load time that the file is not corrupted.You can see the implementation of "mkenvimage" source code located at "tools/mkenvimage.c"

As you are over-writing  uEnv.bin file in u-boot using the "fatwrite" command. Next time you try to import the same binary file it will give a CRC error as you are getting.

According to me, you should import the new u-boot environment variable and then you can save those environment variables "saveenv". If you want, you can change and again save them. After importing once it will be always shown in "printenv" and there won't be the requirement of importing again. I don't see any requirement to write the updated u-boot variable to the binary(uEnv.bin) file again. Is there any specific use case for which you want to write back to binary file?

Feel free to let us know if you have any confusion.

Regards,

Kunal

元の投稿で解決策を見る

0 件の賞賛
2 返答(返信)
4,838件の閲覧回数
kunalkotecha1
Senior Contributor II

Hi trongthinh,

The "mkenvimage" source generates the redundant environment variable from text file based on key-value pairs. It is appending the CRC at the beginning of the generated binary file, to make sure at load time that the file is not corrupted.You can see the implementation of "mkenvimage" source code located at "tools/mkenvimage.c"

As you are over-writing  uEnv.bin file in u-boot using the "fatwrite" command. Next time you try to import the same binary file it will give a CRC error as you are getting.

According to me, you should import the new u-boot environment variable and then you can save those environment variables "saveenv". If you want, you can change and again save them. After importing once it will be always shown in "printenv" and there won't be the requirement of importing again. I don't see any requirement to write the updated u-boot variable to the binary(uEnv.bin) file again. Is there any specific use case for which you want to write back to binary file?

Feel free to let us know if you have any confusion.

Regards,

Kunal

0 件の賞賛
4,837件の閲覧回数
trongthinh
Contributor IV

Dear Kunal,

I think it is an incorrect usage in my case. Thank for clarify me.

Regards,