注册 登录  
 加关注
查看详情
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

蒙奇D小豌豆的博客

蒙奇D小豌豆的学习记录

 
 
 

日志

 
 

U-boot常用命令  

2010-04-11 21:29:09|  分类: others |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

A 信息命令
bdinfo命令(简写为bdi)将在终端显示诸如内存地址和大小、时钟频率、MAC地址等信息。这些信息在传递给Linux内核一些参数时会用到。

=> bdi
memstart    = 0x00000000

memsize     = 0x04000000

flashstart  = 0x40000000

flashsize   = 0x00800000

flashoffset = 0x00030000

sramstart   = 0x00000000

sramsize    = 0x00000000

immr_base   = 0xFFF00000

bootflags   = 0x00000001

intfreq     =     50 MHz

busfreq     =     50 MHz

ethaddr     = 00:D0:93:00:28:81

IP addr     = 10.0.0.99

baudrate    = 115200 bps

2  输出包括了设备名、标识和当前使用情况。
=> conin

List of available devices:

serial   80000003 SIO stdin stdout stderr

这个输出结果意为串口设备是一个系统设备(标志‘S’),它提供输入(标志‘I’)和输出(标志‘O’)功能,而且当前已经指派给3个标准I/O流:tdin,stdout 和stderr。


3  flinfo命令 (简写为fli) 用于获取可用的flash存储信息(参见后面的Flash存储命令)。
=> fli

 Bank # 1: FUJITSU AM29LV160B (16 Mbit, bottom boot sect)

  Size: 4 MB in 35 Sectors

  Sector Start Addresses:

    40000000 (RO) 40008000 (RO) 4000C000 (RO) 40010000 (RO) 40020000 (RO)

    40040000      40060000      40080000      400A0000      400C0000

    400E0000      40100000      40120000      40140000      40160000

    40180000      401A0000      401C0000      401E0000      40200000

    40220000      40240000      40260000      40280000      402A0000

    402C0000      402E0000      40300000      40320000      40340000

    40360000      40380000      403A0000      403C0000      403E0000

4  minfo (简写为imi) 用于显示像Linux内核或者ramdisk之类的映像文件的头部信息。 它显示映像名、类型、大小以及CRC32校验和以验证文件没问题。

=> imi 100000

 ## Checking Image at 00100000 ...

   Image Name:   Linux-2.4.4

   Created:      2002-04-07  21:31:59 UTC

   Image Type:   PowerPC Linux Kernel Image (gzip compressed)

   Data Size:    605429 Bytes = 591 kB = 0 MB

   Load Address: 00000000

   Entry Point:  00000000

   Verifying Checksum ... OK

5 imls - list all images found in flash

6  help – 显示在线帮助
 help指令(简写为h或者?)显示在线帮助。如果不加任何参数,它会打印出所有当前U-Boot可用命令列表。你可以把某一指令名作为help的参数来获得这一命令的具体信息。比如:

=> help imi
 显示imi命令如何使用


B 存储类指令

1  base – 显示或者设置地址偏移

=> help base

base

    - print address offset for memory commands

base off

    - set address offset for memory commands to 'off'


=> base

Base Address: 0x00000000

2  md 显示内存  c为个数(uboot下面的个数 默认都是指4个字节的因为默认为l 32位列表的原因 例如下面的feffffff)  0为离base的偏移

=> help md
 md[.b,.w,.l]  address [# of objects]
=> md 0 c  

00000000: feffffff 00000000 7cbd2b78 7cdc3378    ........|.+x|.3x

00000010: 3cfb3b78 3b000000 7c0002e4 39000000    <.;x;...|...9...

00000020: 7d1043a6 3d000400 7918c3a6 3d00c000    }.C.=...y...=...

 

=> base 40000000

Base Address: 0x40000000

=> md 0 c

40000000: 27051956 50504342 6f6f7420 312e312e    '..VPPCBoot 1.1.

40000010: 3520284d 61722032 31203230 3032202d    5 (Mar 21 2002 -

40000020: 2031393a 35353a30 34290000 00000000     19:55:04)......


3 cmp – 存储单元比较
=> help cmp

cmp [.b, .w, .l] addr1 addr2 count

    - compare memory


=> md 0 c
00000000: ffffffff ffffffff 00000000 00000000    ................
00000010: 00000000 00000000 ffffffff ffffffff    ................
00000020: 080a80a6 156a0000 14004804 8110bc00    .....j....H.....

=> cmp 00000000 00000018 3
word at 0x00000008 (0x00000000) != word at 0x00000020 (0x080a80a6)

=> cmp.b 0000000 00000018 8
Total of 8 bytes were the same

=> cmp.w 00000000 00000018 8
Total of 8 bytes were the same


4  cp – 存储器拷贝

=> help cp

cp [.b, .w, .l] source target count

    - copy memory

 

    cp用来复制存储单元。count 的单位由[.b, .w, .l]来定

=> cp 40000000 100000 10000


    cp 可以使用类型标识符 .l , .w和.b。

5  mm – 存储单元修正(自动增长)

=> help mm

mm [.b, .w, .l] address

    - memory modify  auto increment address

mm提供了一种互动修改存储器内容的方法。它将会显示地址和当前值,然后提示用户输入。如果你输入了一个合法的十六进制数,这个新的值将会被写入该地址。然后提示下一个地址。如果你没有输入任何值,只是按了一下回车,那么该地址的内容保持不变。只要你输入任意非十六进制的数据(比如说.),此命令就立刻结束。

=> mm 100000

00100000: 27051956 ? 0

00100004: 50504342 ? AABBCCDD

00100008: 6f6f7420 ? 01234567

0010000c: 312e312e ? .

=> md 100000 10

00100000: 00000000 aabbccdd 01234567 312e312e    .........#Eg1.1.

00100010: 3520284d 61722032 31203230 3032202d    5 (Mar 21 2002 -

00100020: 2031393a 35353a30 34290000 00000000     19:55:04)......

00100030: 00000000 00000000 00000000 00000000    ................

 

   同样,这条命令也可以加上类型标识符.l, .w 和 .b 


6   mtest – 简单地RAM测试

=> help mtest

mtest [start [end [pattern]]]

    - simple RAM read/write test

 =>

mtest提供一个简单地存储器测试。

=> mtest 100000 200000

Testing 00100000 ... 00200000:

Pattern 0000000F  Writing...  Reading...

 

00100000: 00000000 aabbccdd 01234567 312e312e    .........#Eg1.1.

00100010: 3520284d 61722032 31203230 3032202d    5 (Mar 21 2002 -

00100020: 2031393a 35353a30 34290000 00000000     19:55:04)......

00100030: 00000000 00000000 00000000 00000000    ................

=>

   同样,这条命令也可以加上类型标识符.l, .w 和 .b ;

7   mw – 写存储器

=> help mw

mw [.b, .w, .l] address value [count]

    - write memory

=>

   mw是一种往存储器填写某些数据的方法。如果调用时没加计数参数,值将仅仅被写到某一给定的地址。当使用了计数参数时,整个存储区域都会写入该值。

  => md 100000 10

00100000: 0000000f 00000010 00000011 00000012    ................

00100010: 00000013 00000014 00000015 00000016    ................

00100020: 00000017 00000018 00000019 0000001a    ................

00100030: 0000001b 0000001c 0000001d 0000001e    ................

=> mw 100000 aabbccdd

=> md 100000 10

00100000: aabbccdd 00000010 00000011 00000012    ................

00100010: 00000013 00000014 00000015 00000016    ................

00100020: 00000017 00000018 00000019 0000001a    ................

00100030: 0000001b 0000001c 0000001d 0000001e    ................

=> mw 100000 0 6

=> md 100000 10

00100000: 00000000 00000000 00000000 00000000    ................

00100010: 00000000 00000000 00000015 00000016    ................

00100020: 00000017 00000018 00000019 0000001a    ................

00100030: 0000001b 0000001c 0000001d 0000001e    ................

=>

它又是一条可以加标识符.l, .w和.b的命令;

C flash存储器命令

1 flash存储器copy命令

=> help cp
cp - memory copy

Usage:
cp [.b, .w, .l] source target count


=>cp.b 100000 FF900000 40000
Copy to Flash... done


2 flash存储器擦除命令
=> help era
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


=> era FF900000 FF95FFFF

... done
Erased 3 sectors


3 开启or关闭flash存储器写保护

=> help protect
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

=> prot on 0xFF900000 0xFF97FFFF
Protected 4 sectors
=> fli
FF900000 E RO     FF920000 E RO     FF940000 E RO     FF960000 E RO
当写保护后就不能erase命令 这个区域


4 mtdparts  在uboot中设置分区的命令
u-boot支持2种mtd分区方式

a 第一种是静态的定义在板级config文件中 例如
#undef CONFIG_JFFS2_CMDLINE
#define CONFIG_JFFS2_DEV               "nor0"
#define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF     /* use whole device */
#define CONFIG_JFFS2_PART_SIZE         0x00100000     /* use 1MB */
#define CONFIG_JFFS2_PART_OFFSET       0x00000000

b第二种发法是运用mtdparts 命令 动态定义

=> help mtdparts
mtdparts
    - list partition table
mtdparts delall
    - delete all partitions
mtdparts del part-id
    - delete partition (e.g. part-id = nand0,1)
mtdparts add [@] [] [ro]
    - add partition
mtdparts default
    - reset partition table to defaults


这个命令运用的三个环境变量:

'partition' - keeps current partition identifier

partition  :=
  := ,part_num

'mtdids' - linux kernel mtd device id <-> u-boot device id mapping

mtdids=[,,...]

    := =
   := 'nand'|'nor'
  := mtd device number, 0...
   := unique device tag used by linux kernel to find mtd device (mtd->name)

'mtdparts' - partition list

mtdparts=mtdparts=[;...]

  := :[,...]
   := unique device tag used by linux kernel to find mtd device (mtd->name)
:= [@][][]
     := standard linux memsize OR '-' to denote all remaining space
   := partition start offset within the device
     := '(' NAME ')'
  := when set to 'ro' makes partition read-only (not used, passed to kernel)

5 bootm  启动应用镜像命令
=> help bootm
bootm - boot application image from memory

Usage:
bootm [addr [arg ...]]
    - boot application image stored in memory

such
 bootm ${kernel_addr} - ${fdt_addr}

boot所需要的镜像一般是从tftp下载到ram中的
例子
tftp 31000000 uImage  
tftp C00000    ramdisk
bootm 0x31000000 - C00000

6 tftp 下载命令
tftp 31000000 uImage 
下载文件uImage到内存31000000处


D  环境变量命令

1 打印环境变量命令
=> help printenv
printenv - print environment variables

Usage:
printenv
    - print values of all environment variables
printenv name ...
    - print value of environment variable 'name'


=> printenv ipaddr hostname netmask
ipaddr=192.168.100.6
hostname=canyonlands
netmask=255.255.0.0

2保存环境变量命令
=> help saveenv
saveenv - save environment variables to persistent storage

Usage:
saveenv

所有命令都是在内存中的 当一掉电就没有了 所以通过saveenv保存到可保存的存储器中比如flash
=> saveenv
Saving Environment to Flash...
Un-Protected 1 sectors
Un-Protected 1 sectors
Erasing Flash...
. done
Erased 1 sectors
Writing to Flash... done
Protected 1 sectors
Protected 1 sectors

3 setenv设置环境变量
=> help setenv
setenv - set environment variables

Usage:
setenv name value ...
    - set environment variable 'name' to 'value ...'
setenv name
    - delete environment variable 'name'


=> setenv foo This is an example value.
=> printenv foo
foo=This is an example value.
=> setenv foo
=> printenv foo
## Error: "foo" not defined
=>


=> printenv bar
## Error: "bar" not defined
=> setenv bar This is a new example.
=> printenv bar
bar=This is a new example.

一个常见的错误

setenv name=value
应代替为
setenv name value

4 在环境变量中 的run命令

=> setenv test  echo This is a test;printenv ipaddr;echo Done.  为跳行
=> printenv test
test=echo This is a test;printenv ipaddr;echo Done.
=> run test
This is a test
ipaddr=192.168.100.6
Done.
=>


5  help boot
boot - No help available.

=>


The bootd (short: boot) executes the default boot command, i. e. what happens when you don't interrupt the initial countdown. This is a synonym for the run bootcmd command.
boot 执行默认的boot命令 它等同于 run  bootcmd命令

 

E 其他命令
1  echo
=> help echo
echo - echo args to console

Usage:
echo [args..]
    - echo args to console; c suppresses newline
=>


The echo command echoes the arguments to the console:


=> echo The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
=>


2 重启cpu

=> help reset
reset - Perform RESET of the CPU

Usage:
reset
=>


The reset command reboots the system.


=>
=> reset


3  延迟执行一段时间

=> help sleep
sleep - delay execution for some time

Usage:
sleep N
    - delay execution for N seconds (N is _decimal_ !!!)
=>


The sleep command pauses execution for the number of seconds given as the argument:


=> sleep 5
=>

4 显示uboot版本
=> help version
version - print monitor version

Usage:
version
=>

You can print the version and build date of the U-Boot image running on your system using the version command (short: vers):

=> version

U-Boot 2009.11.1 (Feb 05 2010 - 08:57:12)

 

 

 

 

 

 

 


 

  评论这张
 
阅读(997)| 评论(0)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018