2014年12月15日 星期一

uboot 常用指令介紹

U-Boot 是嵌入式系統上最常見的 Boot Loader,底下說明其常用指令:

U-Boot# help -> 列出可使用指令

U-Boot# version -> 觀看目前所使用 U-Boot 版本

U-Boot 2014.07 (Oct 14 2014 - 11:45:06)
arm-linux-gnueabi-gcc (Debian 4.4.5-8) 4.4.5
GNU ld (GNU Binutils for Debian) 2.20.1.20100303


U-Boot# bdinfo  -> 觀看嵌入式電路板資訊
arch_number = 0x0000060A
boot_params = 0x80000100
DRAM bank   = 0x00000000
-> start    = 0x80000000
-> size     = 0x08000000
DRAM bank   = 0x00000001
-> start    = 0x88000000
-> size     = 0x08000000
eth0name    = usb_ether
ethaddr     = (not set)
current eth = usb_ether
ip_addr     = <NULL>
baudrate    = 115200 bps
TLB addr    = 0x8FFF0000
relocaddr   = 0x8FF4C000
reloc off   = 0x0FE4C000
irq_sp      = 0x8EF2BEE0
sp start    = 0x8EF2BED0

U-Boot# mmc list        -> 列出目前板子上面的 sdcard
OMAP SD/MMC: 0

U-Boot# mmcinfo         -> 顯示(SD)記憶卡資訊,亦可以打成 mmc info
Device: OMAP SD/MMC
Manufacturer ID: aa
OEM: 5859
Name: QEMU!
Tran Speed: 25000000
Rd Block Len: 512
SD version 1.0
High Capacity: No
Capacity: 1 GiB
Bus Width: 4-bit

U-Boot# mmc part        -> 觀看 MMC 上的分割區

Partition Map for MMC device 0  --   Partition Type: DOS

Part    Start Sector    Num Sectors     UUID            Type
  1     2048            163840          8a5a18c6-01     0b Boot
  2     165888          1931264         8a5a18c6-02     83

 U-Boot# ls              -> 可觀看目錄裡的檔案,底下介紹用法
ls - list files in a directory (default /)

Usage:
ls <interface> [<dev[:part]> [directory]]
    - List files in directory 'directory' of partition 'part' on
      device type 'interface' instance 'dev'.

U-Boot# ls mmc 0:1      -> 觀看第 0 個 MMC,第 1 個分割區之內容
  2404728   uimage
    51100   mlo
  1853076   u-boot
   392152   u-boot.bin
   392216   u-boot.img

5 file(s), 0 dir(s)

U-Boot# ls mmc 0:2      -> 觀看第 0 個 MMC,第 2 個分割區 (rootfs) 之內容


U-Boot# fatinfo         -> 觀看 FAT 檔案系統資訊
usage: fatinfo <interface> [<dev[:part]>]

U-Boot# fatinfo mmc 0:1 -> 觀看第 0 個 MMC,第 1 個分割區之資訊
Interface:  MMC
  Device 0: Vendor: Man 0000aa Snr adbeef00 Rev: 13.14 Prod: QEMU!
            Type: Removable Hard Disk
            Capacity: 1024.0 MB = 1.0 GB (2097152 x 512)
Filesystem: FAT16 "           "

U-Boot# fatinfo mmc 0:2 -> 觀看第 0 個 MMC,第 2 個分割區,因此分割區為 ext3,故
無資料顯示。

** Unable to use mmc 0:2 for fatinfo **

U-Boot# fatls mmc 0:1   -> 觀看第 0 個 MMC,第 1 個分割區之內容
  2404728   uimage
    51100   mlo
  1853076   u-boot
   392152   u-boot.bin
   392216   u-boot.img

5 file(s), 0 dir(s)
 U-Boot# ext2ls mmc 0:2  -> 觀看第 0 個 MMC,第 2 個分割區(ext3)之內容


** 所有 ls 指令如 fatls、ext2ls .. 等均可以直接用 ls 指令來代替,語法一樣 **

U-Boot# reset
resetting ...

U-Boot# usb             -> USB 操作相關指令
usb - USB sub-system

Usage:
usb start - start (scan) USB controller
usb reset - reset (rescan) USB controller
usb stop [f] - stop USB [f]=force stop
usb tree - show USB device tree
usb info [dev] - show available USB devices
usb test [dev] [port] [mode] - set USB 2.0 test mode
    (specify port 0 to indicate the device's upstream port)
    Available modes: J, K, S[E0_NAK], P[acket], F[orce_Enable]
usb storage - show details of USB storage devices
usb dev [dev] - show or set current USB storage device
usb part [dev] - print partition table of one or all USB storage    devices
usb read addr blk# cnt - read `cnt' blocks starting at block `blk#'
    to memory address `addr'
usb write addr blk# cnt - write `cnt' blocks starting at block `blk#'
    from memory address `addr'

U-Boot# usb info        -> 觀看 USB 資訊,不過因為還沒啟動,所以沒資訊
USB is stopped. Please issue 'usb start' first.

U-Boot# usb start       -> 啟動 USB 裝置
(Re)start USB...
USB0:   USB EHCI 0.00
scanning bus 0 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
       scanning usb for ethernet devices... 0 Ethernet Device(s) found

此時再執行 usb info 可以看到 USB 裝置
U-Boot# usb info
1: Hub,  USB Revision 2.0
 - u-boot EHCI Host Controller
 - Class: Hub
 - PacketSize: 64  Configurations: 1
 - Vendor: 0x0000  Product 0x0000 Version 1.0
   Configuration: 1
   - Interfaces: 1 Self Powered 0mA
     Interface: 0
     - Alternate Setting 0, Endpoints: 1
     - Class Hub
     - Endpoint 1 In Interrupt MaxPacket 8 Interval 255ms

U-Boot# printenv        -> 列出開機環境設定,請全部複製下來修改
arch=arm
baudrate=115200
beaglerev=C4
board=beagle
board_name=beagle
bootargs=console=ttyO2,115200n8 mpurate=auto buddy=none camera=none vram=12M omapfb.mode=dvi:640x480MR-16@60 omapdss.def_disp=dvi root=ubi0:rootfs ubi.mtd=4 rootfstype=ubifs
bootcmd=run findfdt; mmc dev ${mmcdev}; if mmc rescan; then if run userbutton; then setenv bootenv uEnv.txt;else setenv bootenv user.txt;fi;echo SD/MMC found on device ${mmcdev};if run loadbootenv; then echo Loaded environment from ${bootenv};run importbootenv;fi;if test -n $uenvcmd; then echo Running uenvcmd ...;run uenvcmd;fi;if run loadimage; then run mmcboot;fi;fi;run nandboot;setenv bootfile zImage;if run loadimage; then run loadfdt;run mmcbootz; fi;
bootdelay=1
bootdir=/boot
bootenv=uEnv.txt
bootfile=zImage
bootpart=0:2
buddy=none
camera=none
console=ttyO2,115200n8
cpu=armv7
defaultdisplay=dvi
dieid#=51454d5551454d555400000051454d55
dvimode=640x480MR-16@60
ethact=usb_ether
fdt_high=0xffffffff
fdtaddr=0x80f80000
fdtfile=omap3-beagle.dtb
findfdt=if test $beaglerev = AxBx; then setenv fdtfile omap3-beagle.dtb; fi; if test $beaglerev = Cx; then setenv fdtfile omap3-beagle.dtb; fi; if test $beaglerev = C4; then setenv fdtfile omap3-beagle.dtb; fi; if test $beaglerev = xMAB; then setenv fdtfile omap3-beagle-xm-ab.dtb; fi; if test $beaglerev = xMC; then setenv fdtfile omap3-beagle-xm.dtb; fi; if test $fdtfile = undefined; then echo WARNING: Could not determine device tree to use; fi;
importbootenv=echo Importing environment from mmc ...; env import -t $loadaddr $filesize
loadaddr=0x80200000
loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenv}
loadfdt=run validatefdt; load mmc ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}
loadimage=load mmc ${bootpart} ${loadaddr} ${bootdir}/${bootfile}
loadramdisk=load mmc ${bootpart} ${rdaddr} ${bootdir}/${ramdisk}
mmcargs=setenv bootargs console=${console} ${optargs} mpurate=${mpurate} buddy=${buddy} camera=${camera} vram=${vram} omapfb.mode=dvi:${dvimode} omapdss.def_disp=${defaultdisplay} root=${mmcroot} rootfstype=${mmcrootfstype}
mmcboot=echo Booting from mmc ...; run mmcargs; bootm ${loadaddr}
mmcbootz=echo Booting with DT from mmc${mmcdev} ...; run mmcargs; bootz ${loadaddr} - ${fdtaddr}
mmcdev=0
mmcroot=/dev/mmcblk0p2 rw
mmcrootfstype=ext3 rootwait
mpurate=auto
nandargs=setenv bootargs console=${console} ${optargs} mpurate=${mpurate} buddy=${buddy} camera=${camera} vram=${vram} omapfb.mode=dvi:${dvimode} omapdss.def_disp=${defaultdisplay} root=${nandroot} rootfstype=${nandrootfstype}
nandboot=echo Booting from nand ...; run nandargs; nand read ${loadaddr} 280000 400000; bootm ${loadaddr}
nandroot=ubi0:rootfs ubi.mtd=4
nandrootfstype=ubifs
ramargs=setenv bootargs console=${console} ${optargs} mpurate=${mpurate} buddy=${buddy} vram=${vram} omapfb.mode=dvi:${dvimode} omapdss.def_disp=${defaultdisplay} root=${ramroot} rootfstype=${ramrootfstype}
ramboot=echo Booting from ramdisk ...; run ramargs; bootm ${loadaddr}
ramdisk=ramdisk.gz
ramroot=/dev/ram0 rw ramdisk_size=65536 initrd=0x81000000,64M
ramrootfstype=ext2
rdaddr=0x81000000
soc=omap3
stderr=serial
stdin=serial
stdout=serial
usbtty=cdc_acm
userbutton=if gpio input 173; then run userbutton_xm; else run userbutton_nonxm; fi;
userbutton_nonxm=gpio input 7;
userbutton_xm=gpio input 4;
validatefdt=if test $beaglerev = xMAB; then if test ! -e mmc ${bootpart} ${bootdir}/${fdtfile}; then setenv fdtfile omap3-beagle-xm.dtb; fi; fi;
vendor=ti
ver=U-Boot 2014.07 (Oct 14 2014 - 11:45:06)
vram=12M

Environment size: 3604/131068 bytes

沒有留言:

張貼留言