U-boot environment: Difference between revisions

From embeddedTS Manuals
(Created page with "On the SPI flash U-boot has 2 separate binaries. The u-boot binary itself and U-boot's environment. Our default build has 8KB of environment which can be used for variables ...")
 
(Grammar fixups)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
On the SPI flash U-boot has 2 separate binaries.  The u-boot binary itself and U-boot's environment.  Our default build has 8KB of environment which can be used for variables and scripts to control booting your operating systemThese commands are relevant to manipulating the environment:
The eMMC flash contains both the U-Boot executable binary and U-Boot environment.  Our default build has 2 MiB of environment space which can be used for variables and boot scripts.  The following commands are examples of how to manipulate the U-Boot environment:


<source lang=bash>
<source lang=bash>
Line 14: Line 14:
env run hellocmd;
env run hellocmd;


# Commit env changes to the spi flash
# Commit environment changes to the SPI flash
# Otherwise changes are lost
# Otherwise changes are lost
env save
env save


# Restore env to default
# Restore environment to default
env default -a
env default -a


Line 24: Line 24:
env delete emmcboot
env delete emmcboot
</source>
</source>
For a production environment the best option for setting depends on the number of units.  For a smaller number of units it may be simplest to update any required commands manually.  For example, a custom cmdline when booting to eMMC may look like this:
<source lang=bash>
env set bootdelay 0;
env set bootcmd 'load mmc 1:1 ${fdtaddr} /boot/imx6q-ts4900-8390.dtb; load mmc 1:1 ${loadaddr} /boot/uImage; env set bootargs 'console=ttymxc0,115200 debug root=/dev/mmcblk1p1 rootwait rw init=/sbin/init'; bootm ${loadaddr} - ${fdtaddr};'
env save
</source>
If you are blasting many boards you can use a script to automate this.  There are multiple hooks in our default software image.  By default we load and source a script from USB or SD/eMMC if either exist.

Latest revision as of 13:17, 27 September 2018

The eMMC flash contains both the U-Boot executable binary and U-Boot environment. Our default build has 2 MiB of environment space which can be used for variables and boot scripts. The following commands are examples of how to manipulate the U-Boot environment:

# Print all environment variables
env print -a

# Sets the variable bootdelay to 5 seconds
env set bootdelay 5;

# Variables can also contain commands
env set hellocmd 'led red on; echo Hello world; led green on;'

# Execute commands saved in a variable
env run hellocmd;

# Commit environment changes to the SPI flash
# Otherwise changes are lost
env save

# Restore environment to default
env default -a

# Remove a variable
env delete emmcboot