Specifications
device tree source file structure, etc.).
7.3. Passing Kernel Arguments
In nearly all cases, you will want to pass additional information to the Linux kernel; for instance, information
about the root device or network configuration.
In U-Boot, this is supported using the bootargs environment variable. Its contents are automatically passed
to the Linux kernel as boot arguments (or "command line" arguments). This allows the use of the same Linux
kernel image in a wide range of configurations. For instance, by just changing the contents of the bootargs
variable you can use the very same Linux kernel image to boot with an initrd ramdisk image, with a root
filesystem over NFS, with a CompactFlash disk or from a flash filesystem.
As one example, to boot the Linux kernel image at address 0x42000000 using the initrd ramdisk image at
address 0x44100000 as root filesystem, and with the flattened device tree blob at address 0x41000000, you
can use the following commands:
=> setenv bootargs root=/dev/ram rw
=> bootm 0x42000000 0x44100000 0x41000000
To boot the same kernel image with a root filesystem over NFS, the following command sequence can be
used. This example assumes that your NFS server has the IP address "192.168.1.1" and exports the directory
"/opt/eldk-5.2/armv5te/rootfs" as root filesystem for the target. The target has been assigned the IP address
"192.168.20.38" and the hostname "m28". A netmask of "255.255.0.0" is used:
=> setenv bootargs root=/dev/nfs rw nfsroot=192.168.1.1:/opt/eldk-5.2/armv5te/rootfs ip=192.168.20.38:192.168.1.1:192.168.1.1:255.255.0.0:m28::off
=> bootm 0x42000000 - 0x41000000
Please see also the files Documentation/initrd.txt and Documentation/nfsroot.txt in your
Linux kernel source directory for more information about which options can be passed to the Linux kernel.
Note: Once your system is up and running, if you have a simple shell login, you can normally examine the
boot arguments that were used by the kernel for the most recent boot with the command:
$ cat /proc/cmdline
7.4. Boot Arguments Unleashed
Passing command line arguments to the Linux kernel allows for very flexible and efficient configuration
which is especially important in Embedded Systems. It is somewhat strange that these features are nearly
undocumented everywhere else. One reason for that is certainly the very limited capabilities of other boot
loaders.
It is especially U-Boot's capability to easily define, store, and use environment variables that makes it such a
powerful tool in this area. In the examples above we have already seen how we can use for instance the root
and ip boot arguments to pass information about the root filesystem or network configuration. The ip
argument is not only useful in configurations with root filesystem over NFS; if the Linux kernel has the
CONFIG_IP_PNP configuration enabled (IP kernel level autoconfiguration), this can be used to enable
automatic configuration of IP addresses of devices and of the routing table during kernel boot, based on either
information supplied on the kernel command line or by BOOTP or RARP protocols.
7.4. Boot Arguments Unleashed 88