U-Boot command (function parameters and usage)

Source: Internet
Author: User
Tags crc32 crc32 checksum

After U-Boot is powered on, press any key to exit the Automatic startup status and enter the command line.

DRAM: 64 MB
Flash: 2 MB
NAND: 64 MiB
In: serial
Out: serial
Err: serial
Net: CS8900-0
Hit any key to stop autoboot: 1

At the command line prompt, enter the U-Boot command and execute it. U-Boot supports dozens of Common commands. With these commands, You can debug the Development Board, guide the Linux kernel, and erase Flash to complete system deployment and other functions. Only by understanding the use of these commands can we smoothly develop embedded systems.

Enter the help command to obtain the list of all commands of the current U-Boot. Each Command is followed by a simple command description.

U-Boot also provides more detailed Command help. You can use the help command to view the parameter descriptions of each command. For the development process, it is necessary to clarify the usage of the U-Boot command first. Next, explain the functions and parameters of each command based on the help information of each command.

1) bootm command

The bootm command can boot the program images stored in the memory, including RAM and permanently saved Flash.

Bootm-boot application image from memory
Usage:
Bootm [addr [arg...]
-Boot application image stored in memory
Passing arguments 'arg... '; when booting a Linux kernel,
'Arg 'can be the address of an initrd image
Sub-commands to do part of the bootm sequence. The sub-commands must beissued in
The order below (it's OK to not issue all sub-commands ):
Start [addr [arg...]
Loados-load OS image
Define line-OS specific command line processing/setup
Bdt-OS specific bd_t processing
Prep-OS specific prep before relocation or go
Go-start OS

● The 1st parameter addr is the address of the program image. The program image must be converted to the U-Boot format.
● The 2nd parameters are useful for Linux kernel Boot. Generally, they are used as the RAMDISK image storage address in the U-Boot format; it can also be a parameter passed to the Linux kernel (the bootargs environment variable is passed to the kernel by default ).

2) bootp command

The bootp Command requires the DHCP server to allocate an IP address and then download the specified file to the memory through the TFTP protocol.

Bootp-boot image via network using BOOTP/TFTP protocol

Usage:
Bootp [loadAddress] [[hostIPaddr:] bootfilename]

● The 1st parameters are the memory Address of the load Address file to be downloaded.
● The 2nd parameter is the name of the file to be downloaded by bootfilename. The file should be prepared on the Development host.

3) cmp command

The cmp command can compare the content in two pieces of memory .. B is in bytes;. w is in words;. l is in long words. Note: Do not retain spaces in the middle of cmp. B. You must enter commands consecutively.

Cmp-memory compare

Usage:
Cmp [. B,. w,. l] addr1 addr2 count

● The 1st addr1 parameter is the starting address of the first block of memory.
● The 2nd addr2 parameter is the starting address of the second memory.
● The count parameter is the number to be compared. The unit is byte, word, or long word.

4) cp command

The cp command can copy data blocks in the memory, including read/write operations on Flash.

Cp-memory copy

Usage:
Cp [. B,. w,. l] source target count

● The source Parameter contains the starting address of the data block to be copied.
● The 2nd target parameter is the address to be copied to the data block. If the address is in Flash, it will directly call the function operation for writing Flash. Therefore, use this command for U-Boot Flash writing. Of course, you need to clean the corresponding Flash area first.
● The count parameter is the number of copies. The unit is byte, word, and long word, respectively, according to cp. B, cp. w, and cp. l.

5) crc32 command

The crc32 command can calculate the checksum of stored data.

Crc32-checksum calculation

Usage:
Crc32 address count [addr]
-Compute CRC32 checksum [save at addr]

● The 1st parameter address is the start address of the data to be verified.
● The count parameter is the number of data bytes to be verified.
● The addr parameter 3rd is used to specify the address for saving the result.

6) echo command

Echo command echo parameters.

Echo-echo args to console

Usage:
Echo [args...]
-Echo args to console; \ c suppresses newline

7) erase command

The erase command can erase Flash. The parameter must specify the Flash erasure range.

Erase-erase FLASH memory

Usage:
Erase start end
-Erase FLASH from addr 'start' to addr 'end'
Erase start + len
-Erase FLASH from addr 'start' to the end of sect w/addr 'start' + 'len'-1
Erase N: SF [-SL]
-Erase sectors SF-SL in FLASH bank # N
Erase bank N
-Erase FLASH bank # N
Erase all
-Erase all FLASH banks

According to the start address and end address, start must be the start address of the erased block; end must be the end address of the erased end block, which is the most common method. Example: erase 0x20000 ~ The 0x3ffff Region Command is erase 20000 3 ffff.

By group and sector, N indicates the Flash group number, SF indicates the start fan area number, and SL indicates the end fan area number. In addition, the entire Flash group with group number N can be erased. To erase all Flash files, you only need to give an all parameter.

8) nand command

The nand command can erase, read, and write the Nand Flash with different parameters.

The meanings of Common commands are as follows (for specific formats, see help nand ).

Nand-NAND sub-system

Usage:
Nand info-show available NAND devices
Nand device [dev]-show or set current device
Nand read-addr off | partition size
Nand write-addr off | partition size
Read/write 'SIZE' bytes starting at offset 'off'
To/from memory address 'add', skipping bad blocks.
Nand erase [clean] [off size]-erase 'SIZE' bytes from
Offset 'off' (entire device if not specified)
Nand bad-show bad blocks
Nand dump [. oob] off-dump page
Nand scrub-really clean NAND erasing bad blocks (UNSAFE)
Nand markbad off [...]-mark bad block (s) at offset (UNSAFE)
Nand biterr off-make a bit error at offset (UNSAFE)

● Nand erase: erased Nand Flash.
● Nand read: read Nand Flash. An error occurs when flash blocks are damaged.
● Nand write: an error occurs when the Nand write command encounters a Flash bad block.

9) flinfo command

The flinfo command prints the information of all Flash groups, or only one of them can be printed. Generally, there is only one set of Flash in embedded systems.

Flinfo-print FLASH memory information

Usage:
Flinfo
-Print information for all FLASH memory banks
Flinfo N
-Print information for FLASH memory bank # N

10) go command

The go command can run applications.

Go-start application at address 'addr'

Usage:
Go addr [arg...]
-Start application at address 'add'
Passing 'arg 'as arguments

● The 1st addr parameter is the entry address of the program to be executed.
● The 2nd Optional parameters are the parameters passed to the program.

11) iminfo command

The iminfo command can print the start information of the program image, including the verification of the image content (serial number, header, and checksum ).

Iminfo-print header information for application image

Usage:
Iminfo addr [addr...]
-Print header information for application image starting
Address 'addr 'in memory; this includes des verification of
Image contents (magic number, header and payload checksums)

The first parameter addr specifies the starting address of the image. The optional parameter specifies more image addresses.

12) loadb command

The loadb command can be used to download binary files through a string.

Loadb-load binary file over serial line (kermit mode)

Usage:
Loadb [off] [baud]
-Load binary file over serial line with offset 'off' and baudrate 'baud'

13) loads command

The loads command can be used to download files in the S-Record format through a string.

Loads-load S-Record file over serial line

Usage:
Loads [off]
-Load S-Record file over serial line with offset 'off'

14) mw command

The mw command can write memory in bytes, words, and long words. The usage of. B,. w, and. l is the same as that of the cp command.

Mw-memory write (fill)

Usage:
Mw [. B,. w,. l] address value [count]

● The 1st parameter address is the memory address to be written.
● The value of the 2nd parameter is the value to be written.
● The count parameter is the number of unit values to be written.

15) nfs commands

The nfs command can start the image over the network using the NFS network protocol.

Nfs-boot image via network using NFS protocol

Usage:
Nfs [loadAddress] [[hostIPaddr:] bootfilename]

16) printenv command

The printenv command prints environment variables. All environment variables can be printed, or only environment variables listed in parameters can be printed.

Printenv-print environment variables

Usage:
Printenv
-Print values of all environment variables
Printenv name...
-Print value of environment variable 'name'

17) protect command

The protect command is a write protection operation for Flash, which can enable and disable write protection.

Protect-enable or disable FLASH write protection

Usage:
Protect on start end
-Protect FLASH from addr 'start' to addr 'end'
Protect on start + len
-Protect FLASH from addr 'start' to end of sect w/addr 'start' + 'len'-1
Protect on N: SF [-SL]
-Protect sectors SF-SL in FLASH bank # N
Protect on bank N
-Protect FLASH bank # N
Protect on all
-Protect all FLASH banks
Protect off start end
-Make FLASH from addr 'start' to addr 'end' writable
Protect off start + len
-Make FLASH from addr 'start' to end of sect w/addr 'start' + 'len'-1 wrtable
Protect off N: SF [-SL]
-Make sectors SF-SL writable in FLASH bank # N
Protect off bank N
-Make FLASH bank # N writable
Protect off all
-Make all FLASH banks writable

● The 1st parameter on indicates Enable write protection; The off parameter indicates that write protection is disabled.
● The 2nd and 3 Parameters specify the Flash write protection operation range, which is the same as the erasure method.

18) rarpboot command

The rarpboot command can use the TFTP protocol to start the image over the network, that is, to download the specified file to the specified address and then run it.

Rarpboot-boot image via network using RARP/TFTP protocol

Usage:
Rarpboot [loadAddress] [[hostIPaddr:] bootfilename]

● The 1st parameters are the memory address to which the loadAddress image file is downloaded.
● The 2nd parameter is the image file to be downloaded and executed by bootfilename.

19) run Command

The run command can be used to execute the commands in environment variables. The following parameters can be followed by several environment variable names.

Run-run commands in an environment variable

Usage:
Run var [...]
-Run the commands in the environment variable (s) 'var'

20) setenv command

The setenv command can be used to set environment variables.

Setenv-set environment variables

Usage:
Setenv name value...
-Set environment variable 'name' to 'value ...'
Setenv name
-Delete environment variable 'name'

● The 1st parameters are the name of the name environment variable.
● The first parameter is the value to be set. If there are no 2nd parameters, the environment variable is deleted.

21) sleep command

The sleep command can use the TFTP protocol to download files over the network and download files in binary format. In addition, you must configure relevant environment variables, such as serverip and ipaddr, to use this command.

Sleep-delay execution for some time

Usage:
Sleep N
-Delay execution for N seconds (N is _ decimal _!!!)

The sleep command can be executed with a delay of N seconds. N is a decimal number.

22) nm command

The nm command can modify the memory, which can be operated by byte, word, and long word.

Nm-memory modify (constant address)

Usage:
Nm [. B,. w,. l] address

The address parameter is the memory address to be read and modified.

23) tftpboot command

The tftpboot command can be used to download binary files on the network using the TFTP protocol.


Usage:
Tftpboot [loadAddress] [[hostIPaddr:] bootfilename]

24) saveenv command

The saveenv command can save environment variables to storage devices.

Saveenv-save environment variables to persistent storage

Usage:
Saveenv

These U-Boot commands provide rich development and debugging functions for embedded systems. You can use the U-Boot command during Linux kernel startup and debugging. However, generally, you do not need to use all commands. For example, if the Ethernet interface is already supported and you can use the tftpboot command to download files, you do not need to use the loadb for serial download. If the Development Board requires special debugging functions, you can also add new commands.

ExcerptEmbedded Linux application development from practice

Related Article

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.