xref: /rk3399_rockchip-uboot/tools/env/README (revision 1c4ea78aa7ca53fa5b1d09753fea35908922ce55)
16aff3115Swdenk
26aff3115SwdenkThis is a demo implementation of a Linux command line tool to access
36aff3115Swdenkthe U-Boot's environment variables.
46aff3115Swdenk
556c17698SLuca CeresoliIn the current version, there is an issue in cross-compilation.
656c17698SLuca CeresoliIn order to cross-compile fw_printenv, run
756c17698SLuca Ceresoli    make HOSTCC=<your CC cross-compiler> env
856c17698SLuca Ceresoliin the root directory of the U-Boot distribution. For example,
956c17698SLuca Ceresoli    make HOSTCC=arm-linux-gcc env
1056c17698SLuca Ceresoli
11d0fb80c3SwdenkFor the run-time utiltity configuration uncomment the line
12d0fb80c3Swdenk#define CONFIG_FILE  "/etc/fw_env.config"
13d0fb80c3Swdenkin fw_env.h.
14d0fb80c3Swdenk
156de66b35SMarkus KlotzbücherFor building against older versions of the MTD headers (meaning before
166de66b35SMarkus Klotzbücherv2.6.8-rc1) it is required to pass the argument "MTD_VERSION=old" to
176de66b35SMarkus Klotzbüchermake.
186de66b35SMarkus Klotzbücher
19d0fb80c3SwdenkSee comments in the fw_env.config file for definitions for the
20d0fb80c3Swdenkparticular board.
21d0fb80c3Swdenk
22d0fb80c3SwdenkConfiguration can also be done via #defines in the fw_env.h file. The
236aff3115Swdenkfollowing lines are relevant:
246aff3115Swdenk
256aff3115Swdenk#define HAVE_REDUND	/* For systems with 2 env sectors */
266aff3115Swdenk#define DEVICE1_NAME	"/dev/mtd1"
276aff3115Swdenk#define DEVICE2_NAME	"/dev/mtd2"
28d0fb80c3Swdenk#define DEVICE1_OFFSET    0x0000
296aff3115Swdenk#define ENV1_SIZE         0x4000
306aff3115Swdenk#define DEVICE1_ESIZE     0x4000
3156086921SGuennadi Liakhovetski#define DEVICE1_ENVSECTORS     2
32d0fb80c3Swdenk#define DEVICE2_OFFSET    0x0000
336aff3115Swdenk#define ENV2_SIZE         0x4000
346aff3115Swdenk#define DEVICE2_ESIZE     0x4000
3556086921SGuennadi Liakhovetski#define DEVICE2_ENVSECTORS     2
366aff3115Swdenk
376aff3115SwdenkUn-define HAVE_REDUND, if you want to use the utlities on a system
38d0fb80c3Swdenkthat does not have support for redundant environment enabled.
39d0fb80c3SwdenkIf HAVE_REDUND is undefined, DEVICE2_NAME is ignored,
40d0fb80c3Swdenkas is ENV2_SIZE and DEVICE2_ESIZE.
41d0fb80c3Swdenk
42d0fb80c3SwdenkThe DEVICEx_NAME constants define which MTD character devices are to
43d0fb80c3Swdenkbe used to access the environment.
44d0fb80c3Swdenk
45d0fb80c3SwdenkThe DEVICEx_OFFSET constants define the environment offset within the
46d0fb80c3SwdenkMTD character device.
47d0fb80c3Swdenk
48d0fb80c3SwdenkENVx_SIZE defines the size in bytes taken by the environment, which
49d0fb80c3Swdenkmay be less then flash sector size, if the environment takes less
50d0fb80c3Swdenkthen 1 sector.
51d0fb80c3Swdenk
526aff3115SwdenkDEVICEx_ESIZE defines the size of the first sector in the flash
53d0fb80c3Swdenkpartition where the environment resides.
5456086921SGuennadi Liakhovetski
5556086921SGuennadi LiakhovetskiDEVICEx_ENVSECTORS defines the number of sectors that may be used for
5656086921SGuennadi Liakhovetskithis environment instance. On NAND this is used to limit the range
5756086921SGuennadi Liakhovetskiwithin which bad blocks are skipped, on NOR it is not used.
58*1c4ea78aSJoe Hershberger
59*1c4ea78aSJoe HershbergerTo prevent losing changes to the environment and to prevent confusing the MTD
60*1c4ea78aSJoe Hershbergerdrivers, a lock file at /var/lock/fw_printenv.lock is used to serialize access
61*1c4ea78aSJoe Hershbergerto the environment.
62