[U-Boot] Environment "image" tool

Hi, is there a tool to create an "environemnt image" that I can flash to my NAND?
I think I've seen a tool that takes a text file with an environment setting per line, calculates the CRC and generates a binary that can be transferred to the board (via tftp or other means) to be written with "nand write".
Alternatively, is there a description of how the environment is read, my U-Boot, so that I can write my own program to create such image?
Thanks! bye as

Dear Alessio Sangalli,
In message 4E221C41.1080900@manoweb.com you wrote:
Hi, is there a tool to create an "environemnt image" that I can flash to my NAND?
I think I've seen a tool that takes a text file with an environment setting per line, calculates the CRC and generates a binary that can be transferred to the board (via tftp or other means) to be written with "nand write".
Alternatively, is there a description of how the environment is read, my U-Boot, so that I can write my own program to create such image?
Just load the text file into U-Boot (for example using TFTP or reading from some file system) and use "env import -t" on it.
Best regards,
Wolfgang Denk

On 07/16/2011 04:31 PM, Wolfgang Denk wrote:
Dear Alessio Sangalli,
Just load the text file into U-Boot (for example using TFTP or reading from some file system) and use "env import -t" on it.
Hi Wolfgang!
Thanks this is a very interesting way but in this application it'd be easier to just flash what is needed on the NAND, so that I won't need an interactive session with U-Boot on the board.
I am writing a "flashing tool" for my NAND chip.
Is the format that U-Boot uses to write the environment "stable" or it could change?
Thanks! bye as

On 07/16/2011 10:19 PM, Alessio Sangalli wrote:
I am writing a "flashing tool" for my NAND chip.
Is the format that U-Boot uses to write the environment "stable" or it could change?
So I have written in my application some code that:
1) takes an area equivalent in size to ENV_SIZE and places a series of '\0' terminated strings 2) calculates the CRC32 and places it in the first 4 bytes
This is written to the NAND and used by U-Boot, no problems at all.
My application is GLP-3 and available at:
https://gitorious.org/microflasher
bye as

On Sat, Jul 16, 2011 at 19:18, Alessio Sangalli wrote:
Hi, is there a tool to create an "environemnt image" that I can flash to my NAND?
tools/envcrc will output the binary env blob if you give it the --binary option. but it does not take arbitrary env inputs. ./tools/envcrc --binary > env.bin
I think I've seen a tool that takes a text file with an environment setting per line, calculates the CRC and generates a binary that can be transferred to the board (via tftp or other means) to be written with "nand write".
sounds like it might be a useful addition to tools/envcrc
Alternatively, is there a description of how the environment is read, my U-Boot, so that I can write my own program to create such image?
<4 byte crc><var=value>\0[<var=value>\0]...\0 -mike

On 07/18/2011 10:38 AM, Mike Frysinger wrote:
On Sat, Jul 16, 2011 at 19:18, Alessio Sangalli wrote:
Hi, is there a tool to create an "environemnt image" that I can flash to my NAND?
tools/envcrc will output the binary env blob if you give it the --binary option. but it does not take arbitrary env inputs. ./tools/envcrc --binary > env.bin
In the meanwhile I've written my own utility, but I do not understand the "it does not take arbitrary env inputs".
sounds like it might be a useful addition to tools/envcrc
I could not find it so I rewrote such functionality. If you want, I could extract the relevant part of the code and send it to you. It's quite trivial once I figured out how the U-Boot environment works.
Alternatively, is there a description of how the environment is read, my U-Boot, so that I can write my own program to create such image?
<4 byte crc><var=value>\0[<var=value>\0]...\0
Yes, and the environment has a size specified by ENV_SIZE
bye as

On Mon, Jul 18, 2011 at 13:47, Alessio Sangalli wrote:
On 07/18/2011 10:38 AM, Mike Frysinger wrote:
On Sat, Jul 16, 2011 at 19:18, Alessio Sangalli wrote:
Hi, is there a tool to create an "environemnt image" that I can flash to my NAND?
tools/envcrc will output the binary env blob if you give it the --binary option. but it does not take arbitrary env inputs. ./tools/envcrc --binary > env.bin
In the meanwhile I've written my own utility, but I do not understand the "it does not take arbitrary env inputs".
tools/envcrc atm only outputs the default env that the board is configured for. you cant give it a text representation of the env and have it calc things.
although thinking about it a bit more, you probably could do it in shell. (cat <env file> | tr '\n' '\0' ; dd if=/dev/zero count=1 ibs=1) > env.bin env_size=8192 pad_size=$(( env_size - $(set -- $(du -b env.bin); echo $1) - 4)) dd if=/dev/zero ibs=$pad_size count=1 | tr '\0' '\377' >> env.bin
and then you get the crc and prepend the 4 bytes crc env.bin
sounds like it might be a useful addition to tools/envcrc
I could not find it so I rewrote such functionality. If you want, I could extract the relevant part of the code and send it to you. It's quite trivial once I figured out how the U-Boot environment works.
extending tools/envcrc to take a --file option and use that rather than the linked in default would be cool imo. -mike

On 07/18/2011 10:59 AM, Mike Frysinger wrote:
although thinking about it a bit more, you probably could do it in shell. (cat <env file> | tr '\n' '\0' ; dd if=/dev/zero count=1 ibs=1) > env.bin env_size=8192 pad_size=$(( env_size - $(set -- $(du -b env.bin); echo $1) - 4)) dd if=/dev/zero ibs=$pad_size count=1 | tr '\0' '\377' >> env.bin
and then you get the crc and prepend the 4 bytes crc env.bin
Hi! I am not sure here how you would calculate the crc in the shell script. Are you suggesting there is a command "crc(1)"?
extending tools/envcrc to take a --file option and use that rather than the linked in default would be cool imo.
I will have a look at that prgram.
bye!!! as

On Mon, Jul 18, 2011 at 15:52, Alessio Sangalli wrote:
On 07/18/2011 10:59 AM, Mike Frysinger wrote:
although thinking about it a bit more, you probably could do it in shell. (cat <env file> | tr '\n' '\0' ; dd if=/dev/zero count=1 ibs=1) > env.bin env_size=8192 pad_size=$(( env_size - $(set -- $(du -b env.bin); echo $1) - 4)) dd if=/dev/zero ibs=$pad_size count=1 | tr '\0' '\377' >> env.bin
and then you get the crc and prepend the 4 bytes crc env.bin
Hi! I am not sure here how you would calculate the crc in the shell script. Are you suggesting there is a command "crc(1)"?
there is indeed such a command. the "xc" program suite provides one. i'm sure there are others as well like `crc32`.
$ crc env.bin 5473921d 8188 env.bin -mike
participants (3)
-
Alessio Sangalli
-
Mike Frysinger
-
Wolfgang Denk