Skip to contentSkip to conversation

Creating U-Boot env image

U-Boot Alexey Smishlayev 5 participants 9 messages Dec 9, 2013 – Dec 11, 2013

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw

Dear Alexey Smishlayev,

Quoted 7 lines · In message <[email protected]> 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

Quoted 6 lines

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

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Living on Earth may be expensive, but it includes an annual free trip
around the Sun.
#2 lore raw

Dear Wolfgang Denk,

Quoted 6 lines · Wolfgang Denk

Dear Alexey Smishlayev,

Quoted 1 line · In message <[email protected]> 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

#3 lore raw
Quoted 11 lines · Alexey Smishlayev

Dear Wolfgang Denk,

Quoted 7 lines · Wolfgang Denk

Dear Alexey Smishlayev,

Quoted 2 lines · In message <[email protected]> you wrote:

What should I do to flash environment values directly to the board's NAND?

Why don't you just use "env import"?

Quoted 6 lines

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

#4 lore raw
In reply to Alexey Smishlayev

Hi Alexey,

Quoted 10 lines · Alexey Smishlayev

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

#5 lore raw

Hello, Mats,

Quoted 5 lines · Mats K?rrman

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.

Quoted 2 lines

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.

Quoted 3 lines

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

#6 lore raw
Quoted 2 lines · Alexey Smishlayev

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.

Quoted 3 lines

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

#7 lore raw

Hello Mats,

Quoted 6 lines · Mats K?rrman
Quoted 2 lines · Alexey Smishlayev

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.

Quoted 6 lines
Quoted 3 lines

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

#8 lore raw
In reply to Alexey Smishlayev

Hi Alexey Smishlayev,

Quoted 7 lines · Alexey Smishlayev

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

Quoted 9 lines

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