Understanding UBoot Environment Variables

The following is the snapshot of standard U-Boot Environment Variables. 
These environmental variables can be altered according to requirements and preferences
and they in turn alter the way of U-Boot functioning just like the Kernel Environment Variables.
bootargs=console=ttyS2,115200n8 noinitrd rw ubi.mtd=3,4096 root=ubi0:ubifs0 rw rootfstype=ubifs ip=off
bootcmd=nand read 0xc0700000 0x500000 0x300000; bootm 0xc0700000

Now I will brief you about the various environmental variables in U-Boot and how you can tweak them to make desired changes.

1. 'bootdelay' : This variable holds an integer. This integer accounts for the number of seconds   U-Boot will wait before executing the contents of the bootcmd variable.

So if you want to get the u-boot prompt to change some variable or excute some command then you need to press any key before these number of seconds as mentioned.
Set this variable to 0 boot without delay. Be careful: depending on the contents of your bootcmd variable, this can prevent you from entering interactive commands again forever!
Set this variable to -1 to disable autoboot.

2. 'baudrate' : This is an integer that defines the console baud-rate in bps (bits per second). This means it defines the speed with which the board and PC communicate. Only a predefined value of baud-rate can be set according to a list.
    You can try to switch the baud-rate from the U-boot prompt via:

    > setenv baudrate <desired_baudrate_value>

U-Boot will switch the baudrate of the console terminal and wait for a newline which must be entered with the new speed setting. This is to make sure you can actually type at the new speed. If this fails, you have to reset the board (which will operate at the old speed since you were not able to saveenv the new settings.)
    If no "baudrate" variable is defined, the default baudrate of 115200 is used.

3. 'ipaddr' : This variable defines the ip address of the board. Yes this means U-Boot supports network connectivity and operations to some extent.
For example, you can ping other machines in the same network but self-ping, ie pinging the board itself, is not supported. Tftp command will also need this variable value to be set and valid.
It can be set as follows:

    > setenv ipaddr

    Also before pinging or any other network operation you have to set the ethaddr environmental variable which is explained below.

4. 'ethaddr' : This environmental variable holds the MAC address of the first and only ethernet interface (=eth0 in Linux).
This variable can be set only once (usually during manufacturing of the board). U-Boot refuses to delete or overwrite this variable once it has been set.
For more than one interfaces on Linux like eth1, eth2.. set environmental variables like eth1addr, eth2addr....

5. 'serverip and bootfile' : “serverip” holds the ipaddress of the server. This will be used in tftp command. “bootfile” holds the name/path where the image to be fetched from network is stored. U-boot will fetch the $bootfile from the $serverip 's tftpboot directory. So if the uImage lies in any sub-directories please enter the whole path after tftpboot in “bootfile” variable.

For example: If your uImage is in tftpboot->Extra->uImage, then your “bootfile” variable should be “Extra/uImage”

6. 'gatewayip' : This variable holds the ip address of the gateway server of the network.

7. 'bootcmd' : This variable is executed in the autoboot mode. It holds information related to boot up process like from where and how to fetch the uImage, for example via tftp, from NAND, etc.
    According to the location of uImage the bootcmd will change, for example:

    a. tftpboot: > setenv bootcmd 'tftp 0x08700000 uImage; bootm'
    b. MMC boot: > setenv bootcmd 'mmc rescan 0;fatload mmc 0 0xc0700000 uImage_usb;bootm'

    As you can see the bootm command is common. I will write a post on how this command works. For now it just executes the image from RAM.

8. 'bootargs' : This is the most important environmental variable of U-Boot and one which you will tweak more often than the others.
The contents of this variable are passed to the Linux kernel as boot arguments (aka "command line arguments"). These contain various networking, console, baudrate, etc information. From the user space it can be seen by 'cat /proc/cmdline'; these being the kernel command line arguments

    Example bootargs: console=ttyS2,115200n8 noinitrd rw root=/dev/mmcblk0p2 rootfstype=ext3 rw ip=off

I will bifurcate each and every part of the bootargs and show various bootargs from different filesystem types in the next post.

Till then keep embedding !!

No comments:

Post a Comment