u-boot常用命令匯總

我們經(jīng)常使用uboot命令,雖然資料光盤->常見(jiàn)問(wèn)題目錄有U-boot常用命令匯總文檔,但從大家的反饋來(lái)看,并沒(méi)有很多人注意到這個(gè)文檔,所以把它挪到這里。如此全的uboot命令匯總,建議收藏。
注意:不同版本的uboot,它的命令有所不同,這里使用u-boot 1.1.6。
一、nandflash分區(qū)信息
OpenJTAG>mtdpart
device nand0 <nandflash0>, # parts = 4
#:
name ? ? ? ? ? ? ?size ? ? ? ? ? ? ? ?offset
0: bootloader 0x00040000 ?0x00000000
1: params ? ? 0x00020000 ? 0x00040000
2: kernel ? ? ? 0x00200000 ? 0x00060000
3: root ? ? ? ? ? 0x0fba0000 ? ?0x00460000
二、設(shè)置機(jī)器ID
set machid 16a // JZ2440,也可以用setenv machid 16a
set machid 7CF // mini2440
三、設(shè)置環(huán)境變量
print // 打印環(huán)境變量
save // 保存環(huán)境變量
setenv bootdelay 5 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?// 設(shè)置bootdelay 為5?
setenv ipaddr 192.168.1.226 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?// 設(shè)置開(kāi)發(fā)板ip為192.168.1.226
setenv serverip 192.168.1.200 ? ? ? ? ? ? ? ? ? ? ? ? ? // 設(shè)置服務(wù)器ip為192.168.1.200
setenv gatewayip 192.168.1.1 ? ? ? ? ? ? ? ? ? ? ? ? ? // 設(shè)置網(wǎng)關(guān)為 192.168.1.1
setenv netmask 255.255.255.0 ? ? ? ? ? ? ? ? ? ? ? ? // 設(shè)置子網(wǎng)掩碼
// 由于是兩條指令,因此需要用單引號(hào)引起來(lái)
// 讀取內(nèi)核 并啟動(dòng)
setenv bootcmd 'nand read.jffs2 0x30007FC0 kernel ; bootm 0x30007FC0'
// 使用flash中的文件系統(tǒng)啟動(dòng),默認(rèn)為yaffs2文件系統(tǒng),如果是jffs2文件系統(tǒng),添加 rootfstype=jffs2
// yaffs2
setenv bootargs noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0,115200
// jffs2?
setenv bootargs noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0,115200rootfstype=jffs2
舉例:
虛擬機(jī)ip :192.168.1.2
網(wǎng)關(guān) :192.168.1.1
開(kāi)發(fā)板ip : 192.168.1.3
子網(wǎng)掩碼 :255.255.255.0
文件系統(tǒng)目錄:/work/nfs_root/xxxx
// 使用nfs網(wǎng)絡(luò)文件系統(tǒng)啟動(dòng),默認(rèn)為yaffs2文件系統(tǒng),如果是jffs2文件系統(tǒng),添加rootfstype=jffs2
// yaffs2 ,注意是一行
setenv bootargs noinitrd root=/dev/nfs console=ttySAC0
nfsroot=192.168.1.2:/work/nfs_root/xxxx
ip=192.168.1.3:192.168.1.2:192.168.1.1:255.255.255.0::eth0:off init=/linuxrc
// jffs2 ,注意是一行
setenv bootargs noinitrd root=/dev/nfs console=ttySAC0
nfsroot=192.168.1.2:/work/nfs_root/xxxx
ip=192.168.1.3:192.168.1.2:192.168.1.1:255.255.255.0::eth0:off init=/linuxrc?rootfstype=jffs2
// 清除某個(gè)環(huán)境變量
setenv bootargs //以bootargs為例
save
// 清除全部的環(huán)境變量
nand erase params
四、tftp燒寫
// 通過(guò)tftp燒寫u-boot.bin到nand Flash步驟:
打開(kāi) tftpd32.exe 軟件, 將u-boot.bin 拷貝至工作目錄
在SecureCRT中依次輸入:
tftp 0x30008000 u-boot.bin?//將uboot.bin下載到sdram 0x30008000地址處
nand erase bootloader // 擦除bootloader區(qū)域
nand write 0x30008000 bootloader // 燒寫到bootloader
// 通過(guò)tftp燒寫uImage到nand Flash步驟:
打開(kāi) tftpd32.exe 軟件, 將 uImage 拷貝至工作目錄
在SecureCRT中依次輸入:
tftp 0x30008000 uImage
nand erase kernel
nand write 0x30008000 kernel
// 燒寫YAFFS文件系統(tǒng)至Nand Flash
打開(kāi) tftpd32.exe 軟件, 將 fs_mini.yaffs2 拷貝至工作目錄
在SecureCRT中依次輸入:
tftp 0x30008000 fs_mini.yaffs2
nand erase root
nand write.yaffs 0x30008000 root $(filesize) // $(filesieze) 是fs_mini.yaffs2 的大小
// 燒寫JFFS文件系統(tǒng)至Nand Flash
//使用 jffs2 文件系統(tǒng)啟動(dòng)時(shí)記得修改 bootargs 添加 rootfstype=jffs2
打開(kāi) tftpd32.exe 軟件,將 fs_mini.jffs2 拷貝至工作目錄
在SecureCRT中依次輸入:
tftp 0x30008000 fs_mini.jffs2
nand erase root
nand write.jffs2 0x30008000 root $(filesize) // $(filesieze) 是fs_mini.yaffs2 大小
當(dāng)然,之前的所有下載也可以換成 nfs ,
假設(shè)虛擬機(jī) ip 為 192.168.1.123
nfs共享目錄(在ubuntu 的 /etc/exports設(shè)置)為: /work/nfs_root
那么nfs下載命令如下:
nfs 0x30008000 192.168.1.123:/work/nfs_root/u-boot.bin // nfs下載u-boot.bin
nfs 0x30008000 192.168.1.123:/work/nfs_root/uImage // nfs下載uImage
nfs 0x30008000 192.168.1.123:/work/nfs_root/fs_mini.yaffs2 // nfs下載fs_mini.yaffs2
nfs 0x30008000 192.168.1.123:/work/nfs_root/fs_mini.jffs2 // nfs下載fs_mini.jffs2?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? - end -
預(yù)知更多嵌入式干貨,請(qǐng)關(guān)注微信公眾號(hào)baiwenkeji