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命令来完成 。
审核编辑:汤梓红
-
嵌入式
+关注
关注
5072文章
19028浏览量
303534 -
命令
+关注
关注
5文章
678浏览量
21987 -
Uboot
+关注
关注
4文章
125浏览量
28168
发布评论请先 登录
相关推荐
评论