U-BOOT 命令的介绍

U­BOOT 常用命令

通常使用 help(或者只使用问号?),来查看所有的 U­BOOT 命令。将会列出在当前配置下所有支持的命令。 但是我们要注意,尽管 U­BOOT 提供了很多配置选项,并不是所有选项都支持各种处理器和开发板,有些选项 可能在你的配置中并没有被选上。

4.1.1 获得帮助信息

通过 help 可以获得当前开发板的 U­BOOT 中支持的命令.

CRANE2410 # help

?       - alias for 'help' 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' bootelf - Boot from an ELF image in memory bootm      - boot application image from memory

bootp   - boot image via network using BootP/TFTP protocol bootvx  - Boot vxWorks from an ELF image

cmp     - memory compare

coninfo - print console devices and information cp   - memory copy

crc32   - checksum calculation

date    - get/set/reset date & time dcache - enable or disable data cache echo  - echo args to console

erase   - erase FLASH memory

flinfo  - print FLASH memory information

go      - start application at address 'addr' help   - print online help

icache  - enable or disable instruction cache

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

loop    - infinite loop on address range md   - memory display

mm      - memory modify (auto-incrementing) 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 printenv- print environment variables

protect - enable or disable FLASH write protection rarpboot- boot image via network using RARP/TFTP protocol reset - Perform RESET of the CPU

run     - run commands in an environment variable

saveenv - save environment variables to persistent storage setenv  - set environment variables

sleep   - delay execution for some time

tftpboot- boot image via network using TFTP protocol version - print monitor version

4.2 常用命令使用说明

4.2.1   askenv(F)

在标准输入(stdin)获得环境变量。

4.2.2   autoscr

从内存(Memory)运行教本。(注意,从下载地址开始,例如我们的开发板是从 0x30008000 处开始运 行).

CRANE2410 # autoscr 0x30008000

## Executing script at 30008000

4.2.3   base

打印或者设置当前指令与下载地址的地址偏移。

4.2.4   bdinfo

打印开发板信息

CRANE2410 # bdinfo

-arch_number = 0x000000C1 (CPU 体系结构号)

-env_t       = 0x00000000 (环境变量)

-boot_params = 0x30000100 (启动引导参数)

-DRAM bank   = 0x00000000 (内存区)

--> start    = 0x30000000 (SDRAM 起始地址)

--> size     = 0x04000000 (SDRAM 大小)

-ethaddr     = 01:23:45:67:89:AB (以太网地址)

-ip_addr     = 192.168.1.5 (IP 地址)

-baudrate    = 115200 bps  (波特率)

4.2.5  bootp

通过网络使用 Bootp 或者 TFTP 协议引导境像文件。 CRANE2410 # help bootp

bootp [loadAddress] [bootfilename]

4.2.6  bootelf

默认从 0x30008000 引导 elf 格式的文件(vmlinux)

CRANE2410 # help bootelf

bootelf  [address] - load address of ELF image.

4.2.7   bootd(=boot)

引导的默认命令,即运行 U-BOOT 中在“include/configs/smdk2410.h” 中设置的“bootcmd”中 的命令。如下:

#define CONFIG_BOOTCOMMAND "tftp 0x30008000 uImage; bootm 0x30008000";

在命令下做如下试验:

CRANE2410 # set bootcmd printenv CRANE2410 # boot

bootdelay=3 baudrate=115200 ethaddr=01:23:45:67:89:ab

CRANE2410 # bootd bootdelay=3 baudrate=115200 ethaddr=01:23:45:67:89:ab

4.2.8   tftp(tftpboot)

即将内核镜像文件从 PC 中下载到 SDRAM 的指定地址,然后通过 bootm 来引导内核,前提是所用 PC 要安装设 置 tftp 服务。

下载信息:

CRANE2410 # tftp 0x30008000 zImage

TFTP from server 10.0.0.1; our IP address is 10.0.0.110 Filename 'zImage'.

Load address: 0x30008000

Loading: #################################################################

#################################################################

#################################################

done

Bytes transferred = 913880 (df1d8 hex)

4.2.9  bootm

内核的入口地址开始引导内核。

CRANE2410 # bootm 0x30008000

## Booting image at 30008000 ... Starting kernel ...

Uncompressing Linux......................................................................

done, .

4.2.10   go

直接跳转到可执行文件的入口地址,执行可执行文件。

CRANE2410 # go 0x30008000

## Starting application at 0x30008000 ...

4.2.11  cmp

对输入的两段内存地址进行比较。

CRANE2410 # cmp 0x30008000 0x30008040 64

word at 0x30008000 (0xe321f0d3) != word at 0x30008040 (0xc022020c) Total of 0 words were the same

CRANE2410 # cmp 0x30008000 0x30008000 64

Total of 100 words were the same

4.2.12   coninfo

打印所有控制设备和信息,例如

-List of available devices:

-serial   80000003 SIO stdin stdout stderr

4.2.13  cp

内存拷贝,cp 源地址 目的地址 拷贝大小(字节)

CRANE2410 # help cp

cp [.b, .w, .l] source target count ANE2410 # cp 0x30008000 0x3000f000 64

4.2.14   date

获得/设置/重设日期和时间

CRANE2410 # date

Date: 2006-6-6 (Tuesday)    Time:  06:06:06

4.2.15   erase(F)

擦除 FLASH MEMORY, 由于该 ARM 板没有 Nor Flash, 所有不支持该命令.

CRANE2410 # help erase 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

4.2.16   flinfo(F)

打印 Nor Flash 信息, 由于该 ARM 板没有 Nor Flash, 所有不支持该命令.

4.2.17  iminfo

打印和校验内核镜像头, 内核的起始地址由 CFG_LOAD_ADDR 指定:

#define  CFG_LOAD_ADDR 0x30008000  /* default load address */

该宏在 include/configs/crane2410.h 中定义.

CRANE2410 # iminfo

## Checking Image at 30008000 ...

Image Name:   Linux-2.6.14.1

Created:      2006-06-28   7:43:01 UTC

Image Type:   ARM Linux Kernel Image (uncompressed) Data Size:              1047080 Bytes = 1022.5 kB

Load Address: 30008000

Entry Point:  30008040 Verifying Checksum ... OK

4.2.18   loadb

从串口下载二进制文件

CRANE2410 # loadb

## Ready for binary (kermit) download to 0x30008000 at 115200 bps...

## Total Size      = 0x00000000 = 0 Bytes

## Start Addr      = 0x30008000

4.2.19  md

显示指定内存地址中的内容

CRANE2410

# md 0

00000000:

ea000012

e59ff014

e59ff014

e59ff014

................

00000010:

e59ff014

e59ff014

e59ff014

e59ff014

................

00000020:

33f80220

33f80280

33f802e0

33f80340

..3...3...3@..3

00000030:

33f803a0

33f80400

33f80460

deadbeef

...3...3`..3....

00000040:

33f80000

33f80000

33f9c0b4

33fa019c

...3...3...3...3

00000050:

e10f0000

e3c0001f

e38000d3

e129f000

..............).

00000060:

e3a00453

e3a01000

e5801000

e3e01000

S...............

00000070:

e59f0444

e5801000

e59f1440

e59f0440

D.......@...@...

00000080:

e5801000

e59f043c

e3a01003

e5801000

....<...........

00000090:

eb000051

e24f009c

e51f1060

e1500001

Q.....O.`.....P.

000000a0:

0a000007

e51f2068

e51f3068

e0432002

....h ..h0... C.

000000b0:

e0802002

e8b007f8

e8a107f8

e1500002

. ............P.

000000c0:

dafffffb

e51f008c

e2400803

e2400080

..........@...@.

000000d0:

e240d00c

e51f0094

e51f1094

e3a02000

..@.......... ..

000000e0:

e5802000

e2800004

e1500001

dafffffb

. ........P.....

000000f0:

eb000006

e59f13d0

e281f000

e1a00000

................

4.2.20   mm

顺序显示指定地址往后的内存中的内容,可同时修改,地址自动递增。

CRANE2410 30008000:

30008004:

30008008:

# mm 0x30008000

e1a00000 ? fffff e1a00000 ? eeeeee e1a00000 ? q

CRANE2410 30008000:

# md 30008000

000fffff 00eeeeee

 

e1a00000

 

e1a00000

 

................

30008010:

e1a00000 e1a00000

e1a00000

e1a00000

................

30008020:

ea000002 016f2818

00000000

000df1d8

.....(o.........

30008030:

e1a07001 e3a08000

e10f2000

e3120003

.p....... ......

4.2.21  mtest

简单的 RAM 检测 CRANE2410 # mtest

Pattern FFFFFFFD  Writing...  Reading...

4.2.22   mw

向内存地址写内容

CRANE2410 # md 30008000

30008000: ffffdffd ffffdffc ffffdffb ffffdffa    ................

CRANE2410 # mw 30008000 0 4 CRANE2410 # md 30008000

30008000: 00000000 00000000 00000000 00000000    ................

4.2.23  nm

修改内存地址, 地址不递增 CRANE2410 # nm 30008000 30008000: de4c457f ? 00000000

30008000: 00000000 ? 11111111

30008000: 11111111 ?

4.2.24  printenv

打印环境变量 CRANE2410 # printenv bootdelay=3 baudrate=115200

ethaddr=01:23:45:67:89:ab ipaddr=10.0.0.110 serverip=10.0.0.1 netmask=255.255.255.0 stdin=serial stdout=serial

stderr=serial

Environment size: 153/65532 bytes

4.2.25  ping

ping 主机

CRANE2410 # ping 10.0.0.1

host 10.0.0.1 is alive

4.2.26  reset

复位 CPU

4.2.27  run

运行已经定义好的 U-BOOT 的命令 CRANE2410 # set myenv ping 10.0.0.1 CRANE2410 # run myenv

host 10.0.0.1 is alive

4.2.28  saveenv(F)

保存设定的环境变量

4.2.29  setenv

设置环境变量

CRANE2410 # setenv ipaddr 10.0.0.254 CRANE2410 # printenv ipaddr=10.0.0.254

4.2.30   sleep

命令延时执行时间

CRANE2410 # sleep 1

4.2.31   version

打印 U-BOOT 版本信息 CRANE2410 # version

U-Boot 1.1.4 (Jul  4 2006 - 12:42:27)

4.2.32  nand info

打印 nand flash 信息 CRANE2410 # nand info

Device 0: Samsung K9F1208U0B at 0x4e000000 (64 MB, 16 kB sector)

4.2.33  nand device <n>

显示某个 nand 设备 CRANE2410 # nand device 0

Device 0: Samsung K9F1208U0B at 0x4e000000 (64 MB, 16 kB sector)

... is now current device

4.2.34   nand bad

CRANE2410 # nand bad Device 0 bad blocks:

4.2.35   nand read

nand read InAddr FlAddr size

InAddr: 从 nand flash 中读到内存的起始地址。 FlAddr: nand flash 的起始地址。

size: 从 nand flash 中读取的数据的大小。

CRANE2410 # nand read 0x30008000 0 0x100000

NAND read: device 0 offset 0, size 1048576 ... 1048576 bytes read: OK

4.2.36   nand erease

nand erase FlAddr size

FlAddr: nand flash 的起始地址

size: 从 nand flash 中擦除数据块的大小

CRANE2410 # nand erase 0x100000 0x20000

NAND erase: device 0 offset 1048576, size 131072 ... OK

4.2.37   nand write

nand write InAddr FlAddr size

InAddr: 写到 Nand Flash 中的数据在内存的起始地址 FlAddr: Nand Flash 的起始地址

size: 数据的大小

CRANE2410 # nand write 0x30f00000 0x100000 0x20000

NAND write: device 0 offset 1048576, size 131072 ... 131072 bytes written: OK

4.2.37 nboot

u-boot-1.1.4 代码对于 nboot 命令的帮助不正确,修改如下:

正确的顺序为:

nboot InAddr dev FlAddr InAddr: 需要装载到的内存的地址。

FlAddr: 在 nand flash 上 uImage 存放的地址 dev: 设备号

需要提前设置环境变量,否则 nboot 不会调用 bootm CRANE2410 #setenv autostart yes CRANE2410 # nboot 30008000 0 100000

Loading from device 0: <NULL> at 0x4e000000 (offset 0x100000) Image Name:              Linux-2.6.14.3

Created:      2006-07-06   7:31:52 UTC

Image Type:   ARM Linux Kernel Image (uncompressed) Data Size:              897428 Bytes = 876.4 kB

Load Address: 30008000

Entry Point:  30008040

Automatic boot of image at addr 0x30008000 ...

## Booting image at 30008000 ... Starting kernel ...

原文地址:https://www.cnblogs.com/fanweisheng/p/11105638.html