欢迎光临散文网 会员登陆 & 注册

u-boot常用命令汇总

2018-05-25 11:37 作者:韦东山  | 我要投稿

我们经常使用uboot命令,虽然资料光盘->常见问题目录有U-boot常用命令汇总文档,但从大家的反馈来看,并没有很多人注意到这个文档,所以把它挪到这里。如此全的uboot命令汇总,建议收藏。

注意:不同版本的uboot,它的命令有所不同,这里使用u-boot 1.1.6。


一、nandflash分区信息

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


二、设置机器ID

set machid 16a // JZ2440,也可以用setenv machid 16a

set machid 7CF // mini2440


三、设置环境变量

print // 打印环境变量

save // 保存环境变量

setenv bootdelay 5                                              // 设置bootdelay 为5 
setenv ipaddr 192.168.1.226                              // 设置开发板ip为192.168.1.226
setenv serverip 192.168.1.200                           // 设置服务器ip为192.168.1.200

setenv gatewayip 192.168.1.1                           // 设置网关为 192.168.1.1
setenv netmask 255.255.255.0                         // 设置子网掩码


// 由于是两条指令,因此需要用单引号引起来

// 读取内核 并启动

setenv bootcmd 'nand read.jffs2 0x30007FC0 kernel ; bootm 0x30007FC0'


// 使用flash中的文件系统启动,默认为yaffs2文件系统,如果是jffs2文件系统,添加 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


举例:

虚拟机ip :192.168.1.2

网关 :192.168.1.1

开发板ip : 192.168.1.3

子网掩码 :255.255.255.0

文件系统目录:/work/nfs_root/xxxx


// 使用nfs网络文件系统启动,默认为yaffs2文件系统,如果是jffs2文件系统,添加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


// 清除某个环境变量

setenv bootargs //以bootargs为例

save

// 清除全部的环境变量

nand erase params


四、tftp烧写

// 通过tftp烧写u-boot.bin到nand Flash步骤:

打开 tftpd32.exe 软件, 将u-boot.bin 拷贝至工作目录

在SecureCRT中依次输入:

tftp 0x30008000 u-boot.bin //将uboot.bin下载到sdram 0x30008000地址处

nand erase bootloader // 擦除bootloader区域

nand write 0x30008000 bootloader // 烧写到bootloader


// 通过tftp烧写uImage到nand Flash步骤:

打开 tftpd32.exe 软件, 将 uImage 拷贝至工作目录

在SecureCRT中依次输入:

tftp 0x30008000 uImage

nand erase kernel

nand write 0x30008000 kernel


// 烧写YAFFS文件系统至Nand Flash

打开 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文件系统至Nand Flash

//使用 jffs2 文件系统启动时记得修改 bootargs 添加 rootfstype=jffs2

打开 tftpd32.exe 软件,将 fs_mini.jffs2 拷贝至工作目录

在SecureCRT中依次输入:

tftp 0x30008000 fs_mini.jffs2

nand erase root

nand write.jffs2 0x30008000 root $(filesize) // $(filesieze) 是fs_mini.yaffs2 大小


当然,之前的所有下载也可以换成 nfs ,

假设虚拟机 ip 为 192.168.1.123

nfs共享目录(在ubuntu 的 /etc/exports设置)为: /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 -

预知更多嵌入式干货,请关注微信公众号baiwenkeji


u-boot常用命令汇总的评论 (共 条)

分享到微博请遵守国家法律