Uboot命令應用
U-Boot 是一個主要用于嵌入式系統的引導加載程序,可以支持多種不同的計算機系統結構,包括PPC、ARM、AVR32、MIPS、x86、68k、Nios與MicroBlaze。這也是一套在GNU通用公共許可證之下發布的自由軟件。
U-Boot本質是一個裸機程序,是一種普遍用于嵌入式系統中的開源的Bootloader,作用是用來引導操作系統,以及給開發人員提供測試調試工具。主要負責基本硬件初始化,導啟動內核啟動。
U-Boot命令眾多,通過uboot命令可完成系統環境變量設置。U-Boot本質就是一份裸機程序,這樣可以在U-Boot命令下調試一些硬件設備問題。U-Boot命令行也是可以實現自動補全功能。
1.查看當前U-Boot支持命令:?或者help
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.打印系統環境變量: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.設置保存環境變量
TINY4412 # set wbyq "uboot test" #設置環境變量
TINY4412 # save #保存環境變量
Saving Environment to SMDK bootable device...
done
4.串口傳輸二進制文件到DDR:laody
??用法:loady [內存地址] [波特率]
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 ]為選填參數。不填則有由系統選擇。
- 示例:
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 #調到指定地址執行
## Starting application at 0x40008000 ...
5.磁盤分區命令:fdisk
-
用法:
??fdisk -p <設備號>
??fdisk -c <設備號> [<系統分區大小(MB)> <用戶數據分區大小> <緩存分區大小>]
??fdisk命令一次實現4個分區
TINY4412 # ? fdisk
fdisk - fdisk for sd/mmc.
Usage:
fdisk -p - print partition information
fdisk -c []
- create partition
- 示例:
TINY4412 # fdisk -p 0 #查看設備0分區信息
partion # size(MB) block start # block count partition_Id
1 14764 309248 30236672 0x0C
TINY4412 # fdisk -c 0 1024 1024 1024 #設置分區
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.安裝文件系統
??當前uboot命令中支持文件系統格式有ext2、ext3、fat32。
-
安裝文件示例
??下面以fat32為例安裝文件系統。
?? 用法:fatformat mmc <設備號:分區號>
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.查看設備指定目錄下文件:fatls
-
用法:
??fatls <設備號:分區號> [目錄路徑]
TINY4412 # ? fatls
fatls - list files in a directory (default /)
Usage:
fatls [directory]
- list files from 'dev' on 'interface' in a 'directory'
//查看設備0的根目錄下的文件
TINY4412 # fatls mmc 0 /
Partition1: Start Address(0x4b800), Size(0x1cd6000)
system volume information/
images/
0 file(s), 2 dir(s)
[:part]>
7.加載設備中二進制文件到內存:fatload
-
用法:
??fatls <設備號:分區號> <內存地址> <文件名> [加載字節數]
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
//從設備0中讀取mian.bin文件到40008000
TINY4412 # fatload mmc 0 40008000 /main.bin
Partition1: Start Address(0x4b800), Size(0x1cd6000)
reading /main.bin
656 bytes read
//跳轉到40008000中執行main.bin文件
TINY4412 # go 40008000
[:part]>
9.mmc子系統
- mmc命令功能
TINY4412 # ? mmc
mmc - MMC sub system
Usage:
mmc read addr blk# cnt #從設備中讀取數據到內存中
mmc write addr blk# cnt #將地址中的數據寫入到設備中
mmc rescan
mmc erase
mmc list - lists available devices
//從設備0中第1057個扇區連續讀12288個扇區到40009000地址中
TINY4412 # mmc read 0 40009000 421 3000
MMC read: dev # 0, block # 1057, count 12288 ... 12288 blocks read: OK
//跳轉到40009000中執行
TINY4412 # bootm 40009000
10.movi子系統
- movi命令功能
movi init 初始化和顯示設備信息。
movi read 從sd或mmc中讀bl1.bin、bl2.bin、uboot、kernel、tzsw.bin文件到指定內存地址中。
movi write 將指定內存地址中bl1.bin、bl2.bin、uboot、kernel、tzsw.bin寫入到sd或mmc中。
movi read rootfs讀根文件系統到指定內存地址中。
movi write rootfs將指定內存地址中根文件系統寫入到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開發板bl1、bl2、uboot、kernel、tzsw、rootfs在SD卡和EMMC中存儲格式:
??將bl1、bl2、uboot、kernel從SD卡拷貝到EMMC中示例:
//從設備0讀取bl1.bin到內存,再寫入到設備1中
movi r f 0 40008000;emmc open 1;movi w z f 1 40008000;emmc close 1;
//從設備0讀取bl2.bin到內存,再寫入到設備1中
movi r b 0 40008000;emmc open 1;movi w z b 1 40008000;emmc close 1;
//從設備0讀取完整uboot到內存,再寫入到設備1中
movi r u 0 40008000;emmc open 1;movi w z u 1 40008000;emmc close 1;
//從設備0讀取kernel到內存,再寫入到設備1中
movi r k 0 40008000;movi w k 1 40008000;
?注意:由于SD卡存儲和EMMC存儲bl1、bl2、uboot、tzsw這幾個文件時總是相冊一個扇區,所以從EMMC中讀取bl1、bl2、uboot、tzsw這幾個文件時要使用movi read zero命令來完成。寫入bl1、bl2、uboot、tzsw這幾個文件到EMMC時要使用movi write zero命令來完成 。
審核編輯:湯梓紅
-
嵌入式
+關注
關注
5068文章
19021瀏覽量
303326 -
命令
+關注
關注
5文章
678瀏覽量
21984 -
Uboot
+關注
關注
4文章
125瀏覽量
28165
發布評論請先 登錄
相關推薦
評論