U-Boot Overview

From wiki.emacinc.com
Jump to: navigation, search
TODO: {{#todo:Complete;(12-31-13-11:30->MG+);(12.31.13:11:52->KY+);(03.06.14-15:25->BS-);(04.11.14-14:45->BS+)(11.18.2015-16:30->MD+)|Michael Welling|oe 4,oe 5,mw,mg,Complete,ky,bs}}

Das U-Boot is the bootloader used on the majority of EMAC's ARM-based systems. It is loaded by the processor boot-ROM or low-level bootstrap code and performs device initialization followed by loading and starting the OS. EMAC has made modifications to U-Boot to add additional features when necessary. While generally used to load Linux, EMAC also uses U-Boot to load Windows CE and other operating systems. This page provides an introduction to U-Boot and common commands. Complete U-Boot documentation can be found at http://www.denx.de/wiki/U-Boot/WebHome

Accessing the U-Boot Console

By default, U-Boot is set up to automatically boot the OS after a set timeout. The following steps will interrupt the boot process and access the U-Boot prompt.

  1. Configure a serial connection with the target board using the settings specified for the hardware. Refer to the Serial Connections page or other documentation for more information.
  2. After a serial connection has been established, reboot the board.
  3. When initial boot messages are printed to the serial terminal, press Enter in the serial terminal application. This should bring up the U-Boot prompt as seen below:
  4. U-Boot 2009.06-rc1-svn1357 (Jul 08 2010 - 13:31:57)
    
    EMAC Inc. SOM-9M10/G45M
    
    DRAM:  128 MB
    NAND:  256 MiB
    DataFlash:AT45DB321
    Nb pages:   8192
    Page Size:    528
    Size= 4325376 bytes
    Logical address: 0xC0000000
    Area 0: C0000000 to C00041FF (RO) Bootstrap
    Area 1: C0004200 to C00083FF      Environment
    Area 2: C0008400 to C0041FFF (RO) U-Boot
    Area 3: C0042000 to C0251FFF      Kernel
    Area 4: C0252000 to C041FFFF      FS
    In:    serial
    Out:   serial
    Err:   serial
    Net:   macb0
    macb0: Starting autonegotiation...
    macb0: Autonegotiation complete
    macb0: link up, 100Mbps full-duplex (lpa: 0x45e1)
    Hit any key to stop autoboot:  0
    U-Boot>
    
  5. U-Boot commands may be entered at this prompt. To see all available commands, type help. Individual command help can be accessed by passing the command name as an argument to the help command. Available commands may differ between systems depending on applicable features.

The U-Boot Environment

The U-Boot environment is stored in a pre-determined area of non-volatile storage. This is generally the same device that stores the U-Boot image and Linux Kernel. On systems that use raw NAND flash as the primary storage device, there is generally a secondary storage device used for low-level boot images such as U-Boot, the U-Boot environment, and the Linux kernel due to the complexities of bad-block handling with NAND flash. Devices using NOR flash typically use a portion of the NOR flash to store the bootloader and kernel. The flinfo command can provide an idea of the storage layout on the device, see below for an example:

U-Boot> flinfo
DataFlash:AT45DB321
Nb pages:   8192
Page Size:    528
Size= 4325376 bytes
Logical address: 0xC0000000
Area 0: C0000000 to C00041FF (RO) Bootstrap
Area 1: C0004200 to C00083FF      Environment
Area 2: C0008400 to C0041FFF (RO) U-Boot
Area 3: C0042000 to C0251FFF      Kernel
Area 4: C0252000 to C041FFFF      FS

Standard Environment Variables

U-Boot uses a set of environmental variables to control the operation of the system. There are standard variables that are used for specific purposes by the system. The user can also add and combine variables to customize the system operation. The printenv command is used to view the current environment, as shown below:

U-Boot> printenv
baudrate=115200
stdin=serial
stdout=serial
stderr=serial
ethact=macb0
ethaddr=00:50:C2:C9:2B:D6
bootdelay=1
bootargs=console=ttyS0,115200 root=/dev/mtdblock0 mtdparts=atmel_nand:128M(root),-(aux) ro rootfstype=jffs2
bootcmd=cp.b 0xC0042000 0x70000000 0x210000; bootm 0x70000000
kernel_name=uImage-2.6.30
rootfs_name=rootfs.jffs2
filesize=130B194
fileaddr=70000000
ipaddr=10.0.2.24
serverip=10.0.2.60

Environment size: 771/16892 bytes

Table 1 below defines many of the standard variables shown above.

Variable Name Purpose
buadrate Serial console baud rate
stdin The device to use for the console standard input
stdout The device to use for the console standard output
stderr The device to use for the console standard error outout
ethact Defines the Ethernet device
bootdelay The number of seconds to wait after loading before running the command stored in bootcmd
bootargs Kernel command line passed to Linux on boot
bootcmd Commands to run to boot the system. This is generally used to load and boot the OS.
filesize Automatically set to the size of the last file loaded on the system
fileaddr Automatically set to the logical address used for the last file loaded to the system
ipaddr The static IP address to use for network communications
serverip The IP address of the TFTP server on the local network to use for file transfer

Accessing Variables

To access the value of a variable, use the variable name enclosed in ${}. For example, printenv ${bootcmd} will print the current value of the bootcmd variable.

Setting Variables

The setenv command is used to set the value of a new or existing variable. For example, the following command will set the ipaddr variable to a value of 192.168.2.1:

U-Boot> setenv ipaddr 192.168.2.1

When U-Boot loads, it loads the current environment from flash into RAM. Using setenv only changes the volatile copy of the environment but does not commit the change to flash. If a change needs to be committed to non-volatile memory, the saveenv command must be used to save the current environment. This will allow changes to be preserved for the next time that U-Boot is loaded.

Important Variables

Two of the U-Boot variables need special attention as they effect the Linux kernel boot process. These variables, bootargs and bootcmd, are described in detail in the section below.

bootargs

The bootargs variable contains parameters used by the Linux kernel during boot. It specifies the boot partition, serial console for boot messages, and other possible boot parameters.

For example, here is the bootargs string on the SoM-9G45:

bootargs=console=ttyS0,115200 mtdparts=atmel_nand:128M(root),-(aux) root=/dev/mtdblock0 rootfstype=jffs2 ro video=LG

Everything after the first equals sign is contained within the bootargs variable. The following explains each of the variables in the bootargs:

Table 1: bootargs parameters
Parameter Description
console The UART device node and baud rate for the boot messages.
mtdparts Enumerates flash partition. The name and size for each partition is specified.
root Sets which MTD partition to mount as the root file system.
rootfstype The file system formatting used on the root partition.
ro Mounts the root partition read-only.
video Sets the video mode for the display.
Table 2: video parameter values
Value Description
LG 4.3" LCD distributed with the SoM-200, SoM-210, and SoM-212 carriers.
PRIMEVIEW 7" LCD distributed with the SoM-250ES (PPC-E7+)
AMPIRE 10" LCD distributed with the SoM-250ES (PPC-E10)

bootcmd

The bootcmd variable is a set of instructions used to relocate and boot the Linux kernel. This command will vary from machine to machine based on Flash and RAM types.

Further Information

Where to Go Next