Uboot命令的使用

学习资料:
 

记录一次uboot启动log打印:

U-Boot 2016.03 (Mar 18 2024 - 01:07:08 +0800)    // 编译时间2024/03/18 01:07:08

CPU:   Freescale i.MX6ULL rev1.1 69 MHz (running at 396 MHz)    // CPU运行在396MHZ
CPU:   Industrial temperature grade (-40C to 105C) at 48C    
Reset cause: POR
Board: MX6ULL 14x14 EVK
I2C:   ready    // i2c准备就绪
DRAM:  512 MiB    // 内存512M
MMC:   FSL_SDHC: 0, FSL_SDHC: 1    // 两个MMC控制器,0接的是SD卡,1接的是EMMC
*** Warning - bad CRC, using default environment

Display: TFT43AB (480x272)    // LCD型号和格式
Video: 480x272x24    // 24表示RGB888格式LCD
In:    serial        // 标准输入
Out:   serial        // 标准输出
Err:   serial        // 标准错误
switch to partitions #0, OK    // 切换到了emmc的第0个分区
mmc1(part 0) is current device 
Net:   Board Net Initialization Failed    // net初始化失败
No ethernet found.
Normal Boot
Hit any key to stop autoboot:  0
 

uboot下支持的命令:

=> help
?       - alias for 'help'
base    - print or set address offset
bdinfo  - print Board Info structure
bmode   - sd1|sd2|qspi1|normal|usb|sata|ecspi1:0|ecspi1:1|ecspi1:2|ecspi1:3|esdhc1|esdhc2|esdhc3|esdhc4 [noreset]
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
bootz   - boot Linux zImage image from memory
clocks  - display clocks
cmp     - memory compare
coninfo - print console devices and information
cp      - memory copy
crc32   - checksum calculation
dcache  - enable or disable data cache
dhcp    - boot image via network using DHCP/TFTP protocol
dm      - Driver model low level access
echo    - echo args to console
editenv - edit environment variable
env     - environment handling commands
erase   - erase FLASH memory
exit    - exit script
ext2load- load binary file from a Ext2 filesystem
ext2ls  - list files in a directory (default /)
ext4load- load binary file from a Ext4 filesystem
ext4ls  - list files in a directory (default /)
ext4size- determine a file's size
ext4write- create a file in the root directory
false   - do nothing, unsuccessfully
fatinfo - print information about filesystem
fatload - load binary file from a dos filesystem
fatls   - list files in a directory (default /)
fatsize - determine a file's size
fatwrite- write file into a dos filesystem
fdt     - flattened device tree utility commands
flinfo  - print FLASH memory information
fstype  - Look up a filesystem type
fuse    - Fuse sub-system
go      - start application at address 'addr'
gpio    - query and control gpio pins
help    - print command description/usage
i2c     - I2C sub-system
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
load    - load binary file from a filesystem
loadb   - load binary file over serial line (kermit mode)
loads   - load S-Record file over serial line
loadx   - load binary file over serial line (xmodem mode)
loady   - load binary file over serial line (ymodem mode)
loop    - infinite loop on address range
ls      - list files in a directory (default /)
md      - memory display
mdio    - MDIO utility commands
mii     - MII utility commands
mm      - memory modify (auto-incrementing address)
mmc     - MMC sub system
mmcinfo - display MMC info
mtest   - simple RAM read/write test
mw      - memory write (fill)
nfs     - boot image via network using NFS protocol
nm      - memory modify (constant address)
ping    - send ICMP ECHO_REQUEST to network host
pmic    - PMIC
printenv- print environment variables
protect - enable or disable FLASH write protection
reset   - Perform RESET of the CPU
run     - run commands in an environment variable
save    - save file to a filesystem
saveenv - save environment variables to persistent storage
setenv  - set environment variables
setexpr - set environment variable as the result of eval expression
sf      - SPI flash sub-system
showvar - print local hushshell variables
size    - determine a file's size
sleep   - delay execution for some time
source  - run script from memory
test    - minimal test like /bin/sh
tftpboot- boot image via network using TFTP protocol
true    - do nothing, successfully
usb     - USB sub-system
usbboot - boot from USB device
version - print monitor, compiler and linker version

 

1、信息查询命令

bdinfo:查看板子信息
=> bdinfo arch_number = 0x00000000 boot_params = 0x80000100 DRAM bank = 0x00000000 -> start = 0x80000000 -> size = 0x20000000 eth0name = FEC1 ethaddr = (not set) current eth = FEC1 ip_addr = <NULL> baudrate = 115200 bps TLB addr = 0x9FFF0000 relocaddr = 0x9FF56000 reloc off = 0x18756000 irq_sp = 0x9EF53EA0 sp start = 0x9EF53E90
  • arch_number = 0x00000000:表示体系结构号为0。
  • boot_params = 0x80000100:引导参数的地址为0x80000100。
  • DRAM bank = 0x00000000:
    • start = 0x80000000:DRAM bank的起始地址为0x80000000。
    • size = 0x20000000:DRAM bank的大小为0x20000000,即536870912字节(约512MB)。
  • eth0name = FEC1:网卡eth0的名称为FEC1。
  • ethaddr = (not set):网卡eth地址未设置。
  • current eth = FEC1:当前网卡为FEC1。
  • ip_addr = :IP地址未设置。
  • baudrate = 115200 bps:波特率为115200 bps。
  • TLB addr = 0x9FFF0000:TLB地址为0x9FFF0000。
  • relocaddr = 0x9FF56000:重定位地址为0x9FF56000。
  • reloc off = 0x18756000:重定位偏移为0x18756000。
  • irq_sp = 0x9EF53EA0:中断服务程序堆栈指针地址为0x9EF53EA0。
  • sp start = 0x9EF53E90:堆栈指针的起始地址为0x9EF53E90。
printenv:输出环境变量信息
version:查看uboot版本号
 

2、环境变量操作命令

setenv:设置或新建环境变量
saveenv:保存环境变量
 

3、内存操作函数

md:查看显示内存值,md显示默认md.l,md.b、md.w、md.l分别显示1字节、2字节、4字节
nm:修改指定地址内存的值
mm:修改指定地址内存的值,相对nm对地址自增
cp:内存拷贝命令
cmp:内存比较命令
 

4、网络操作命令

setenv ipaddr:设置ip地址,ip地址可以自己设置也可以使用dhcp获取
setenv ethaddr:设置MAC地址,mac地址在同一局域网下不能设置成一样的
setenv gatewayip:设置网关地址
setenv netmask:设置子网掩码
setenv serverip:设置服务器IP地址,设置为主机ip地址
ping:ping网络操作
dhcp:用于从路由器获取 IP 地址
nfs:nfs挂载,设置nfs文件夹,单板可直接通过nfs协议下载
tftp:ubuntu主机作为tftp服务器
 

问题解决:

问题一:
0
主机和单板连接到同一路由器上,vmware虚拟机使用桥接模式,如下:
0
 
问题二:
uboot下使用nfs挂载失败参考博客:
 

5、MMC基础操作命令

mmc info:当前选中的设备信息
mmc rescan:扫描mmc设备
mmc list:显示设备是sd卡还是emmc
mmc dev:mmc dev 0切换到第一个mmc设备,mmc dev 1 0切换到第二个mmc设备的分区0
mmc part:查看分区
mmc read:读取mmc设备的数据
mmc write:对mmc设备进行写操作
mmc erase:mmc擦除操作
 

6、MMC文件操作命令

对于imx6u来说,SD/EMMC分为三个分区
第一个:存放uboot
第二个:存放linux aImage,.dtb,这些是FAT格式的
第三个:系统的根文件系统,EXT4格式
 
fat info:查看mmc设置设备分区的文件系统信息
fatls:查询FAT格式设备的目录和文件信息
fstype:查看MMC设备某个分区的文件系统格式
fatload:用于将指定的文件读取到DRAM中**
fatwrite:写到emmc中
 
uboot 有 ext2 和 ext4 这两种格式的文件系统的操作命令,常用的就四个命令,分别为:ext2load、ext2ls、ext4load、ext4ls 和 ext4write
ext4ls :ext4文件格式查看
ext4load:ex4文件格式镜像搬运到DRAM
ext4write:ext4文件格式写到emmc中
 

7、BOOT操作命令

bootz:要启动linux,需要先将linux镜像文件拷贝到DDR中,如果使用到设备树的话也需要将设备树拷贝到DDR中,也可以从EMMC或者NAND等存储设备中将Linux镜像和设备树文件拷贝到DDR中,也可以通过nfs或者tftp将linux镜像文件和设备树文件下载到DDR中,然后使用bootz命令来启动,bootz命令用于自动zImage镜像文件,bootz命令格式如下:
bootz [addr [initrd[:size]] [fdt]]
 
bootm:bootm用于uImage
boot:boot 命令也是用来启动 Linux 系统的,只是 boot 会读取环境变量 bootcmd 来启动 Linux 系统
booti:引导 ARM64 内核镜像
 

8、其他操作命令

fdt addr 83000000
fdt print
reset:复位
go:用于跳转到指定的地址处执行应用,例如printf.bin。load.imx前面的头部是bootm要获取信息
run:用于运行环境变量中定义的命令
mtest:内存测试命令
 
 
 
 
posted @ 2024-03-20 19:24  lethe1203  阅读(64)  评论(0编辑  收藏  举报