Read SD card contents in Uboot

Source: Internet
Author: User

1. SD Card Upgrade command

Mmcinit 0

Fatload MMC 0:1 0 uzimage.bin 80000

Fatload MMC 0:1 1000000 initrd.gz 580000

BOOTM 0

2. U-boot Script

Can be saved as nfs.script, placed in the root directory of TFTP

setenv Bootargs mem=214m root=/dev/nfsroot nfsroot=10.1.1.2:/home/nfs_android ip=dhcp rw console=ttys0,115200n8 ANDROIDBOOT.CONSOLE=TTYS0 Init=/init lcdid=1 lpj=750000

How do I load it?

setenv bootcmd setenv ipaddr 10.1.1.3/;setenv serverip 10.1.1.2 / setenv gatewayip 10.1.1.1 / ; Tftpboot 0 2000000 nfs.script / ; AUTOSCR

here/; make a command of multiple commands.

Here Bootcmd references Bootargs

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

The methods for converting to image files are listed below:

bash$ mkimage-t script-c none-n ' Demo script File '-D setenv-commands setenv.img

Image Name:demo Script File

Created:mon June 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, the user can mount using a command such as TFTP, like any other image file, and then execute the image using the command AUTOSCR, as follows:

= TFTP 100000/tftpboot/tqm860l/setenv.img

3. Tftpboot,bootm,tftp

BOOTM is to load and start the operating system image and file system, the 1th parameter is the kernel's mirror address, RAM address or flash address. The second parameter is an optional, initrd image address. Also tell the kernel the size and address of the RAMDisk.

TFTP is downloaded to the specified address.

Tftpboot Download the image via the TFTP protocol. Tftpboot [loadaddress] [filename]

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

U-boot Environment variables: bootcmd and Bootargs

U-bootcmd
As mentioned earlier, Bootcmd are some of the commands that are executed by default at auto-start, so you can define different configurations in your current environment, set the parameters for different environments, and then set Bootcmd as the parameters that you use most often.
U-bootargs
Bootargs is the heaviest of the environment variables, and even the whole environment variable is set around the Bootargs. Bootargs is very, very much, we usually just use a few, interested can see this article said very full: http://blog.chinaunix.net/u2/79570/showart_1675071.html. Bootargs is very flexible, the kernel and file system different collocation will have different settings, and even you can not set the Bootargs, and directly write it into the kernel (in the configuration of the kernel options can be set), it is these reasons for the Bootargs use of the difficulties.
The following describes the Bootargs commonly used parameters, Bootargs is very much, and with the development of kernel will appear some new parameters, making the setting will be more flexible and diverse.

A. Root
Used to specify the location of the rootfs, common cases are:
Root=/dev/ram RW
Root=/dev/ram0 RW
Please note that the above two settings are general, I have done the test even root=/dev/ram1 RW and root=/dev/ram2 RW is also possible, online some people say in some cases is not universal, that must be set to RAM or RAM0, but not yet encountered, Further confirmation is required, and you can try each time you encounter a problem.

ROOT=/DEV/MTDX RW
Root=/dev/mtdblockx RW
root=/dev/mtdblock/x RW
root=31:0x

The above are common in some cases, of course, it depends on whether your current system is supported, but MTD is a character device, and Mtdblock is a block device, and sometimes you try to get to the bottom of the current system to support the case, but Root=/dev/mtdblockx RW is more versatile. In addition, if you specify the device name directly, it is also possible to use the device number for 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, which is the directory that indicates the file system exists for that host.

B. Rootfstype
This option needs to be used in conjunction with root, generally if the root filesystem is ext2, there is no such option is irrelevant, but if it is JFFS2,SQUASHFS and other file systems, you need to rootfstype indicate the type of file system, otherwise you will not be able to mount the root partition.

C. Console
Console=tty uses virtual serial terminal equipment.
Console=ttys[,options] using a specific serial port, options can be the form of BBBBPNX, where BBBB refers to the serial port baud rate, p is the parity bit (never seen used), n refers to bits.
Console=ttysac[,options] with the top.

Look at your current environment, sometimes with ttys, sometimes with Ttysac, online Some people say, this is the kernel version of the 2.4 with TTYSAC, but the fact is the official document is also used TTYs, so should be not associated with the kernel version. You can view Documentation/serial-console.txt to find the relevant description.

D. Mem
MEM=XXM Specifies the size of the memory, not required

E. ramdisk_size
Ramdisk=xxxxx Not recommended
Ramdisk_size=xxxxx recommended
Both of the above can tell the RAMDisk driver, create the size of the RAMDisk, by default is 4m (s390 default 8M), you can view documentation/ramdisk.txt find the relevant description, but ramdisk= XXXXX in the new version of the kernel has not been mentioned, is not recommended to use.

F. Initrd, NOINITRD
When you do not use the RAMDisk boot system, you need to use the NOINITRD this parameter, but if used, you need to specify Initrd=r_addr,size, R_ADDR represents the INITRD in memory location, size represents INITRD.

G. Init
INIT specifies that after the kernel is set up, the first script to run into the system, generally INIT=/LINUXRC, or init=/etc/preinit,preinit, is typically to create console,null device nodes, run the INIT program, Mount some file systems, and so on. Please note that many beginners think INIT=/LINUXRC is a fixed notation, in fact,/LINUXRC refers to the LINUXRC script under the directory, is generally a connection.

H. mtdparts
mtdparts=fc000000.nor_flash:1920k (Linux), 128k (FDT), 20M (RAMDisk), 4M (JFFS2), 38272k (user), 256k (env), 384k (Uboot)
In order for this parameter to work, the MTD driver in the kernel must be supported, that is, the kernel configuration needs to be selected on Device Drivers---> Memory technology Device (MTD) Support---> Command line P Artition 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)
So you need to set it in the following format when you use it:
mtdparts=mtd-id:@ (), @ ()
Here are a few important points to note:
A. Mtd-id must be consistent with the flash Mtd-id of your current platform, or the entire mtdparts will fail
B. Size can be set to the actual size (xxm,xxk,xx), or '-' which indicates all the remaining space.
Example:
Assuming that the mtd-id of Flash is sa1100, then you can use the following method to set:
mtdparts=sa1100:-→ only one partition
mtdparts=sa1100:256k (Armboot) ro,-(root) → has two partitions
You can see the comments in drivers/mtd/cmdlinepart.c to find the relevant description.

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, and in other cases you will see your own preferences. There are two ways of setting up IP:
ip = IP Addr
Ip=ip addr:server IP Addr:gateway:netmask::which netcard:off
These two methods can be used, but obviously the second is much more detailed, note that the second type of which netcard refers to the network card on the Development Board, not the network card on the host.

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

2). Assuming the file system is RAMDisk, and in Flash, the Bootargs settings should be as follows:
Setenv Bootargs ' mem=32m console=ttys0,115200 root=/dev/ram rw init=/linuxrc '
Note In this case you should specify RAMDisk address in Flash in the BOOTM command, such as Bootm kernel_addr ramdisk_addr (FDT_ADDR)

3). Assuming that the file system is of type JFFS2, and in Flash, the Bootargs settings should be as follows
Setenv Bootargs ' mem=32m console=ttys0,115200 noinitrd root=/dev/mtdblock2 rw rootfstype=jffs2 init=/linuxrc '

4). Assuming that the file system is NFS based, the Bootargs settings should be as follows
Setenv Bootargs ' noinitrd mem=64m 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=64m console=ttysac0 root=/dev/nfs nfsroot=192.168.0.3:/nfs ip=192.168.0.5 '

The above is a number of bootargs we often use a combination of, to be honest, Bootargs very very flexible, so the method has a lot of form, the specific should also be based on your platform specific circumstances to set.

U-boot environment variable is the key to use U-boot, it can be defined by you, but some of them are often used, the contract is ripe, some are u-boot their own definition, change these names will appear error, In the table below we have listed some of the commonly used environment variables:

Environment variables

Describe

BootDelay

number of wait seconds to execute auto-start

BaudRate

baud rate of serial console

Netmask

Mask for Ethernet interface

Ethaddr

NIC Physical Address of Ethernet card

Bootfile

The default download file

Bootargs

boot parameters passed to the kernel

Bootcmd

commands executed at auto-start

ServerIP

server-side IP address

IPAddr

local IP address

Stdin

Standard input Devices

StdOut

Standard output Devices

StdErr

standard error Device

Above is just some of the most basic environment variables, please note that there is no environment variables in the board, u-boot By default, there will be some basic environment variables, after you have executed the saveenv , the environment variable will be saved to flash for the first time , and then your changes to the environment variables are saved based on the actions of the environment variables stored in flash.

Read SD card contents in Uboot

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.