14.3.27. How can I access U-Boot environment variables in Linux?

Question:
I would like to access U-Boot's environment variables from my Linux application. Is this possible?

Answer:
Yes, you can. The environment variables must be stored in flash memory, and your Linux kernel must support flash access through the MTD layer. In the U-Boot source tree you can find the environment tools in the directory tools/env, which can be built with command:

make env

For building against older versions of the MTD headers (meaning before v2.6.8-rc1) it is required to pass the argument "MTD_VERSION=old" to make:

make MTD_VERSION=old env

The resulting binary is called fw_printenv, but actually includes support for setting environment variables too. To achieve this, the binary behaves according to the name it is invoked as, so you will have to create a link called fw_setenv to fw_printenv.

These tools work exactly like the U-Boot commands printenv resp. setenv You can either build these tools with a fixed configuration selected at compile time, or you can configure the tools using the /etc/fw_env.config configuration file in your target root filesystem.

[링크 : http://www.denx.de/wiki/view/DULG/HowCanIAccessUBootEnvironmentVariablesInLinux]

2010.03.11 추가
간단하게 말하자면 eboot 소스트리에서
u-boot/tools/env 에서
fw_env를 컴파일 하게 되면
fw_setenv
fw_getenv 파일이 생성된다. (물론 하나는 심볼릭 링크이다)

2009/07/18 - [프로그램 사용/u-boot] - U-Boot 환경변수 읽어오기 (u-boot environment variable)

Posted by 구차니

댓글을 달아 주세요