[U-Boot] Creating U-Boot env image

Hello!
I would like to flash the environment variable values to my board, rather than setting them at the prompt. I've founa a tool mkenvimage is made specially for that. I used it to create a binary image of the U-Boot environment. However, when I flash it to my board, I get the message *** Warning - bad CRC, using default environment
I thought it is due to that redundant memory wasn't written aswell, so I commented out #define CONFIG_ENV_REDUND_OFFSET in the include/configs/at91sam9g20ek.h, and tried once again, but I'm still getting this error.
What should I do to flash environment values directly to the board's NAND?
Best regards, Alexey Smishlayev

Dear Alexey Smishlayev,
In message 52A5D4F1.7020101@xtech2.lv you wrote:
I would like to flash the environment variable values to my board, rather than setting them at the prompt. I've founa a tool mkenvimage is made specially for that. I used it to create a binary image of the U-Boot environment. However, when I flash it to my board, I get the message *** Warning - bad CRC, using default environment
I thought it is due to that redundant memory wasn't written aswell, so I commented out #define CONFIG_ENV_REDUND_OFFSET in the include/configs/at91sam9g20ek.h, and tried once again, but I'm still getting this error.
What should I do to flash environment values directly to the board's NAND?
Why don't you just use "env import"?
Best regards,
Wolfgang Denk

Dear Wolfgang Denk,
On 2013.12.09. 22:12, Wolfgang Denk wrote:
Dear Alexey Smishlayev,
In message 52A5D4F1.7020101@xtech2.lv you wrote:
What should I do to flash environment values directly to the board's NAND?
Why don't you just use "env import"?
I didn't have any information about that. Also, I would like to get done without entering the U-Boot prompt. I am flashing my board using the J-TAG - USB cable, and it will be much more simple and convenient if I'd be able to just write the binary images on the NAND flash.
So, there is no way to do something like that straight away?
Best regards, Alexey Smishlayev

On 12/09/2013 02:39 PM, Alexey Smishlayev wrote:
Dear Wolfgang Denk,
On 2013.12.09. 22:12, Wolfgang Denk wrote:
Dear Alexey Smishlayev,
In message 52A5D4F1.7020101@xtech2.lv you wrote:
What should I do to flash environment values directly to the board's NAND?
Why don't you just use "env import"?
I didn't have any information about that. Also, I would like to get done without entering the U-Boot prompt. I am flashing my board using the J-TAG - USB cable, and it will be much more simple and convenient if I'd be able to just write the binary images on the NAND flash.
So, there is no way to do something like that straight away?
I have no idea if something similar would work on your SoC, but I flash my Tegra devices as follows:
* Download a copy of U-Boot into RAM and execute it.
I use "tegrarcm" to download it (a method of talking to Tegra's boot ROM), but I imagine you could download using JTAG too.
* This U-Boot's bootcmd (specified in the attached device tree in my case) writes the desired binary to boot flash; I flash from the device itself rather than using JTAG/... for the actual flash writes.
* After flashing the U-Boot binary, the same U-Boot does "env default -f -a; saveenv" and hence re-initializes the environment in flash. You can easily "setenv foo bar" between those two commands for any custom overrides. You could even push a file into some known RAM location and run "env import" on it too...
* Reboot into the newly-flashed U-Boot.
The code is at: https://github.com/NVIDIA/tegra-uboot-flasher-scripts

Hi Alexey,
on: Monday, December 09, 2013 3:34 PM, Alexey Smishlayev wrote:
I would like to flash the environment variable values to my board, rather than setting them at the prompt. I've founa a tool mkenvimage is made specially for that. I used it to create a binary image of the U-Boot environment. However, when I flash it to my board, I get the message *** Warning - bad CRC, using default environment
I thought it is due to that redundant memory wasn't written aswell, so I commented out #define CONFIG_ENV_REDUND_OFFSET in the include/configs/at91sam9g20ek.h, and tried once again, but I'm still getting this error.
I can definitely see the use case in producing a complete flash image, e.g. for production use and maybe be able to select the env image from one of many depending on some factor.
What you describe should definitely be possible. Are you sure that it's not something simple like a missmatch in env size?
You could use U-Boots Linux fw_printenv tools and/or dd to read the flashed env image and perhaps compare it to an image saved by U-Boot to figure out what is going wrong.
BR // Mats

Hello, Mats,
On 2013.12.10. 13:39, Mats Kärrman wrote:
Hi Alexey,
I can definitely see the use case in producing a complete flash image, e.g. for production use and maybe be able to select the env image from one of many depending on some factor.
Yes, the use case is exactly as you described.
What you describe should definitely be possible. Are you sure that it's not something simple like a missmatch in env size?
I'm not sure, if that's not something simple, that's why I wrote to this list. I just don't know every little detail about using U-Boot.
You could use U-Boots Linux fw_printenv tools and/or dd to read the flashed env image and perhaps compare it to an image saved by U-Boot to figure out what is going wrong.
That's what I've thought also - if I just dd the environment contents to a file, can I then use it as a valid image for production? That could be the most simple way to achieve what I want.
Best regards, Alexey Smishlayev

On: Tuesday, December 10, 2013 1:32 PM, Alexey Smishlayev wrote:
I'm not sure, if that's not something simple, that's why I wrote to this list. I just don't know every little detail about using U-Boot.
I was thinking something like: [flash-sector-size] <= [U-Boot-configured-env-size] and you must give the right number to the env image generation program.
That's what I've thought also - if I just dd the environment contents to a file, can I then use it as a valid image for production? That could be the most simple way to achieve what I want.
Yes, should be possible. If you're using redundant environments, you probably want to use the env copy that has "0x01" in the 5:th byte. See common/env_flash.c and include/environment.h.
// Mats

Hello Mats,
On 2013.12.10. 15:33, Mats Kärrman wrote:
On: Tuesday, December 10, 2013 1:32 PM, Alexey Smishlayev wrote:
I'm not sure, if that's not something simple, that's why I wrote to this list. I just don't know every little detail about using U-Boot.
I was thinking something like: [flash-sector-size] <= [U-Boot-configured-env-size] and you must give the right number to the env image generation program.
That's what I've thought also - if I just dd the environment contents to a file, can I then use it as a valid image for production? That could be the most simple way to achieve what I want.
Yes, should be possible. If you're using redundant environments, you probably want to use the env copy that has "0x01" in the 5:th byte. See common/env_flash.c and include/environment.h.
Thank you, I will check that. How can I see if I'm compiling U-Boot with redundant environment, or not?
Best regards, Alexey

Hi Alexey Smishlayev,
On 12/09/2013 10:34 PM, Alexey Smishlayev wrote:
Hello!
I would like to flash the environment variable values to my board, rather than setting them at the prompt. I've founa a tool mkenvimage is made specially for that. I used it to create a binary image of the U-Boot environment. However, when I flash it to my board, I get the message *** Warning - bad CRC, using default environment
Can you try the sam-ba tool provide by Atmel to generate this kind of image? Run the bat file in demo package [1]. It will generate the image automatically. More information, please reference the demo package [1].
[1] ftp://ftp.linux4sam.org/pub/demo/linux4sam_2.0/linux4sam-angstrom-at91sam9g20ek.zip
I thought it is due to that redundant memory wasn't written aswell, so I commented out #define CONFIG_ENV_REDUND_OFFSET in the include/configs/at91sam9g20ek.h, and tried once again, but I'm still getting this error.
What should I do to flash environment values directly to the board's NAND?
Best regards, Alexey Smishlayev
Best Regards, Bo Shen
participants (5)
-
Alexey Smishlayev
-
Bo Shen
-
Mats Kärrman
-
Stephen Warren
-
Wolfgang Denk