U_boot bootcmd and bootargs Parameters

Source: Internet
Author: User

Original article: www.cnblogs.com/cornflower/archive/2010/03/27/1698279.html

From: http://linux.chinaunix.net/bbs/archiver/tid-1111568.html

The U-boot environment variables are worth noting: bootcmd and bootargs.
U-bootcmd
As mentioned above, bootcmd is the default command for Automatic startup. Therefore, you can define different configurations and parameter settings in different environments in the current environment, set bootcmd as your frequently used parameter.
U-bootargs
Bootargs is the top priority among environment variables. It can be said that the whole environment variable is set around bootargs. Bootargs has many types. We usually only use several types of bootargs. If you are interested, please refer to this article for details: http://blog.chinaunix.net/u2/79570/showart_1675071.html. Bootargs is very flexible. Different combinations of the kernel and file system have different setting methods. You can even choose not to set bootargs, directly write it to the kernel (this setting can be performed in the Kernel configuration option), which causes difficulties in using bootargs.
The following describes the common bootargs parameters. There are many bootargs types, and new parameters will appear with the development of the kernel, making the settings more flexible and diverse.

A. Root
Used to specify the location of rootfs. common situations include:
Root =/dev/Ram RW
Root =/dev/ram0 RW
Note that the above two settings are common. I have tested them and even root =/dev/ram1 RW and root =/dev/ram2 RW are acceptable, some people on the Internet say that it is not universal in some cases, that is, it must be set to Ram or ram0, but it has not yet been met. Further confirmation is required. You can try it one by one when it fails.

Root =/dev/mtdx RW
Root =/dev/mtdblockx RW
Root =/dev/mtdblock/X RW
Root = 31: 0x

The above items are common in some cases. Of course, it depends on whether your current system supports them. However, MTD is a character device, while mtdblock is a block device, sometimes you try it one by one to check whether the current system supports the above situation, but root =/dev/mtdblockx RW is more common. In addition, if you can directly specify the device name, you can also use the device number of this device.

Root =/dev/nfs
Used when the file system is an NFS-based file system. Of course, after specifying root =/dev/NFS, you also need to specify nfsroot = serverip: nfs_dir, that is, the directory under which the file system exists.

B. rootfstype
This option needs to be used together with the root. Generally, if the root file system is ext2, it doesn't matter if there is such an option, but if it is a file system such as jffs2 and squashfs, rootfstype is required to specify the type of the file system. Otherwise, the root partition cannot be mounted.

C. Console
Console = tty use virtual serial port terminal devices.
Console = TTYs [, options] use a specific serial port. options can be bbbbpnx in this form. BBBB indicates the baud rate of the serial port, and P indicates the parity (never seen before ), N refers to bits.
Console = ttysac [, options.

Depending on your current environment, TTYs is used sometimes and ttysac is used. Some people on the Internet say that this is related to the kernel version. TTYs is used for 2.4 and ttysac is used for 2.6, however, the actual situation is that TTYs is also used in the official documentation, so it should be unrelated to the kernel version. You can view the documentation/serial-console.txt to find the relevant description.

D. mem
Mem = xxm specifies the memory size, not required

E. ramdisk_size
Ramdisk = XXXXX not recommended
Recommended ramdisk_size = XXXXX
Both of the above can tell the ramdisk driver that the size of the created ramdisk is 4 MB by default (8 MB by default for s390). You can view the description of documentation/ramdisk.txt, however, ramdisk = XXXXX has not been mentioned in the new kernel version and is not recommended.

F. initrd, noinitrd
When you do not use ramdisk to start the system, you need to use the noinitrd parameter. However, if you use it, you need to specify initrd = r_addr, size, r_addr to indicate the initrd position in the memory, size indicates the size of initrd.

G. init
Init specifies the first script to run in the system after the kernel is started. Generally, init =/linuxrc, or init =/etc/preinit. The preinit content is generally used to create the console, null device node, run init program, mount some file systems, and so on. Note that many beginners think that init =/linuxrc is a fixed writing method. Otherwise,/linuxrc refers to the linuxrc script under the/directory, which is generally a connection.

H. mtdparts
Mtdparts = fc000000.nor _ FLASH: 1920 K (Linux), 128 K (FDT), 20 m (ramdisk), 4 m (jffs2), 38272 K (user ), 256 K (ENV), 384 K (uboot)
To use this parameter, the MTD driver in the kernel must be supported. For Kernel configuration, choose device drivers ---> memory technology device (MTD) support ---> command line Partition Table parsing.

The mtdparts format is as follows:
Mtdparts = [;
: =: [,]
: = [@ Offset] [] [Ro]
: = Unique ID used in mapping driver/Device
: = Standard Linux memsize or "-" to denote all remaining space
: = (Name)
Therefore, you must follow the following format when using it:
Mtdparts = MTD-ID :@(),@()
Note the following:
A. The MTD-ID must be consistent with the MTD-id of flash on the current platform. Otherwise, the entire mtdparts will become invalid.
B. The size can be set to the actual size (xxm, xxk, XX) or '-', which indicates all the remaining space.
Example:
If the MTD-id of Flash is sa1100, you can set it in the following way:
Mtdparts = sa1100:-→ only one partition
Mtdparts = sa1100: 256 K (armboot) Ro,-(Root) → two partitions
You can view the description in drivers/MTD/cmdlinepart. C.

I. IP
Specify the IP address of the network card after the system starts. If you use an NFS-based file system, you must have this parameter. In other cases, it depends on your preferences. You can set an IP address in either of the following ways:
IP = IP ADDR
IP = ip addr: Server ip addr: Gateway: Netmask: Which netcard: Off
These two methods can be used, but obviously the second method requires a lot of details. Note that in the second method, which netcard refers to the NIC on the Development Board, rather than the NIC on the host.

After talking about several common bootargs types, let's discuss several combinations that I usually use:
1) assume that the file system is ramdisk and is directly in the memory. The bootargs settings should be as follows:
Setenv bootargs 'initrd = 0x32000000, 0xa00000 root =/dev/ram0 console = ttysac0 mem = 64 m init =/linuxrc'

2) Suppose the file system is ramdisk, and in flash, the bootargs settings should be as follows:
Setenv bootargs 'mem = 32 m console = ttys0, 115200 root =/dev/Ram RW init =/linuxrc'
Note that in this case, you should specify the ramdisk address in flash in the bootm command, such as bootm kernel_addr ramdisk_addr (fdt_addr)

3) assume that the file system is of the jffs2 type, and in flash, the bootargs settings should be as follows:
Setenv bootargs 'mem = 32 m console = ttys0, 115200 noinitrd root =/dev/mtdblock2 RW rootfstype = jffs2 init =/linuxrc'

4) if the file system is nfs-based, the bootargs settings should be as follows:
Setenv bootargs 'noinitrd mem = 64 m console = ttysac0 root =/dev/nfs nfsroot = 192.168.0.3:/nfs IP = 192.168.0.5: 192.168.0.3: 192.168.0.3: 255.255.255.0: eth0: off'
Or
Setenv bootargs 'noinitrd mem = 64 m console = ttysac0 root =/dev/nfs nfsroot = 192.168.0.3:/nfs IP = 192.168.0.5'

The above is the combination of several bootargs that we often use. To be honest, bootargs is very flexible, so there are many ways to set it, the specific settings should also be based on the specific circumstances of your platform.

================================================= ============

Make the Development Board automatically mounted to the NFS file system at startup:

Take my Development Board as an example: mini2440 Development Board, supervivi with friendly arm

Param set linux_cmd_line"Noinitrd root =/dev/nfs nfsroot = 192.168.1.131:/nfs/busybox/mini_fs2 IP = 192.168.1.230: 192.168.1.131: 192.168.1.1: 255.255.255.0: eth0: Off init =/linuxrc
Console = ttysac0"

Note: 192.168.1.131 is the NFS server IP address, 192.168.1.230 is the Development Board IP address, 192.168.1.1 is the default gateway, and 255.255.255.0 is the subnet mask.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.