Skip to contentSkip to conversation

make env

U-Boot-Users Manuel Sahm 4 participants 17 messages Mar 20, 2008 – Apr 6, 2008

lore
Share & tools
lore
#0 lore raw

Hello

could anybody tell me how to compile the |fw_setenv and ||fw_saveenv binaries ?

I try to use

make ARCH=arm CROSS_COMPILE=<Path to my CrossCompiler> env

But this doesn?t work.

#error This is a kernel header. Perhaps include mtd-user.h instead ? and a lot of error messages appaer ?

Thank you|

Best regards

Manuel Sahm

#1 lore raw
Quoted 5 lines · In message <[email protected]> you wrote:

SGVsbG8KCmNvdWxkIGFueWJvZHkgdGVsbCBtZSBob3cgdG8gY29tcGlsZSB0aGUgfGZ3X3NldGVu diBhbmQgfHxmd19zYXZlZW52IApiaW5hcmllcyA/CgpJIHRyeSB0byB1c2UKCm1ha2UgQVJDSD1h cm0gQ1JPU1NfQ09NUElMRT08UGF0aCB0byBteSBDcm9zc0NvbXBpbGVyPiBlbnYKCkJ1dCB0aGlz IGRvZXNuwrR0IHdvcmsuCgojZXJyb3IgVGhpcyBpcyBhIGtlcm5lbCBoZWFkZXIuIFBlcmhhcHMg aW5jbHVkZSBtdGQtdXNlci5oIGluc3RlYWQgPwphbmQgYSBsb3Qgb2YgZXJyb3IgbWVzc2FnZXMg

Quoted 8 lines

YXBwYWVyID8KClRoYW5rIHlvdXwKCkJlc3QgcmVnYXJkcyAKCk1hbnVlbCBTYWhtCQoKCgoKLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLQpUaGlzIFNGLm5ldCBlbWFpbCBpcyBzcG9uc29yZWQgYnk6IE1pY3Jvc29m dApEZWZ5IGFsbCBjaGFsbGVuZ2VzLiBNaWNyb3NvZnQoUikgVmlzdWFsIFN0dWRpbyAyMDA4Lgpo dHRwOi8vY2xrLmF0ZG10LmNvbS9NUlQvZ28vdnNlMDEyMDAwMDA3MG1ydC9kaXJlY3QvMDEvCl9f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fClUtQm9vdC1Vc2Vy cyBtYWlsaW5nIGxpc3QKVS1Cb290LVVzZXJzQGxpc3RzLnNvdXJjZWZvcmdlLm5ldApodHRwczov L2xpc3RzLnNvdXJjZWZvcmdlLm5ldC9saXN0cy9saXN0aW5mby91LWJvb3QtdXNlcnMK

Please do not send base 64 encoded messages.

Please send plain text only.

Quoted 2 lines

could anybody tell me how to compile the |fw_setenv and ||fw_saveenv binaries ?

I guess (you fail to mention such a basic fact as which version you are using) that you are referring to old code. So I recommend to use recent code (i. e. release 1.3.2).

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
"They that can give up essential liberty to obtain a little temporary
saftey deserve neither liberty not saftey." - Benjamin Franklin, 1759
#2 lore raw
Quoted 3 lines · Wolfgang Denk

I guess (you fail to mention such a basic fact as which version you are using) that you are referring to old code. So I recommend to use recent code (i. e. release 1.3.2).

No matter how recent version is he going to use. Related Makefile fragment reads:
env:

	$(MAKE) -C tools/env all MTD_VERSION=${MTD_VERSION} || exit 1

which means CFLAGS etc. are not propagated to fw_setenv utility...

Best regards,
ladis

#3 lore raw
Quoted 11 lines · In message <[email protected]> you wrote:
Quoted 3 lines · Wolfgang Denk

I guess (you fail to mention such a basic fact as which version you are using) that you are referring to old code. So I recommend to use recent code (i. e. release 1.3.2).

No matter how recent version is he going to use. Related Makefile fragment reads:
env:

	$(MAKE) -C tools/env all MTD_VERSION=${MTD_VERSION} || exit 1

which means CFLAGS etc. are not propagated to fw_setenv utility...

Yes, and actually I think this is correct. What we're building is a target Linux application, so the U-Boto specific CFLAG settings have no meaning for this (or rather would be just dangerous).

Example:

-> make env
make -C tools/env all MTD_VERSION= || exit 1
make[1]: Entering directory `/home/wd/git/u-boot/work/tools/env'
ln -s ../../lib_generic/crc32.c crc32.c
make[1]: Leaving directory `/home/wd/git/u-boot/work/tools/env'
make[1]: Entering directory `/home/wd/git/u-boot/work/tools/env'
arm-linux-gcc -Wall -DUSE_HOSTCC crc32.c fw_env.c fw_env_main.c -o
fw_printenv
make[1]: Leaving directory `/home/wd/git/u-boot/work/tools/env'
-> file tools/env/fw_printenv
tools/env/fw_printenv: ELF 32-bit LSB executable, ARM, version 1, dynamically linked (uses shared libs), for GNU/Linux 2.4.3, not stripped

I'm not sure what you wanted to express with your comment?

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
"I think trash is the most important manifestation of culture we have
in my lifetime."                                      - Johnny Legend
#4 lore raw
Quoted 18 lines · Wolfgang Denk

Yes, and actually I think this is correct. What we're building is a target Linux application, so the U-Boto specific CFLAG settings have no meaning for this (or rather would be just dangerous).

Example:

-> make env
make -C tools/env all MTD_VERSION= || exit 1
make[1]: Entering directory `/home/wd/git/u-boot/work/tools/env'
ln -s ../../lib_generic/crc32.c crc32.c
make[1]: Leaving directory `/home/wd/git/u-boot/work/tools/env'
make[1]: Entering directory `/home/wd/git/u-boot/work/tools/env'
arm-linux-gcc -Wall -DUSE_HOSTCC crc32.c fw_env.c fw_env_main.c -o
fw_printenv
make[1]: Leaving directory `/home/wd/git/u-boot/work/tools/env'
-> file tools/env/fw_printenv
tools/env/fw_printenv: ELF 32-bit LSB executable, ARM, version 1, dynamically linked (uses shared libs), for GNU/Linux 2.4.3, not stripped

Quoted 1 line

I'm not sure what you wanted to express with your comment?

Well, it seems you have "properly" configured toolchain - you installed proper kernel headers. In my case it ends with:

-> make env CROSS_COMPILE=arm-C411_L24-linux-gnu-
make -C tools/env all MTD_VERSION= || exit 1
make[1]: Entering directory `/home/ladis/src/u-boot/tools/env' arm-C411_L24-linux-gnu-gcc -Wall -DUSE_HOSTCC crc32.c fw_env.c fw_env_main.c -o fw_printenv
fw_env.c:39:27: error: mtd/mtd-user.h: No such file or directory

Here I have no opportunity to tell compiler where to find that header. I'd have to put them on some "standard" place, which could conflict with 2.4 headers. I do not want to pass U-Boot specific flags, just fw_setenv specific.

Best regards,
ladis

#5 lore raw
Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 2 lines

I'm not sure what you wanted to express with your comment?

Well, it seems you have "properly" configured toolchain - you installed proper kernel headers. In my case it ends with:

Well, yes, a correctly configured and working toolchain is considered a prerequisite for U-Boot development.

Quoted 6 lines

fw_env.c:39:27: error: mtd/mtd-user.h: No such file or directory

Here I have no opportunity to tell compiler where to find that header. I'd have to put them on some "standard" place, which could conflict with 2.4 headers. I do not want to pass U-Boot specific flags, just fw_setenv specific.

It's not fw_setenv specific. You would have to do the same when you cross-compile any other native Linux application code. The best approach would be to fix your toolchain.

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
"The algorithm to do that is extremely nasty. You might want  to  mug
someone with it."                   - M. Devine, Computer Science 340
#6 lore raw
Quoted 3 lines · Wolfgang Denk

It's not fw_setenv specific. You would have to do the same when you cross-compile any other native Linux application code. The best approach would be to fix your toolchain.

Well, any other applications compile just fine. This is needed only when you are interfacing some kernel subsystem (MTD in this case) and need its headers. Current approach needs one toolchain for compiling fw_setenv with 2.4 kernel and another for 2.6 kernel while there is no technical reason not to use very same toolchain for both.

Best regards,
ladis

PS. I'm just pointing to one minor difficulty, as I have no problem with that. I only tried to guess where might be Manuel's problem once he figure out MTD_VERSION variable.

#7 lore raw

Hello,

I took the U-Boot version 1.3.2; now I am able to generate the make env -> fw_printenv utility.

I copy the jw_printenv binary and rename it to fw_setenv.

I use the config file in the /etc directory.
I want to access a NAND flash. [Pagesize = 0x800; ERASEBLOCKSIZE=0x20000] My uboot is in mtd1.
mtd1 is from 0x20000 ... 0x100000 in my NAND-Flash
The Uboot enviroment is from 0x60000...0x80000; the redundant from 0x80000...0x100000

My fw_config file is:

/dev/mtd1      0x40000   0x20000   0x20000
/dev/mtd1      0x60000   0x20000   0x20000

Is this correct ?

I am able tu use fw_printenv, the variables are printed on the console If I use fw_setenv I get errors:

fw_setenv test 1

Unlocking Flash
Done
nand_write: attempting to write not page aligned data Erasing old enviroment
Done
Writing enviroment to /dev/mtd1: Invalid argument
Error: can?t write fw_env to flash

What?s wrong ????

Thank you very much

Manuel Sahm

Quoted 21 lines · Ladislav Michl
Quoted 4 lines · Wolfgang Denk

It's not fw_setenv specific. You would have to do the same when you cross-compile any other native Linux application code. The best approach would be to fix your toolchain.

Well, any other applications compile just fine. This is needed only when you are interfacing some kernel subsystem (MTD in this case) and need its headers. Current approach needs one toolchain for compiling fw_setenv with 2.4 kernel and another for 2.6 kernel while there is no technical reason not to use very same toolchain for both.

Best regards,
ladis

PS. I'm just pointing to one minor difficulty, as I have no problem with that. I only tried to guess where might be Manuel's problem once he figure out MTD_VERSION variable.

#8 lore raw

Hi Manuel,

Quoted 4 lines · Manuel Sahm

I took the U-Boot version 1.3.2; now I am able to generate the make env -> fw_printenv utility.

I copy the jw_printenv binary and rename it to fw_setenv.

A (hard) link would be enough.

Quoted 7 lines

I use the config file in the /etc directory.
I want to access a NAND flash. [Pagesize = 0x800; ERASEBLOCKSIZE=0x20000] My uboot is in mtd1.
mtd1 is from 0x20000 ... 0x100000 in my NAND-Flash
The Uboot enviroment is from 0x60000...0x80000; the redundant from 0x80000...0x100000

Quoted 6 lines

My fw_config file is:

/dev/mtd1      0x40000   0x20000   0x20000
/dev/mtd1      0x60000   0x20000   0x20000

Is this correct ?

Looks OK to me.

Quoted 13 lines

I am able tu use fw_printenv, the variables are printed on the console If I use fw_setenv I get errors:

fw_setenv test 1

Unlocking Flash
Done
nand_write: attempting to write not page aligned data Erasing old enviroment
Done
Writing enviroment to /dev/mtd1: Invalid argument
Error: can?t write fw_env to flash

Quoted 1 line

What?s wrong ????

I think the problem is that the fw_setenv so far only supports NOR flash. Environment in NAND is implemented slightly different, especially it doesn't (and can't) invalidate the former valid environment after the updated one was written successfully. So I'm afraid you will have to update this tool to support NAND.

Best regards

Markus Klotzbuecher

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de

#9 lore raw

Hello,

but why is there a error concerning NAND flashs if only NOR flashs are supported ?

"nand_write: attempting to write not page aligned data"

Thank you
Manuel Sahm

Quoted 63 lines · Markus Klotzb?cher

Hi Manuel,

Quoted 5 lines · Manuel Sahm

I took the U-Boot version 1.3.2; now I am able to generate the make env -> fw_printenv utility.

I copy the jw_printenv binary and rename it to fw_setenv.

A (hard) link would be enough.

Quoted 7 lines

I use the config file in the /etc directory.
I want to access a NAND flash. [Pagesize = 0x800; ERASEBLOCKSIZE=0x20000] My uboot is in mtd1.
mtd1 is from 0x20000 ... 0x100000 in my NAND-Flash
The Uboot enviroment is from 0x60000...0x80000; the redundant from 0x80000...0x100000

Quoted 7 lines

My fw_config file is:

/dev/mtd1      0x40000   0x20000   0x20000
/dev/mtd1      0x60000   0x20000   0x20000

Is this correct ?

Looks OK to me.

Quoted 13 lines

I am able tu use fw_printenv, the variables are printed on the console If I use fw_setenv I get errors:

fw_setenv test 1

Unlocking Flash
Done
nand_write: attempting to write not page aligned data Erasing old enviroment
Done
Writing enviroment to /dev/mtd1: Invalid argument
Error: can?t write fw_env to flash

Quoted 2 lines

What?s wrong ????

I think the problem is that the fw_setenv so far only supports NOR flash. Environment in NAND is implemented slightly different, especially it doesn't (and can't) invalidate the former valid environment after the updated one was written successfully. So I'm afraid you will have to update this tool to support NAND.

Best regards

Markus Klotzbuecher

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de

#10 lore raw
Quoted 4 lines · Manuel Sahm

but why is there a error concerning NAND flashs if only NOR flashs are supported ?

"nand_write: attempting to write not page aligned data"

Of course NAND is supported by the kernel. This is why it almost works :-) The error is caused because the tool tries to write a single byte using the character device /dev/mtd1 which is obviously not allowed. You can (probably) get rid of it if you use the block device /dev/mtdblock1 in your config file. But the fw_setenv tool of course still doesn't know about the different meanings of the NAND environment header fields.

Best regards

Markus Klotzbuecher

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de

#11 lore raw
In reply to Manuel Sahm
Quoted 5 lines · In message <[email protected]> you wrote:

I took the U-Boot version 1.3.2; now I am able to generate the make env -> fw_printenv utility.

I copy the jw_printenv binary and rename it to fw_setenv.

...

Quoted 1 line

I want to access a NAND flash. [Pagesize = 0x800; ERASEBLOCKSIZE=0x20000]

...

Quoted 1 line

Is this correct ?

No. the fw_env tools are written with NOR flash support in mind. Don't expect this to work unchanged on NAND flash.

Best regards,

Wolfgang Denk

Signature · 7 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
Es ist offensichtlich, dass das menschliche Gehirn wie  ein  Computer
funktioniert.  Da  es  keine  dummen Computer gibt, gibt es also auch
keine dummen Menschen. Nur ein paar Leute, die unter DOS laufen.
                                                       -- <unbekannt>
#12 lore raw

Hello,

I try to modify the env toll for accessing nand flash.

My problem the structure of the enviroment:
If I understand:
4 byte crc; 1 byte flags, 0x20000-5 byte data.

The Enviroment has a size of 0x20000 bytes. There is a redundant enviroment too.(same size)

The CRC is over the data bytes,( not the flags byte included) , right ??

What about the flag byte, which values should I have to write here ?

Thank you very much

Manuel Sahm

Quoted 24 lines · Wolfgang Denk
Quoted 5 lines · In message <[email protected]> you wrote:

I took the U-Boot version 1.3.2; now I am able to generate the make env -> fw_printenv utility.

I copy the jw_printenv binary and rename it to fw_setenv.

...

Quoted 2 lines

I want to access a NAND flash. [Pagesize = 0x800; ERASEBLOCKSIZE=0x20000]

...

Quoted 2 lines

Is this correct ?

No. the fw_env tools are written with NOR flash support in mind. Don't expect this to work unchanged on NAND flash.

Best regards,

Wolfgang Denk

Signature · 32 lines
Freundliche Gr??e / Best regards 

Manuel Sahm	

Research & Development

FEIG ELECTRONIC GmbH
Lange Stra?e 4
35781 Weilburg
Germany
 
Tel.:  +49 (0)6471-3109.492
Fax.:  +49 (0)6471-3109.99
email: manuel.sahm at feig.de
internet: http://www.feig.de

------------------------------------------------------------------------
Amtsgericht Limburg HRB 3178
Gesch?ftsf?hrer: Dipl.-Ing. Wolfgang Feig
------------------------------------------------------------------------

------------------------------------------------------------------------
Diese Email (eingeschlossen die Anhaenge) unterliegt Urheberrecht, die
Informationen sind vertraulich und rechtswirksam privilegiert. Der
Gebrauch dieser Email oder der Anhaenge von einem anderen als den
Adressaten ist nicht gestattet und unrechtmaessig.

This email (including any attachments) is subject to copyright, the
information in it is confidential, and it is legally privileged. Use of
this email or of any information in it other than by the addressee is
unauthorised and unlawful.
------------------------------------------------------------------------
#13 lore raw

Dear Manuel,

Quoted 4 lines · in message <[email protected]> you wrote:

My problem the structure of the enviroment:
If I understand:
4 byte crc; 1 byte flags, 0x20000-5 byte data.

Correct - the flag byte is only present if you use redundant environment.

Quoted 1 line

The CRC is over the data bytes,( not the flags byte included) , right ??

Correct. That's because the flasg byte indicates the state of the environment copy (current -> bit = 1, or obsolete -> bit = 0). It relies on the feature of NOR flash that you can always program '1' bits to '0', even single bits in a single byte.

Quoted 1 line

What about the flag byte, which values should I have to write here ?

See above. But you might have problems doing such a thing on NAND storage.

Best regards,

Wolfgang Denk

Signature · 4 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
I have a very small mind and must live with it.    -- Edsger Dijkstra
#14 lore raw

Hello,

how does uboot handle this flag byte ? (i I use redundant nand)

What initial value must this flag have?
Same value for enviroment1 and enviroment2 ?

If I make a "saveenv" which env. is used, and what values are then written to the NAND flash to set it as aktiv/deactive ?

For example:

In Linux I want to write my own Enviroment to the redundant Env: What must be the value of the flag byte to set this redundant enviroment actik, so that UBoot will use this one ?
And: Which value do I have to write tho the other "old" enviroment in NAND flash, so that this one becomes deactive ?

Thank you very much

Manuel Sahm

Quoted 33 lines · Wolfgang Denk

Dear Manuel,

Quoted 4 lines · in message <[email protected]> you wrote:

My problem the structure of the enviroment:
If I understand:
4 byte crc; 1 byte flags, 0x20000-5 byte data.

Correct - the flag byte is only present if you use redundant environment.

Quoted 2 lines

The CRC is over the data bytes,( not the flags byte included) , right ??

Correct. That's because the flasg byte indicates the state of the environment copy (current -> bit = 1, or obsolete -> bit = 0). It relies on the feature of NOR flash that you can always program '1' bits to '0', even single bits in a single byte.

Quoted 2 lines

What about the flag byte, which values should I have to write here ?

See above. But you might have problems doing such a thing on NAND storage.

Best regards,

Wolfgang Denk

Signature · 32 lines
Freundliche Gr??e / Best regards 

Manuel Sahm	

Research & Development

FEIG ELECTRONIC GmbH
Lange Stra?e 4
35781 Weilburg
Germany
 
Tel.:  +49 (0)6471-3109.492
Fax.:  +49 (0)6471-3109.99
email: manuel.sahm at feig.de
internet: http://www.feig.de

------------------------------------------------------------------------
Amtsgericht Limburg HRB 3178
Gesch?ftsf?hrer: Dipl.-Ing. Wolfgang Feig
------------------------------------------------------------------------

------------------------------------------------------------------------
Diese Email (eingeschlossen die Anhaenge) unterliegt Urheberrecht, die
Informationen sind vertraulich und rechtswirksam privilegiert. Der
Gebrauch dieser Email oder der Anhaenge von einem anderen als den
Adressaten ist nicht gestattet und unrechtmaessig.

This email (including any attachments) is subject to copyright, the
information in it is confidential, and it is legally privileged. Use of
this email or of any information in it other than by the addressee is
unauthorised and unlawful.
------------------------------------------------------------------------
#15 lore raw
Quoted 2 lines · In message <[email protected]> you wrote:

how does uboot handle this flag byte ? (i I use redundant nand)

I already answered that. See my previous message.

Quoted 2 lines

What initial value must this flag have?
Same value for enviroment1 and enviroment2 ?

No. Please see my previous mesage, and the code.

Quoted 1 line

If I make a "saveenv" which env. is used, and what values are then

See the code.

Quoted 2 lines

And: Which value do I have to write tho the other "old" enviroment in NAND flash, so that this one becomes deactive ?

RTFS...

Best regards,

Wolfgang Denk

Signature · 4 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
Old programmers never die, they just branch to a new address.
#16 lore raw
In reply to Manuel Sahm
Quoted 1 line · Manuel Sahm

how does uboot handle this flag byte ? (i I use redundant nand)

As you can't invalidate the old NAND environment as you can with NOR flash, counters are used instead. So for NAND, the flag byte is a counter which gets incremented for each write. This means the environment with the flag containing the larger value is the valid one, except for the case when the counter overflows and the valid environment flag holds the value 0 and the former one 255.

Actually it would make sense to use this technique for NOR flash identically, as it would avoid one write access to the flash.

Check out common/env_nand.c for details.

Best regards

Markus Klotzbuecher

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de