[U-Boot-Users] tool to create environment on host?

Hi there,
is there a tool to create a binary environment block from a text file on the host?
If not what would be the best point to start?

In message 42943FAC.4010206@imc-berlin.de you wrote:
is there a tool to create a binary environment block from a text file on the host?
No, not yet.
If not what would be the best point to start?
tools/env/fw_env.[ch]
Replace the flash_io() code with something that simply writes the data to a regular file.
Best regards,
Wolfgang Denk

Wolfgang Denk wrote:
In message 42943FAC.4010206@imc-berlin.de you wrote:
is there a tool to create a binary environment block from a text file on the host?
No, not yet.
That would be *so* useful for our nightly builds...
-- Simon Poole www.appliancestudio.com

Simon,
is there a tool to create a binary environment block from a text file on the host?
No, not yet.
That would be *so* useful for our nightly builds...
Quick and Dirty Hack attached!
Good luck,
Steven
-- Index: tools/Makefile =================================================================== RCS file: /cvsroot/u-boot/u-boot/tools/Makefile,v retrieving revision 1.10 diff -u -r1.10 Makefile --- tools/Makefile 28 Sep 2004 21:39:46 -0000 1.10 +++ tools/Makefile 25 May 2005 13:12:49 -0000 @@ -21,9 +21,9 @@ # MA 02111-1307 USA #
-BINS = img2srec$(SFX) mkimage$(SFX) envcrc$(SFX) gen_eth_addr$(SFX) bmp_logo$(SFX) +BINS = img2srec$(SFX) mkimage$(SFX) envcrc$(SFX) gen_eth_addr$(SFX) bmp_logo$(SFX) txt2env$(SFX)
-OBJS = environment.o img2srec.o mkimage.o crc32.o envcrc.o gen_eth_addr.o bmp_logo.o +OBJS = environment.o img2srec.o mkimage.o crc32.o envcrc.o gen_eth_addr.o bmp_logo.o txt2env.o
ifeq ($(ARCH),mips) BINS += inca-swap-bytes$(SFX) @@ -121,6 +121,9 @@ envcrc$(SFX): envcrc.o crc32.o environment.o $(CC) $(CFLAGS) -o $@ $^
+txt2env$(SFX): txt2env.o crc32.o environment.o + $(CC) $(CFLAGS) -o $@ $^ + img2srec$(SFX): img2srec.o $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^ $(STRIP) $@ @@ -152,6 +155,9 @@ envcrc.o: envcrc.c $(CC) -g $(CFLAGS) -c $<
+txt2env.o: txt2env.c + $(CC) -g $(CFLAGS) -c $< + crc32.o: crc32.c $(CC) -g $(CFLAGS) -c $<

In message 4294507C.1050104@themalago.net you wrote:
is there a tool to create a binary environment block from a text file on the host?
...
That would be *so* useful for our nightly builds...
Why so? If correctly configured, the environment is built automati- cally with the U-Boot image anyway.
Even if there is good reason for split off environment sectors or for storing the environment in EEPROM (oops, no, impossible - there cannot be any good resons to do that) you can (and should) define a valid and useful default environment, which can even take care of automatic initialization of the "external" environment storage. This requires just a single line of command definitions.
Best regards,
Wolfgang Denk

Wolfgang Denk wrote:
In message 4294507C.1050104@themalago.net you wrote:
is there a tool to create a binary environment block from a text file on the host?
...
That would be *so* useful for our nightly builds...
Why so? If correctly configured, the environment is built automati- cally with the U-Boot image anyway.
Our nightly build produces the full u-boot, kernel, rootfs for our products and wraps it up into a nice single firmware image ready for flashing onto the boards.
The environment for a single board may vary slightly depending on the product it is going into (e.g. different mtdparts kernel bootarg). Our current procedure is to run u-boot on the board, setup the environment correctly, save a binary image of it and put that in the nightly build. Steven's idea means we can keep the environment in 'source' format and build the binary on the fly.
I might have missed a trick though if this can be done as part of the normal u-boot build?
Simon. -- Simon Poole www.appliancestudio.com

In message 42948C33.4010209@themalago.net you wrote:
The environment for a single board may vary slightly depending on the product it is going into (e.g. different mtdparts kernel bootarg). Our
OK - so you have several configurations, which require different environment settings. Right?
Steven's idea means we can keep the environment in 'source' format and build the binary on the fly.
You can have several (default) configuration stored simply in your board's config file and select these for example by using different Makefile targets.
I might have missed a trick though if this can be done as part of the normal u-boot build?
Add the required definitions to your board config file, and select these as different make targets. See for example tre adjustment of the U-Boot image file name on the TFTP server in "include/configs/TQM5200.h" (search for CONFIG_U_BOOT_SUFFIX), or see the different initialization of the environment depending on flash size (CONFIG_FLASH_8MB) and whether or not the hush shell is activated (CFG_HUSH_PARSER) in "include/configs/trab.h"
Best regards,
Wolfgang Denk

Wolfgang Denk wrote:
OK - so you have several configurations, which require different environment settings. Right?
Right.
Add the required definitions to your board config file, and select these as different make targets. See for example tre adjustment of the U-Boot image file name on the TFTP server in "include/configs/TQM5200.h" (search for CONFIG_U_BOOT_SUFFIX), or see the different initialization of the environment depending on flash size (CONFIG_FLASH_8MB) and whether or not the hush shell is activated (CFG_HUSH_PARSER) in "include/configs/trab.h"
Thanks for the pointers. I'll have a play...
-- Simon Poole www.appliancestudio.com

You can have several (default) configuration stored simply in your board's config file and select these for example by using different Makefile targets.
That's a good idea, but doesn't work for us because we distribute the boards with valid MAC's in the enviornment, hence every one must be different, and gets hand programmed. I don't know that there's a way to get around this, but if someone has come up with a tool, I would love to get my hands on it!
NZG.

In message 200505251312.29064.ngustavson@emacinc.com you wrote:
That's a good idea, but doesn't work for us because we distribute the boards with valid MAC's in the enviornment, hence every one must be different, and gets hand programmed.
There are solutions for this, too.
I don't know that there's a way to get around this, but if someone has come up with a tool, I would love to get my hands on it!
See "board/tqm8xx/load_sernum_ethaddr.c" - on these boards the unused space at the end of the last U-Boot flash sector is used: we store some data structure in the last 64 bytes of this sector containing the serial number, MAC address and som configuration information of the board. These 64 bytes are programmed after all the software has been installed, right before testing the boards.
U-Boot will check if the envrionment variables "serial#" and "ethaddr" are already defined - if this is the case, nothing happens; if not they get auto-initialized from this data structure. This is completely transparent to the user.
You see, all these problems were already addressed somewhere :-)
Best regards,
Wolfgang Denk

Wolfgang Denk wrote:
See "board/tqm8xx/load_sernum_ethaddr.c" - on these boards the unused space at the end of the last U-Boot flash sector is used: we store some data structure in the last 64 bytes of this sector containing the serial number, MAC address and som configuration information of the board.
And if you update U-Boot in the field these information get lost!?
-- Steven

In message 42957FBE.6010202@imc-berlin.de you wrote:
See "board/tqm8xx/load_sernum_ethaddr.c" - on these boards the unused space at the end of the last U-Boot flash sector is used: we store some data structure in the last 64 bytes of this sector containing the serial number, MAC address and som configuration information of the board.
And if you update U-Boot in the field these information get lost!?
By then the information has long been saved to the normal environment (it get's written with the first "saveenv"). You just have to make sure that the standard update procedure takes care to keep the old environment - but you want to do this anyway.
Best regards,
Wolfgang Denk

Wolfgang Denk wrote:
In message 42943FAC.4010206@imc-berlin.de you wrote:
is there a tool to create a binary environment block from a text file on the host?
No, not yet.
How do I handle the byteorde of the CRC? Where is this done in U-Boot?
-- Steven

In message 42946E59.5090902@imc-berlin.de you wrote:
How do I handle the byteorde of the CRC?
Use the target's host byte order.
Where is this done in U-Boot?
U-Boot or the fw_env tools are always running on the target, so they just use the native byte order.
If your tool is running on the host, you must add appropriate conversion.
Best regards,
Wolfgang Denk
participants (4)
-
NZG
-
Simon Poole
-
Steven Scholz
-
Wolfgang Denk