Uboot命令應(yīng)用
U-Boot 是一個主要用于嵌入式系統(tǒng)的引導(dǎo)加載程序,可以支持多種不同的計算機(jī)系統(tǒng)結(jié)構(gòu),包括PPC、ARM、AVR32、MIPS、x86、68k、Nios與MicroBlaze。這也是一套在GNU通用公共許可證之下發(fā)布的自由軟件。
U-Boot本質(zhì)是一個裸機(jī)程序,是一種普遍用于嵌入式系統(tǒng)中的開源的Bootloader,作用是用來引導(dǎo)操作系統(tǒng),以及給開發(fā)人員提供測試調(diào)試工具。主要負(fù)責(zé)基本硬件初始化,導(dǎo)啟動內(nèi)核啟動。
U-Boot命令眾多,通過uboot命令可完成系統(tǒng)環(huán)境變量設(shè)置。U-Boot本質(zhì)就是一份裸機(jī)程序,這樣可以在U-Boot命令下調(diào)試一些硬件設(shè)備問題。U-Boot命令行也是可以實現(xiàn)自動補(bǔ)全功能。
1.查看當(dāng)前U-Boot支持命令:?或者h(yuǎn)elp
TINY4412 # ?
? - alias for 'help'
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
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
dnw - dnw - initialize USB device and ready to receive for Windows server (specific)
echo - echo args to console
editenv - edit environment variable
emmc - Open/Close eMMC boot Partition
env - environment handling commands
exit - exit script
ext2format- ext2format - disk format by ext2
ext2load- load binary file from a Ext2 filesystem
ext2ls - list files in a directory (default /)
ext3format- ext3format - disk format by ext3
false - do nothing, unsuccessfully
fastboot- fastboot- use USB Fastboot protocol
fatformat- fatformat - disk format by FAT32
fatinfo - fatinfo - print information about filesystem
fatload - fatload - load binary file from a dos filesystem
fatls - list files in a directory (default /)
fdisk - fdisk for sd/mmc.
go - start application at address 'addr'
help - print command description/usage
icache - enable or disable instruction cache
iminfo - print header information for application image
imxtract- extract a part of a multi-image
itest - return true/false on integer compare
loadb - load binary file over serial line (kermit mode)
2.打印系統(tǒng)環(huán)境變量:print
TINY4412 # pr
baudrate=115200
bootargs=noinitrd root=/dev/nfs nfsroot=192.168.10.106:/root/work/root_nfs ip=192.168.10.123:192.168.10.106:192.168.10.1:255.255.255.0::eth0:off init=/linuxrc console=ttySAC0 lcd=S702
bootcmd=movi read kernel 0 40008000;movi read rootfs 0 41000000 400000;bootm 40008000 41000000
bootdelay=3
ethaddr=00:40:5c:26:0a:5b
gatewayip=192.168.0.1
ipaddr=192.168.0.20
netmask=255.255.255.0
serverip=192.168.0.10
Environment size: 438/16380 bytes
3.設(shè)置保存環(huán)境變量
TINY4412 # set wbyq "uboot test" #設(shè)置環(huán)境變量
TINY4412 # save #保存環(huán)境變量
Saving Environment to SMDK bootable device...
done
4.串口傳輸二進(jìn)制文件到DDR:laody
??用法:loady [內(nèi)存地址] [波特率]
TINY4412 # ? loady
loady - load binary file over serial line (ymodem mode)
Usage:
loady [ off ] [ baud ]
- load binary file over serial line with offset 'off' and baudrate 'baud'
??[ off ] [ baud ]為選填參數(shù)。不填則有由系統(tǒng)選擇。
- 示例:
TINY4412 # loady 40008000 #啟動接收
## Ready for binary (ymodem) download to 0x40008000 at 0 bps...
CCCCCC
ymodem trl+C ?
正在傳輸 main.bin...
100% 656 164 /0:00:04 1
## Total Size = 0x00000290 = 656 Bytes
TINY4412 # go 40008000 #調(diào)到指定地址執(zhí)行
## Starting application at 0x40008000 ...
5.磁盤分區(qū)命令:fdisk
-
用法:
??fdisk -p <設(shè)備號>
??fdisk -c <設(shè)備號> [<系統(tǒng)分區(qū)大小(MB)> <用戶數(shù)據(jù)分區(qū)大小> <緩存分區(qū)大小>]
??fdisk命令一次實現(xiàn)4個分區(qū)
TINY4412 # ? fdisk
fdisk - fdisk for sd/mmc.
Usage:
fdisk -p - print partition information
fdisk -c []
- create partition
- 示例:
TINY4412 # fdisk -p 0 #查看設(shè)備0分區(qū)信息
partion # size(MB) block start # block count partition_Id
1 14764 309248 30236672 0x0C
TINY4412 # fdisk -c 0 1024 1024 1024 #設(shè)置分區(qū)
fdisk is completed
partion # size(MB) block start # block count partition_Id
1 11715 6422528 23993344 0x0C
2 1024 131072 2097152 0x83
3 1024 2228224 2097152 0x83
4 1024 4325376 2097152 0x83
6.安裝文件系統(tǒng)
??當(dāng)前uboot命令中支持文件系統(tǒng)格式有ext2、ext3、fat32。
-
安裝文件示例
??下面以fat32為例安裝文件系統(tǒng)。
?? 用法:fatformat mmc <設(shè)備號:分區(qū)號>
TINY4412 # ? fatformat
fatformat - fatformat - disk format by FAT32
Usage:
fatformat
- format by FAT32 on 'interface'
TINY4412 # fatformat mmc 0:1
Start format MMC&d partition&d ...
Partition1: Start Address(0x620000), Size(0x16e1c00)
size checking ...
Under 16G
write FAT info: 32
Fat size : 0x2dc3
Erase FAT region...................................................................................................................................................
(only>
7.查看設(shè)備指定目錄下文件:fatls
-
用法:
??fatls <設(shè)備號:分區(qū)號> [目錄路徑]
TINY4412 # ? fatls
fatls - list files in a directory (default /)
Usage:
fatls [directory]
- list files from 'dev' on 'interface' in a 'directory'
//查看設(shè)備0的根目錄下的文件
TINY4412 # fatls mmc 0 /
Partition1: Start Address(0x4b800), Size(0x1cd6000)
system volume information/
images/
0 file(s), 2 dir(s)
[:part]>
7.加載設(shè)備中二進(jìn)制文件到內(nèi)存:fatload
-
用法:
??fatls <設(shè)備號:分區(qū)號> <內(nèi)存地址> <文件名> [加載字節(jié)數(shù)]
TINY4412 # ? fatload
fatload - fatload - load binary file from a dos filesystem
Usage:
fatload [bytes]
- load binary file 'filename' from 'dev' on 'interface'
to address 'addr' from dos filesystem
//從設(shè)備0中讀取mian.bin文件到40008000
TINY4412 # fatload mmc 0 40008000 /main.bin
Partition1: Start Address(0x4b800), Size(0x1cd6000)
reading /main.bin
656 bytes read
//跳轉(zhuǎn)到40008000中執(zhí)行main.bin文件
TINY4412 # go 40008000
[:part]>
9.mmc子系統(tǒng)
- mmc命令功能
- mmc read 從指定設(shè)備中讀數(shù)據(jù)到內(nèi)存
- mmc write 將指定內(nèi)存中的數(shù)據(jù)寫到設(shè)備中
- mmc rescan 掃描檢測硬件改動
- mmc erase 擦除
- mmc list列舉可用設(shè)備
TINY4412 # ? mmc
mmc - MMC sub system
Usage:
mmc read addr blk# cnt #從設(shè)備中讀取數(shù)據(jù)到內(nèi)存中
mmc write addr blk# cnt #將地址中的數(shù)據(jù)寫入到設(shè)備中
mmc rescan
mmc erase
mmc list - lists available devices
//從設(shè)備0中第1057個扇區(qū)連續(xù)讀12288個扇區(qū)到40009000地址中
TINY4412 # mmc read 0 40009000 421 3000
MMC read: dev # 0, block # 1057, count 12288 ... 12288 blocks read: OK
//跳轉(zhuǎn)到40009000中執(zhí)行
TINY4412 # bootm 40009000
10.movi子系統(tǒng)
- movi命令功能
movi init 初始化和顯示設(shè)備信息。
movi read 從sd或mmc中讀bl1.bin、bl2.bin、uboot、kernel、tzsw.bin文件到指定內(nèi)存地址中。
movi write 將指定內(nèi)存地址中bl1.bin、bl2.bin、uboot、kernel、tzsw.bin寫入到sd或mmc中。
movi read rootfs讀根文件系統(tǒng)到指定內(nèi)存地址中。
movi write rootfs將指定內(nèi)存地址中根文件系統(tǒng)寫入到sd或mmc中。
TINY4412 # ? movi
movi - movi - sd/mmc r/w sub system for SMDK board
Usage:
movi init - Initialize moviNAND and show card info
movi read zero {fwbl1 | u-boot} {device_number} {addr} - Read data from sd/mmc
movi write zero {fwbl1 | u-boot} {device_number} {addr} - Read data from sd/mmc
movi read {u-boot | kernel} {device_number} {addr} - Read data from sd/mmc
movi write {fwbl1 | u-boot | kernel} {device_number} {addr} - Write data to sd/mmc
movi read rootfs {device_number} {addr} [bytes(hex)] - Read rootfs data from sd/mmc by size
movi write rootfs {device_number} {addr} [bytes(hex)] - Write rootfs data to sd/mmc by size
movi read {sector#} {device_number} {bytes(hex)} {addr} - instead of this, you can use "mmc read"
movi write {sector#} {device_number} {bytes(hex)} {addr} - instead of this, you can use "mmc write"
??tiny4412開發(fā)板bl1、bl2、uboot、kernel、tzsw、rootfs在SD卡和EMMC中存儲格式:
??將bl1、bl2、uboot、kernel從SD卡拷貝到EMMC中示例:
//從設(shè)備0讀取bl1.bin到內(nèi)存,再寫入到設(shè)備1中
movi r f 0 40008000;emmc open 1;movi w z f 1 40008000;emmc close 1;
//從設(shè)備0讀取bl2.bin到內(nèi)存,再寫入到設(shè)備1中
movi r b 0 40008000;emmc open 1;movi w z b 1 40008000;emmc close 1;
//從設(shè)備0讀取完整uboot到內(nèi)存,再寫入到設(shè)備1中
movi r u 0 40008000;emmc open 1;movi w z u 1 40008000;emmc close 1;
//從設(shè)備0讀取kernel到內(nèi)存,再寫入到設(shè)備1中
movi r k 0 40008000;movi w k 1 40008000;
?注意:由于SD卡存儲和EMMC存儲bl1、bl2、uboot、tzsw這幾個文件時總是相冊一個扇區(qū),所以從EMMC中讀取bl1、bl2、uboot、tzsw這幾個文件時要使用movi read zero命令來完成。寫入bl1、bl2、uboot、tzsw這幾個文件到EMMC時要使用movi write zero命令來完成 。
審核編輯:湯梓紅
-
嵌入式
+關(guān)注
關(guān)注
5060文章
18975瀏覽量
302094 -
命令
+關(guān)注
關(guān)注
5文章
678瀏覽量
21965 -
Uboot
+關(guān)注
關(guān)注
4文章
125瀏覽量
28127
發(fā)布評論請先 登錄
相關(guān)推薦
評論