U-Boot常用命令
2025-07-22
93
0
信息查询命令
- version:显示U-Boot 的版本号、编译时间等信息
- printenv:显示前所有的环境变量
- help:列出所有支持的命令及其简要说明。
- bdinf:显示开发板相关信息,如内存大小、时钟频率等
启动命令
- reset:复位开发板并重启。
- go address:跳转到指定的内存地址开始执行代码,不会传递任何参数。用于执行简单的裸机程序
- run var_name:行一个环境变量中定义的命令序列(宏),如run bootcmd
bootcmd=tftp 80800000 zImage; tftp 83000000 imx6ull-14x14-evk-emmc.dtb;bootz 80800000 - 83000000 - boot:boot 会读取环境变量 bootcmd 来启动
- 启动命令主要是bootz和bootm
| 特性 | bootz | bootm |
|---|---|---|
| 架构 | 启动ARM架构的Linux内核 | 启动多种格式的内核 |
| 镜像格式 | zImage | uImage, zImage, FIT等 |
| 压缩处理 | 自动解压zImage | 依赖镜像格式 |
| 使用场景 | 现代ARM Linux启动 | 传统和通用启动 |
| 语法 | bootz kernel_addr - dtb_addr |
bootm kernel_addr |
# bootz 示例(ARM)
bootz 0x80000000 - 0x83000000
# bootm 示例(通用)
bootm 0x80000000
# bootm 使用uImage
bootm 0x82000000
环境变量操作命令
- setenv:设置或修改一个环境变量的值,这个修改只在当前会话中有效,掉电会丢失。
- saveenv:保存当前所有环境变量到 Flash(通常是 NOR/NAND/eMMC/SPI Flash)中,永久生效。对于一个环境变量设置值为空,则删除该环境变量。
- env default -a:清除uboot环境变量,所有环境变量恢复为编译时的默认值。
bootargs是uboot传递给kernel的参数,所以得先有kernel。
setenv bootargs 'console=ttyS0,115200 root=/dev/mtdblock3'
env default -a
saveenv
网络操作命令
- ping:试与另一台主机的网络连通性。 如ping 192.168.1.103
- dhcp:d用于从路由器获取 IP 地址
- tftp:从TFTP服务器下载一个文件到指定的内存地址。如
tftp 0x30000000 uImage - nfs:使用nfs从服务器下载到指定的内存地址
命 令 中 的 “ 80800000 ”表示 zImage 保 存在DRAM中的地址 ,“192.168.1.253:/home/zuozhongkai/linux/nfs/zImage”表示 zImage 在 192.168.1.253 这个主机中, 路径为/home/zuozhongkai/linux/nfs/zImage。nfs 80800000 192.168.1.253:/home/zuozhongkai/linux/nfs/zImage
3. 内存操作命令
用于读、写、拷贝内存。地址通常用十六进制表示。
md [.b, .w, .l] <address> [# of objects]- 功能:Memory Display。显示指定内存地址处的内容。
.b(byte),.w(word, 2 bytes),.l(long, 4 bytes) 分别指定显示单位。 - 用法:
md.l 0x30000000 20(显示从0x30000000开始的 32 个 long 型数据)
- 功能:Memory Display。显示指定内存地址处的内容。
mm [.b, .w, .l] <address>- 功能:Memory Modify。修改指定内存地址处的内容,会进入交互模式。
mw [.b, .w, .l] <address> <value> [count]- 功能:Memory Write。向指定内存地址写入一个值。
- 用法:
mw.l 0x30000000 0x12345678
cp [.b, .w, .l] <source_addr> <dest_addr> <count>- 功能:Memory Copy。在内存之间拷贝数据。
- 用法:
cp.b 0x30000000 0x31000000 0x1000
4. Flash 操作命令 (NAND/NOR/SPI/eMMC)
用于擦除和读写 Flash 存储器。
nand <command> [args](NAND Flash)nand info: 显示 NAND Flash 的信息。nand device: 列出或选择当前 NAND 设备。nand erase <offset> <size>: 擦除指定偏移和大小的区域。在写之前必须先擦除。nand read <mem_addr> <offset> <size>: 从 NAND 读取数据到内存。nand write <mem_addr> <offset> <size>: 将内存中的数据写入到 NAND。
sf <command> [args](SPI Flash)sf probe: 探测并初始化 SPI Flash。sf erase <offset> <size>: 擦除。sf read <mem_addr> <offset> <size>: 读。sf write <mem_addr> <offset> <size>: 写。
mmc <command> [args](eMMC/SD Card)mmc info: 显示 MMC 设备信息。mmc rescan: 重新扫描 MMC 设备。mmc read <mem_addr> <block_start> <block_count>: 读。mmc write <mem_addr> <block_start> <block_count>: 写。
命令大全
=> ?
? - 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
UBOOT环境配置及系统烧写





