xref: /openbmc/u-boot/tools/env/README (revision 7c83aad4dea0e3f5652d9a22fb8b55c6c77eb968)
16aff3115Swdenk
26aff3115SwdenkThis is a demo implementation of a Linux command line tool to access
36aff3115Swdenkthe U-Boot's environment variables.
46aff3115Swdenk
556c17698SLuca CeresoliIn order to cross-compile fw_printenv, run
657332957SSimon Glass    make CROSS_COMPILE=<your cross-compiler prefix> envtools
756c17698SLuca Ceresoliin the root directory of the U-Boot distribution. For example,
857332957SSimon Glass    make CROSS_COMPILE=arm-linux- envtools
956c17698SLuca Ceresoli
1084a42069SSimon GlassYou should then create a symlink from fw_setenv to fw_printenv. They use
1184a42069SSimon Glassthe same program and its function depends on its basename.
1284a42069SSimon Glass
1355011539SRobert P. J. DayFor the run-time utility configuration uncomment the line
14d0fb80c3Swdenk#define CONFIG_FILE  "/etc/fw_env.config"
15d0fb80c3Swdenkin fw_env.h.
16d0fb80c3Swdenk
176de66b35SMarkus KlotzbücherFor building against older versions of the MTD headers (meaning before
186de66b35SMarkus Klotzbücherv2.6.8-rc1) it is required to pass the argument "MTD_VERSION=old" to
196de66b35SMarkus Klotzbüchermake.
206de66b35SMarkus Klotzbücher
21d0fb80c3SwdenkSee comments in the fw_env.config file for definitions for the
22d0fb80c3Swdenkparticular board.
23d0fb80c3Swdenk
24d0fb80c3SwdenkConfiguration can also be done via #defines in the fw_env.h file. The
256aff3115Swdenkfollowing lines are relevant:
266aff3115Swdenk
276aff3115Swdenk#define HAVE_REDUND	/* For systems with 2 env sectors */
286aff3115Swdenk#define DEVICE1_NAME	"/dev/mtd1"
296aff3115Swdenk#define DEVICE2_NAME	"/dev/mtd2"
30d0fb80c3Swdenk#define DEVICE1_OFFSET    0x0000
316aff3115Swdenk#define ENV1_SIZE         0x4000
326aff3115Swdenk#define DEVICE1_ESIZE     0x4000
3356086921SGuennadi Liakhovetski#define DEVICE1_ENVSECTORS     2
34d0fb80c3Swdenk#define DEVICE2_OFFSET    0x0000
356aff3115Swdenk#define ENV2_SIZE         0x4000
366aff3115Swdenk#define DEVICE2_ESIZE     0x4000
3756086921SGuennadi Liakhovetski#define DEVICE2_ENVSECTORS     2
386aff3115Swdenk
3955011539SRobert P. J. DayUn-define HAVE_REDUND, if you want to use the utilities on a system
40d0fb80c3Swdenkthat does not have support for redundant environment enabled.
41d0fb80c3SwdenkIf HAVE_REDUND is undefined, DEVICE2_NAME is ignored,
42d0fb80c3Swdenkas is ENV2_SIZE and DEVICE2_ESIZE.
43d0fb80c3Swdenk
44d0fb80c3SwdenkThe DEVICEx_NAME constants define which MTD character devices are to
45d0fb80c3Swdenkbe used to access the environment.
46d0fb80c3Swdenk
47d0fb80c3SwdenkThe DEVICEx_OFFSET constants define the environment offset within the
48d0fb80c3SwdenkMTD character device.
49d0fb80c3Swdenk
50d0fb80c3SwdenkENVx_SIZE defines the size in bytes taken by the environment, which
51d0fb80c3Swdenkmay be less then flash sector size, if the environment takes less
52d0fb80c3Swdenkthen 1 sector.
53d0fb80c3Swdenk
546aff3115SwdenkDEVICEx_ESIZE defines the size of the first sector in the flash
55d0fb80c3Swdenkpartition where the environment resides.
5656086921SGuennadi Liakhovetski
5756086921SGuennadi LiakhovetskiDEVICEx_ENVSECTORS defines the number of sectors that may be used for
5856086921SGuennadi Liakhovetskithis environment instance. On NAND this is used to limit the range
5956086921SGuennadi Liakhovetskiwithin which bad blocks are skipped, on NOR it is not used.
601c4ea78aSJoe Hershberger
611c4ea78aSJoe HershbergerTo prevent losing changes to the environment and to prevent confusing the MTD
62*7c83aad4SJohn Keepingdrivers, a lock file at /run/fw_printenv.lock is used to serialize access
631c4ea78aSJoe Hershbergerto the environment.
64