Using U-Boot Environment Print

 

U-Boot makes use of the so-called environment variables to define various aspects of the target functionality. On the i.MX 6ULL SOM, the U-Boot environment is stored in the on-module NAND Flash and is persistent across power or reset cycles. Parameters defined by the U-Boot environment variables include: target IP address, target MAC address, location in RAM where a Linux bootable image will be loaded, and many others.

To manipulate the U-Boot environment the following commands are used:

  • printenv <var> - print the value of the variable var. Without arguments, prints all environment variables:
  • IMX6ULL-SOM U-Boot > printenv
    addip=setenv bootargs ${bootargs} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}:eth0:off  fec_mac=${ethaddr}
    args=run args_quiet
    ...
    Environment size: 2040/65531 bytes

  • setenv <var> <val> - set the variable var to the value val:
  • IMX6ULL-SOM U-Boot > setenv image vlad/rootfs.uImage
    IMX6ULL-SOM U-Boot >

    Running setenv <var> will unset (undefine) a specified U-Boot variable, so it won't be shown as available next time you run printenv.

  • saveenv - save the up-to-date U-Boot environment, possibly updated using setenv commands, into internal Flash. Running saveenv makes sure that any updates you have made to the U-Boot environment are persistent across power cycles and resets. If you don't run saveenv, any updates you may have made to the U-Boot environment will be lost on next reboot.
  • IMX6ULL-SOM U-Boot > saveenv
    Saving Environment to NAND...
    Erasing redundant NAND...
    Erasing at 0x3a0000 -- 100% complete.
    Writing to redundant NAND... OK
    IMX6ULL-SOM U-Boot >