Search by Tags

U-Boot fw-utils


Subscribe for this article updates

The U-Boot fw-utils contain the fw_printenv and fw_setenv utilities to read and write U-Boot environment variables from Linux user space.

Basic Usage


One can set any U-Boot environment variable from Linux user space with fw_setenv:

root@apalis-imx6:~# fw_setenv [OPTIONS]... [VARIABLE]...

After the variables are updated, the system cannot apply them on-the-fly. You need to reboot so U-Boot can read the updated variables


root@apalis-imx6:~# fw_setenv fdt_file 'imx6q-apalis-ixora-v1.1.dtb'

fw_setenv also supports a script file as input to change multiple U-Boot environment variables at once:

root@apalis-imx6:~# fw_setenv --script script.txt

Script File Example

The script file syntax for changing multiple U-Boot environment variables at once from Linux user space is:

key [space] value

A couple of useful tips to write your own script:

  • Lines starting with '#' are treated as comments
  • Variables without values will be deleted
  • Any number of spaces are allowed between key and value
  • A space inside of the value is treated as part of the value itself
vidargs 'video=mxcfb0:dev=hdmi,1920x1080M@60,if=RGB24' fdt_file 'imx6q-apalis-ixora.dtb'


One can read a U-Boot environment variable from Linux user space with fw_printenv:

root@apalis-imx6:~# fw_printenv [OPTIONS] [VARIABLE]


root@apalis-imx6:~# fw_printenv fdt_file

or read all of them at once:

root@apalis-imx6:~# fw_printenv 

Advanced Options

U-Boot fw-utils has options that can be used in both of its utilities such as:

-h, --help           print help
-c, --config         configuration file, default:/etc/fw_env.config
-n, --noheader       do not repeat variable name in output
-l, --lock           lock node, default:/var/lock

Note: Since Toradex Linux BSP V2.8, one can display the source version of fw-utils with -v or --version option.

Customize fw-utils Configuration

The U-Boot fw-utils read and write the U-Boot environment variables by accessing the flash location in the partition where the U-Boot environment is stored, pointed in the configuration file /etc/fw_env.config. This file stores different information depending on the exact Toradex module's flash memory type.

Note: One can verify the flash memory type used on the module in its datasheet. To do so, visit Toradex Products page,select your Toradex module and check its datasheet.


In the eMMC flash memory type, the U-Boot environment is stored in at the end of the first eMMC boot partition, just in front of the config block, that occupies the last sector. The fw-utils reads the block device name, device offset (config block plus U-Boot environment size ) and U-Boot environment size.


In the NAND flash memory type, it is possible to configure redundant U-Boot environment adding more than one entry in the fw-utils configuration file located at /etc/fw_env.config. Each entry must have the MTD device name, device offset, U-Boot environment size, flash sector size and number of sectors.