Você está na página 1de 5

Using U-Boot

U-boot provides a powerful command line interface which may be accessed through a terminal emulator connected to the target board's serial port. For example type "help" at the command prompt will print a list of all the available commands:
MB680> help ? - alias for 'help' askenv - get environment variables from stdin autoscr - run script from memory base - print or set address offset bdinfo - print Board Info structure boot - boot default, i.e., run 'bootcmd' bootd - boot default, i.e., run 'bootcmd' bootm - boot application image from memory bootp - boot image via network using BootP/TFTP protocol chpart - change active partition cmp - memory compare coninfo - print console devices and information cp - memory copy crc32 - checksum calculation dhcp - invoke DHCP client to obtain IP/boot params echo - echo args to console erase - erase FLASH memory exit - exit script ext2load- load binary file from a Ext2 filesystem ext2ls - list files in a directory (default /) fatinfo - print information about filesystem fatload - load binary file from a dos filesystem fatls - list files in a directory (default /) flinfo - print FLASH memory information fsinfo - print information about filesystems fsload - load binary file from a filesystem image go - start application at address 'addr' help - print online help iminfo - print header information for application image imls - list all images found in flash itest - return true/false on integer compare loadb - load binary file over serial line (kermit mode) loads - load S-Record file over serial line loady - load binary file over serial line (ymodem mode) loop - infinite loop on address range ls - list files in a directory (default /) md - memory display mii - MII utility commands mm - memory modify (auto-incrementing) mtdparts- define flash/nand partitions mtest - simple RAM test mw - memory write (fill) nand - NAND sub-system nboot - boot from NAND device nfs - boot image via network using NFS protocol nm - memory modify (constant address) ping - send ICMP ECHO_REQUEST to network host

pmb printenvprotect rarpbootreset run saveenv setenv sleep test tftpbootusb usbboot version -

displays the contents of the PMB print environment variables enable or disable FLASH write protection boot image via network using RARP/TFTP protocol Perform RESET of the CPU run commands in an environment variable save environment variables to persistent storage set environment variables delay execution for some time minimal test like /bin/sh boot image via network using TFTP protocol USB sub-system boot from USB device print monitor version

For help on an individual command type "help command". For example:


MB680> help setenv setenv name value ... - set environment variable 'name' to 'value ...' setenv name - delete environment variable 'name'

Note you only need to provide enough of a commands name to distinguish it from all other commands. For example you may type "save" instead of "saveenv".

Command Line Editing


Simple command line editing and history is also provided: Key Control-A Control-E Control-B or Left-Arrow Control-K Control-X Back-Space or Delete Control-D Control-P or Up-Arrow Control-O Control-C Function move to start of line move to end of line move character left erase to end of line erase entire line erase character to the left of the cursor erase character under the cursor previous command history toggle overwrite/insert mode break

Control-F or Right-Arrow move character right

Control-N or Down-Arrow next command history

U-Boot Environment
U-Boot provides user configuration using Environment Variables which can be saved to Flash memory. Environment Variables are set using "setenv", printed using "printenv", and saved to Flash using "saveenv". The value of environment variables can be used in commands (or scripts) by prefixing their name by a dollar ("$"). To stop the evaluation of variables either prepend the dollar with a backslash ("\") or quote the string with quotes ("'"). Here are some examples of using environment variables:
MB680> setenv targetname fred MB680> print targetname targetname=fred MB680> echo $targetname fred MB680> echo ${targetname} fred MB680> echo \${targetname} ${targetname} MB680> echo '${targetname}' ${targetname}

Using "setenv" without a value can be used to delete a variable from the environment. As long as the environment variables are not saved to flash, then you will be working with an in-memory copy. If there is no valid environment in the Flash, a default environment is provided.

Command Scripts
Command scripts can also be saved in environment variables and executed using the "run" command. The syntax for the scripts is similar to the "sh" shell. Commands return 0 if they ran successfully and 1 if they failed. The result of executing a command can be tested with condition commands:
if <list>; then <command list>; [ elif <list>; then <list>; ] ... [ else <list>; ] fi while <list> ; do <list> ; done until <list> ; do <list> ; done for <name> in <word list> ; do <list> ; done

The following is an example script that boots a known good default kernel, if the standard kernel is not available/good in flash - note the script is quoted with quotes ("'") to defer the expansion of the environment variables until the script is eventually executed:
MB680> setenv vm_default_base A0060000 MB680> setenv vm_base A0660000

MB680> set doboot 'if iminfo ${vm_base}; then bootm ${vm_base}; else bootm ${vm_default_base}; fi' MB680> run doboot ## Checking Image at a0660000 ... Bad Magic Number ## Booting image at a0060000 ... Image Name: 2.6.23.17_0116 #1 (mb680) Image Type: SuperH Linux Kernel Image (uncompressed) Data Size: 3895568 Bytes = 3.7 MiB Load Address: 8c001000 Entry Point: 8c002000 Verifying Checksum ... OK OK Starting kernel console=ttyAS0,115200 ...

Note: commands need to be typed on a single line. In some of the examples long commands will wrap over on to the following line - these must always be entered on a single line.

Tests And Comparisons


There are two commands provided for comparing values "test" and "itest". To compare the values of environment variables use "test". The syntax is the same as the shell command: Expression ! EXPRESSION Evaluated to TRUE if ... EXPRESSION is false

EXPRESSION1 -a EXPRESSION2 both EXPRESSION1 and EXPRESSION2 are true EXPRESSION1 -o EXPRESSION2 either EXPRESSION1 or EXPRESSION2 is true -n STRING -z STRING STRING1 = STRING2 STRING1 != STRING2 INTEGER1 -eq INTEGER2 INTEGER1 -ge INTEGER2 INTEGER1 -gt INTEGER2 INTEGER1 -le INTEGER2 INTEGER1 -lt INTEGER2 INTEGER1 -ne INTEGER2 the length of STRING is non-zero the length of STRING is zero the strings are equal the strings are not equal INTEGER1 is equal to INTEGER2 INTEGER1 is greater than or equal to INTEGER2 INTEGER1 is greater than INTEGER2 INTEGER1 is less than or equal to INTEGER2 INTEGER1 is less than INTEGER2 INTEGER1 is not equal to INTEGER2

The command "itest" allows values in memory to be tested. The syntax for"itest" is:

itest[.b,.w,.l,.s] [*]value1 <op> [*]value2 Where the optional suffix means: .b byte .w short .l long (default) .s string value1 and value2 can be a constant or and address if preceded by a *. <op> can be one of: -lt < -gt > -eq == -ne != -ge >= -le <= Less than Greater than Equal to not Equal to Greater than or Equal to Less than or Equal to

<>

Você também pode gostar