%http://blog.csdn.net/ghostyu/article/details/6968681
%http://www.denx.de/wiki/view/DULG/Manual
目的:了解 uboot 的命令列操作方式
uboot 是一套廣泛使用在嵌入式系統上之 bootloader,要順利的使用 uboot,必須對其命令列操作方式有所了解,如此一來當 uboot 在開機時發生錯誤的話,才能夠自己一一針對故障進行排除。底下我們將針對 uboot 的指令作概略的說明:
help -> 呼叫可使用之指令,如底下所示:
? - alias for 'help'
askenv - get environment variables from stdin
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
bootz - boot Linux zImage image from memory
chpart - change active partition
cmp - memory compare
coninfo - print console devices and information
cp - memory copy
crc32 - checksum calculation
dcache - enable or disable data cache
dhcp - boot image via network using DHCP/TFTP protocol
echo - echo args to console
editenv - edit environment variable
env - environment handling commands
exit - exit script
ext2load- load binary file from a Ext2 filesystem
ext2ls - list files in a directory (default /)
false - do nothing, unsuccessfully
fatinfo - print information about filesystem
fatload - load binary file from a dos filesystem
fatls - list files in a directory (default /)
fdt - flattened device tree utility commands
go - start application at address 'addr'
gpio - input/set/clear/toggle gpio pins
help - print command description/usage
i2c - I2C sub-system
icache - enable or disable instruction cache
imxtract- extract a part of a multi-image
itest - return true/false on integer compare
led - [0|1|green|all] [on|off|toggle]
load - load binary file from a filesystem
loadb - load binary file over serial line (kermit mode)
loads - load S-Record file over serial line
loadx - load binary file over serial line (xmodem mode)
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
mm - memory modify (auto-incrementing address)
mmc - MMC sub system
mmcinfo - display MMC info
mtdparts- define flash/nand partitions
mw - memory write (fill)
nand - NAND sub-system
nandecc - switch OMAP3 NAND ECC calculation algorithm
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
reset - Perform RESET of the CPU
run - run commands in an environment variable
saveenv - save environment variables to persistent storage
setenv - set environment variables
setexpr - set environment variable as the result of eval expression
showvar - print local hushshell variables
sleep - delay execution for some time
source - run script from memory
test - minimal test like /bin/sh
tftpboot- boot image via network using TFTP protocol
true - do nothing, successfully
usb - USB sub-system
usbboot - boot from USB device
version - print monitor, compiler and linker version
version(v) -> 顯示目前 u-boot 版本,如底下所示:
U-Boot 2013.10 (Nov 15 2013 - 09:58:56)
arm-linux-gnueabi-gcc (Debian 4.4.6-14) 4.4.6
GNU ld (GNU Binutils for Debian) 2.22
usb start -> 啟動 usb 功能,其畫面如下所示:
(Re)start USB...
USB0: ULPI: ulpi_reset: failed writing reset bit
ULPI: ulpi_reset: failed writing reset bit
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 資訊,如底下所示:
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
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 = 0x8FF59000
reloc off = 0x0FE59000
irq_sp = 0x8FEF8F30
sp start = 0x8FEF8F20
mmcinfo -> 顯示目前記憶卡資訊,如底下所示:
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
mmc -> 顯示記憶卡之相關操作指令,如下所示:
Usage:
mmc read addr blk# cnt
mmc write addr blk# cnt
mmc erase blk# cnt
mmc rescan
mmc part - lists available partition on current mmc device
mmc dev [dev] [part] - show or set current mmc device [partition]
mmc list - lists available devices
mmclist -> 顯示目前的記憶卡,如底下所示:
OMAP SD/MMC: 0
mmc rescan -> 重新掃瞄目前板子上有幾張記憶卡
mmc part -> 顯示目前記憶卡上之分割區,如底下所示:
Partition Map for MMC device 0 -- Partition Type: DOS
Part Start Sector Num Sectors UUID Type
1 2048 163840 bafb41f7-01 0b Boot
2 165888 1931264 bafb41f7-02 83
此資訊可搭配之前分割之 sdcard.img 來比較,如下所示:
Device Boot Start End Blocks Id System
/dev/loop0p1 * 2048 165887 81920 b W95 FAT32
/dev/loop0p2 165888 2097151 965632 83 Linux
fatinfo -> 觀看 FAT filesystem 資訊,其語法如下:
fatinfo <interface> [<dev[:part]>]
其中的 interface 是指儲存介面,而 dev:part 則是指其裝置及分割區編號
我們可以執行底下指令來觀看 sdcard.img 的 #1 分割區:
fatinfo mmc 0: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 " "
fatls -> 列出 FAT 分割區之內容,其語法如下:
fatls <interface> [<dev[:part]>] [directory]
因此我們可以執行底下指令來觀看 FAT 檔案系統中之檔案:
fatls mmc 0:1
其輸出如下所示:
2539176 uimage
47164 mlo
1622640 u-boot
346280 u-boot.img
346216 u-boot.bin
2539112 zimage
6 file(s), 0 dir(s)
fatloat -> 載入 FAT 檔案系統中之檔案,其語法如下:
fatload <interface> [<dev[:part]>] <addr> <filename> [bytes [pos]]
現在,我們要將編好的 Linux 核心載入至 ARM 的初始記憶體位置,也就是
0x80000000,我們應該要下底下指令:
fatload mmc 0:1 0x80000000 uImage
其輸出如下所示:
reading uImage
2539176 bytes read in 325 ms (7.5 MiB/s)
這個訊息告訴我們,uboot 已載入 Linux 核心,其檔名為 uImage,根據我們所下的
指令,這個核心被載入至 0x80000000 的位置。
bootm -> 從某個記憶體位置開機,以我們的例子來說,其開機位置為 0x80000000。
因此我們可以下底下指令來開機:
bootm 0x80000000
李教授您好,偶然間在一本linux雜誌上看見您的專欄,才發現您的blog,我目前是一位layout工程師,很想學習有關EDATool的安裝建置,不知2014年您是否有規劃開班授課?可否接受社會人士的報名?又或著您已經出書了呢?因為我找不到您的書!謝謝!
回覆刪除Stanley 您好,
回覆刪除我的講義尚未出版,其中有關 Linux 安裝的部份已經先整理出書,詳情您可參考左側的「64 位元 Debian Linux 作業系統實務」內容,至於 EDA 工具的部份我們可以另外用 E-mail 討論,請寄信至 pmlee@mail.stust.edu.tw,謝謝。