Set U Boot Environment - FrankBau/meta-marsboard-bsp GitHub Wiki
U-Boot stores some environment variables permanently in SPI flash. When U-Boot does not find a valid environment in SPI flash, e.g. after a new installation or a flash erase, it uses some built-in defaults. Those defaults are not optimal and may not work (e.g. do not boot Linux from microSD) so it is time for a change. It is possible to make such a change in the U-Boot sources and you are invited to submit a patch for that. Until this happened, we are using a different approach.
The most important environment variables for booting Linux are:
- bootcmd: a sequence of U-Boot commands that load the Linux kernel and a .dtb (Device Tree Blob) file and start the kernel boot.
- bootargs. aka the Linux Kernel Arguments. A set of parameters passed on to the Linux Kernel which are used during boot
- ethaddr: the MAC address of your board passed to Linux
To set up these environment variables, reset the board and press a key quickly such that normal boot is interrupted and you are in a U-Boot shell.
Print the Environment
printenv
This will print the current environment. It is recommended to save the output in a file on your build host in case you have to restore the original environment or parts of it (like ethaddr
, the MAC address).
Clear the Environment
In most cases, this step is optional and might be useful to reduce the complexity of the environment.
However, this step is required, when you have to change the MAC address because U-Boot refuses to change the ethaddr
variable after it was permanently stored.
The following command sequence will erase the part of the SPI flash where U-Boot stores its environment.
Note: The SPI-Flash layout is described in the U-Boot board specific header file check CONFIG_ENV_OFFSET
and CONFIG_ENV_SECT_SIZE
.
sf probe
sf erase 0xC0000 0x2000
Set the New Environment
The first line is only needed if the environment was erased. Replace the question marks by a valid MAC address, e.g. the one you printed out earlier.
setenv ethaddr "00:30:d5:00:10:06"
setenv bootargs "console=ttymxc1,115200 rw root=/dev/mmcblk1p2 rootwait consoleblank=0 ethaddr=$ethaddr"
setenv bootcmd "mmc rescan; fatload mmc 0:1 0x10800000 /zimage; fatload mmc 0:1 0x12000000 /imx6q-marsboard.dtb; bootz 0x10800000 - 0x12000000"
saveenv
boot
The saveenv
command saves your settings permanently in SPI-Flash. If you omit this command, your changes are only effective for the current boot, so you may try out different settings before saving them to flash.
The boot
command requires that a bootable Linux is present on the microSD card.