Read SD card content in uboot

Source: Internet
Author: User

1. SD card upgrade command

Mmcinit 0

Fatload MMC 0: 1 0 uzimage. Bin 80000

Fatload MMC 1000000 initrd.gz 580000

Bootm 0


2.
U-boot script

It can be saved as NFS. Script and placed in the root directory of TFTP.

Setenv bootargs mem = 214 m Root =/dev/nfsroot = 10.1.1.2:/home/nfs_android IP = dhcp rw console = ttys0, 115200n8 androidboot. console = ttys0 init =/init lcdid = 1 lpj = 750000

How to load it?

Setenv bootcmd setenv ipaddr 10.1.1.3/; setenv
Serverip 10.1.1.2

/

; Setenv gatewayip
10.1.1.1

/

; Tftpboot 02000000 NFS. Script

/

; Autoscr

Here/; multiple commands form one command.

Here, bootcmd references bootargs.

U-boot allows you to store command sequences in plain text files. Run the mkimage command to convert the file into a script image. The image can be executed using the U-boot command autoscr.

The method for converting to an image file is as follows:

Bash $ mkimage-T script-C none-N 'demo script file'-d
Setenv-commands setenv. img

Image name: Demo script file

Created: Mon Jun 6 13:33:14 2005

Image Type: PowerPC Linux script (uncompressed)

Data size: 1147 bytes = 1.12 kb = 0.00 MB

Load address: 0x00000000

Entry Point: 0x00000000

Contents:

Image 0: 1139 bytes = 1 kb = 0 MB

On the target board, you can use commands such as TFTP for loading like other image files, and then run the command autoscr to execute the image. The method is as follows:

=> TFTP 100000/tftpboot/tqm860l/setenv. img

 

3. tftpboot, bootm, TFTP

Bootm is used to load and start operating system images and file systems. The 1st parameter is the kernel image address, RAM address, or flash Address. The second parameter is an optional initrd image address. At the same time, tell the kernel the size and address of ramdisk.

TFTP is downloaded to the specified address.

Tftpboot is downloaded through the TFTP protocol
Verdana, Geneva; "> Image
. Tftpboot [loadaddress] [filename]


 

Appendix: http://blog.chinaunix.net/u3/94312/showart_1923637.html

U-boot environment variables: bootcmd and bootargs

U-bootcmd

As mentioned above, bootcmd is the default command for Automatic startup. Therefore, you can define different configurations and set parameters in different environments in the current environment, and then set bootcmd to your
This parameter is commonly used.
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.
Is to use only a few, interested can look at this article said very full: 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 writes it to the kernel (this setting can be performed in the Kernel configuration options), which leads to 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 and even root =/dev/ram1.
RW and root =/dev/ram2
RW is also acceptable. Some people on the Internet say it is not universal in some cases, that is, it must be set to Ram or ram0, but it has not yet been met, and further confirmation is required, you can try it one by one when it doesn't work.
Try.

Root =/dev/mtdx RW
Root =/dev/mtdblockx RW

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

The above are general in some cases. Of course it depends on you.
Is the current system supported? However, MTD is a character device, while mtdblock is a block device. Sometimes you try to determine whether the current system supports the above conditions, 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, indicating that the file system exists under the directory of the host.

B. rootfstype
 

This option needs to be used with the root user. Generally, if the root file system is ext2, it doesn't matter if there is any such option, but if it is jffs2, squashfs and other file systems
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]
For a specific serial port, options can be bbbbpnx. BBBB indicates the baud rate of the serial port, P indicates the parity (never used before), and N indicates the bits.
Console = ttysac [, options]
Same as above.

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 and 2.4 are used for 2.6.
Ttysac, but 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 documentation/serial-
Console.txt find the description.

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

E.
Ramdisk_size
Ramdisk = XXXXX not recommended
Ramdisk_size = XXXXX
Recommendation
Both of the above can tell ramdisk
The size of the created ramdisk. The default value is 4 MB (the default value is 8 MB for s390). You can check documentation/ramdisk.txt to find the related
But ramdisk = XXXXX has not been mentioned in the new kernel version and is not recommended.

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

G. init
Init
Specify the first script to run in the system after the kernel is started. Generally, init =/linuxrc,
Or init =/etc/preinit, the content of preinit is generally to create a console, null device node, run the 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)
Yes
If you want this parameter to work, the MTD driver in the kernel must be supported, that is, You must select device drivers ---> memory when configuring the kernel.
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 :@(),@()
There are several required
Note:
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. Size
You can set the actual size (xxm, xxk, XX) or '-' to indicate all the remaining space.
Example:
Assume that flash
If the MTD-id of is sa1100, you can set it in the following way:
Mtdparts = sa1100:-→ only one partition
Mtdparts = sa1100: 256 K (armboot) Ro,-(Root) → Yes
Two partitions
You can view the description in drivers/MTD/cmdlinepart. C.

I. IP
System Startup
The IP address of the backend network card. 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
This
The 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.

Description
After several common bootargs types, we will discuss several combinations that I often 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 & apos; mem = 32 m console = ttys0, 115200 root =/dev/Ram RW init =/linuxrc & apos'
Note
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 are some of the frequently used
To be honest, the combination of bootargs is very flexible. Therefore, there are many methods to set bootargs. The specific method should also be set based on the specific situation of your platform.

 



U-boot

Of
Environment Variable
Yes
U-boot

The key, it
Yes
By
You have defined it by yourself, but some of them are also frequently used by everyone. The conventions are mature, and some are
U-boot

If you change these names, the following table lists some common links.
Environment variable:

 

Environment Variable

Description

Bootdelay




Number of seconds to wait for automatic start

Baudrate




Baud Rate of the serial port console

Netmask




Ethernet interface mask

Ethaddr




Physical address of the ENI

Bootfile




Default File Download

Bootargs




Startup parameters passed to the kernel

Bootcmd




Commands executed during Automatic startup

Serverip




Server Side
IP

Address

Ipaddr




Local
IP

Address

Stdin




Standard Input Device

Stdout




Standard output device

Stderr




Standard Error Device

 

The above are just some of the most basic environment variables. Please note that there are no environment variables in the board,
U-boot

Some basic environment variables are generated by default.
Saveenv

The environment variables are saved
Flash

And then modify the environment variables.
,

Save is based on
Flash

The operation of environment variables in.

 

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.