xref: /OK3568_Linux_fs/u-boot/tools/env/README (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun
2*4882a593SmuzhiyunThis is a demo implementation of a Linux command line tool to access
3*4882a593Smuzhiyunthe U-Boot's environment variables.
4*4882a593Smuzhiyun
5*4882a593SmuzhiyunIn order to cross-compile fw_printenv, run
6*4882a593Smuzhiyun    make CROSS_COMPILE=<your cross-compiler prefix> envtools
7*4882a593Smuzhiyunin the root directory of the U-Boot distribution. For example,
8*4882a593Smuzhiyun    make CROSS_COMPILE=arm-linux- envtools
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunYou should then create a symlink from fw_setenv to fw_printenv. They use
11*4882a593Smuzhiyunthe same program and its function depends on its basename.
12*4882a593Smuzhiyun
13*4882a593SmuzhiyunFor the run-time utility configuration uncomment the line
14*4882a593Smuzhiyun#define CONFIG_FILE  "/etc/fw_env.config"
15*4882a593Smuzhiyunin fw_env.h.
16*4882a593Smuzhiyun
17*4882a593SmuzhiyunFor building against older versions of the MTD headers (meaning before
18*4882a593Smuzhiyunv2.6.8-rc1) it is required to pass the argument "MTD_VERSION=old" to
19*4882a593Smuzhiyunmake.
20*4882a593Smuzhiyun
21*4882a593SmuzhiyunSee comments in the fw_env.config file for definitions for the
22*4882a593Smuzhiyunparticular board.
23*4882a593Smuzhiyun
24*4882a593SmuzhiyunConfiguration can also be done via #defines in the fw_env.h file. The
25*4882a593Smuzhiyunfollowing lines are relevant:
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun#define HAVE_REDUND	/* For systems with 2 env sectors */
28*4882a593Smuzhiyun#define DEVICE1_NAME	"/dev/mtd1"
29*4882a593Smuzhiyun#define DEVICE2_NAME	"/dev/mtd2"
30*4882a593Smuzhiyun#define DEVICE1_OFFSET    0x0000
31*4882a593Smuzhiyun#define ENV1_SIZE         0x4000
32*4882a593Smuzhiyun#define DEVICE1_ESIZE     0x4000
33*4882a593Smuzhiyun#define DEVICE1_ENVSECTORS     2
34*4882a593Smuzhiyun#define DEVICE2_OFFSET    0x0000
35*4882a593Smuzhiyun#define ENV2_SIZE         0x4000
36*4882a593Smuzhiyun#define DEVICE2_ESIZE     0x4000
37*4882a593Smuzhiyun#define DEVICE2_ENVSECTORS     2
38*4882a593Smuzhiyun
39*4882a593SmuzhiyunUn-define HAVE_REDUND, if you want to use the utilities on a system
40*4882a593Smuzhiyunthat does not have support for redundant environment enabled.
41*4882a593SmuzhiyunIf HAVE_REDUND is undefined, DEVICE2_NAME is ignored,
42*4882a593Smuzhiyunas is ENV2_SIZE and DEVICE2_ESIZE.
43*4882a593Smuzhiyun
44*4882a593SmuzhiyunThe DEVICEx_NAME constants define which MTD character devices are to
45*4882a593Smuzhiyunbe used to access the environment.
46*4882a593Smuzhiyun
47*4882a593SmuzhiyunThe DEVICEx_OFFSET constants define the environment offset within the
48*4882a593SmuzhiyunMTD character device.
49*4882a593Smuzhiyun
50*4882a593SmuzhiyunENVx_SIZE defines the size in bytes taken by the environment, which
51*4882a593Smuzhiyunmay be less then flash sector size, if the environment takes less
52*4882a593Smuzhiyunthen 1 sector.
53*4882a593Smuzhiyun
54*4882a593SmuzhiyunDEVICEx_ESIZE defines the size of the first sector in the flash
55*4882a593Smuzhiyunpartition where the environment resides.
56*4882a593Smuzhiyun
57*4882a593SmuzhiyunDEVICEx_ENVSECTORS defines the number of sectors that may be used for
58*4882a593Smuzhiyunthis environment instance. On NAND this is used to limit the range
59*4882a593Smuzhiyunwithin which bad blocks are skipped, on NOR it is not used.
60*4882a593Smuzhiyun
61*4882a593SmuzhiyunTo prevent losing changes to the environment and to prevent confusing the MTD
62*4882a593Smuzhiyundrivers, a lock file at /var/lock/fw_printenv.lock is used to serialize access
63*4882a593Smuzhiyunto the environment.
64