Uboot 常用命令

目   录

帮助命令

查询命令

        bdinfo

        printenv

        version

环境变量操作命令

         新建环境变量

        删除环境变量

内存操作命令

        md

        nm

        mm

        mw

        cp

        cmp

 网络操作命令

        ping

        dhcp

        nfs

        tftp

EMMC和SD操作命令

        mmc info 

        mmc list

        mmc rescan

        mmc part

        mmc dev

        mmc read

        mmc write

EXT 格式文件系统操作命令

        ext4ls

        ext4load

        ext4write


        进入 STM32MP>   命令行

帮助命令

        输入help或者?会打印出当前使能的命令。

?         - alias for 'help'
adc       - ADC sub-system
base      - print or set address offset
bdinfo    - print Board Info structure
blkcache  - block cache diagnostics and control
bmp       - manipulate BMP image data
boot      - boot default, i.e., run 'bootcmd'
bootcount - bootcount
bootd     - boot default, i.e., run 'bootcmd'
bootefi   - Boots an EFI payload from memory
bootm     - boot application image from memory
bootp     - boot image via network using BOOTP/TFTP protocol
bootstage - Boot stage command
bootz     - boot Linux zImage image from memory
chpart    - change active partition
clk       - CLK sub-system
cls       - clear screen
cmp       - memory compare
coninfo   - print console devices and information
cp        - memory copy
crc32     - checksum calculation
date      - get/set/reset date & time
dcache    - enable or disable data cache
dfu       - Device Firmware Upgrade
dhcp      - boot image via network using DHCP/TFTP protocol
dm        - Driver model low level access
dtimg     - manipulate dtb/dtbo Android image
echo      - echo args to console
editenv   - edit environment variable
env       - environment handling commands
erase     - erase FLASH memory
eraseenv  - erase environment variables from persistent storage
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
fastboot  - run as a fastboot usb or udp device
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
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
gpt       - GUID Partition Table
help      - print command description/usage
i2c       - I2C sub-system
icache    - enable or disable instruction cache
itest     - return true/false on integer compare
lcdputs   - print string on video framebuffer
led       - manage LEDs
ln        - Create a symbolic link
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
meminfo   - display memory information
mii       - MII utility commands
mm        - memory modify (auto-incrementing address)
mmc       - MMC sub system
mmcinfo   - display MMC info
mtd       - MTD utils
mtdparts  - define flash/nand partitions
mtest     - simple RAM read/write test
mw        - memory write (fill)
nand      - NAND sub-system
nboot     - boot from NAND device
nfs       - boot image via network using NFS protocol
nm        - memory modify (constant address)
part      - disk partition related commands
ping      - send ICMP ECHO_REQUEST to network host
pinmux    - show pin-controller muxing
pmic      - PMIC sub-system
poweroff  - Perform POWEROFF of the device
printenv  - print environment variables
protect   - enable or disable FLASH write protection
pxe       - commands to get and boot from pxe files
random    - fill memory with random pattern
regulator - uclass operations
reset     - Perform RESET of the CPU
rproc     - Control operation of remote processors in an SoC
run       - run commands in an environment variable
save      - save file to a filesystem
saveenv   - save environment variables to persistent storage
setcurs   - set cursor position within screen
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
sspi      - SPI utility command
stboard   - read/write board reference in OTP
stm32key  - Fuse ST Hash key
stm32prog - <link> <dev> [<addr>] [<size>]
start communication with tools STM32Cubeprogrammer on <link> with Flashlayout at <addr>
sysboot   - command to get and boot from syslinux files
test      - minimal test like /bin/sh
tftpboot  - boot image via network using TFTP protocol
time      - run commands and summarize execution time
timer     - access the system timer
true      - do nothing, successfully
ubi       - ubi commands
ubifsload - load file from an UBIFS filesystem
ubifsls   - list files in a directory
ubifsmount- mount UBIFS volume
ubifsumount- unmount UBIFS volume
ums       - Use the UMS [USB Mass Storage]
usb       - USB sub-system
usbboot   - boot from USB device
version   - print monitor, compiler and linker version

查询命令

        bdinfo

                直接输入bdinfo 输出板子信息

        printenv

                直接输入printenv或者print输出环境变量信息

        version

                查看当前uboot版本号

环境变量操作命令

        环境变量的操作涉及到两个命令:setenv saveenv setenv 命令用于设置或者修改环境变
量的值。命令 saveenv 用于保存修改后的环境变量,一般环境变量存放在外部 flash 中, uboot
启动的时候会将环境变量从 flash 读取到 DRAM 中。所以使用命令 setenv 修改的是 DRAM
中的环境变量值,修改以后要使用 saveenv 命令将修改后的环境变量保存到 flash 中,否则
uboot 下一次重启会继续使用以前的环境变量值。

                比如我们要将环境变量 bootdelay 改为 5,就可以使用如下所示命令:

            setenv bootdelay 5

            saveenv

         新建环境变量

                setenv 变量名  变量内容

                saveenv

        删除环境变量

                setenv  变量名  内容不写

                saveenv

内存操作命令

        内存操作命令就是用于直接对 DRAM 进行读写操作的,常用的内存操作命令有 mdnm

mm mw cp cmp。

        md

                md 命令用于显示内存值

                md[.b, .w, .l] address [# of objects]

               命令中的[.b .w .l]对应 byteword long,也就是分别以 1 个字节、2 个字节、4 个字节来显示内存值。address 就是要查看的内存起始地址,[# of objects]表示要查看的数据长度,这个数据长度单位不是字节,而是跟你所选择的显示格式有关。

                uboot 命令中的数字都是十六进制的!不是十进制的!

                比如你想查看 0XC0100000 开始的 20 个字节的内存值,显示格式为 .b 的话,应该使用如下所示命令:
                md.b C0100000 14

                 而不是:

                md.b C0100000 20

        nm

                nm 命令用于修改指定地址内存值

                nm [.b, .w, .l] address

        mm

                mm 命令也是修改指定地址内存值的,使用 mm 修改内存值的时候地址会自增,而使用 nm 命令的话地址不会自增。

        mw

                命令 mw 用于使用一个指定的数据填充一段内存。

                mw [.b, .w, .l] address value [count]

        cp

                cp 是数据拷贝命令,用于将 DRAM 中的数据从一段内存拷贝到另一段内存中,或者把 NorFlash 中的数据拷贝到 DRAM 中。

                cp [.b, .w, .l] source target count

        cmp

                cmp 是比较命令,用于比较两段内存的数据是否相等

                cmp [.b, .w, .l] addr1 addr2 count

 网络操作命令

        uboot 是支持网络的,我们在移植 uboot 的时候一般都要调通网络功能,因为在移植 linux kernel 的时候需要使用到 uboot 的网络功能做调试。uboot 支持大量的网络相关命令,比如 dhcp、 pingnfs tftpboot。

环境变量
描述
ipaddr
开发板 ip 地址,可以不设置,使用 dhcp 命令来从路由器获取 IP 地址。
ethaddr
开发板的 MAC 地址,一定要设置。
gatewayip
网关地址。
netmask
子网掩码。
serverip
服务器 IP 地址,也就是 Ubuntu 主机 IP 地址,用于调试代码。
setenv ipaddr 192.168.1.141  //找一个没有被使用的IP
setenv ethaddr b8:ae:1d:01:01:00
setenv gatewayip 192.168.1.1
setenv netmask 255.255.255.0
setenv serverip 192.168.1.249  //虚拟机的IP
saveenv

        ping

        ping IP

        dhcp

        dhcp 用于从路由器获取 IP 地址,前提是开发板得连接到路由器上的,如果开发板是和电脑直连的,那么 dhcp 命令就会失效。直接输入 dhcp 命令即可通过路由器获取到 IP 地址。

        nfs

        

        tftp

        

EMMC和SD操作命令

        uboot 支持 EMMC SD 卡,因此也要提供 EMMC SD 卡的操作命令。一般认为 EMMC 和 SD 卡是同一个东西,所以没有特殊说明,本教程统一使用 MMC 来代指 EMMC SD 卡。 uboot 中常用于操作 MMC 设备的命令为“mmc”。        

        通过 ?  mmc查询相关命令

        

mmc - MMC sub system

Usage:
mmc info - display info of the current MMC device
mmc read addr blk# cnt
mmc write addr blk# cnt
mmc erase blk# cnt
mmc rescan
mmc part - lists available partition on current mmc device
mmc dev [dev] [part] - show or set current mmc device [partition]
mmc list - lists available devices
mmc hwpartition [args...] - does hardware partitioning
  arguments (sizes in 512-byte blocks):
    [user [enh start cnt] [wrrel {on|off}]] - sets user data area attributes
    [gp1|gp2|gp3|gp4 cnt [enh] [wrrel {on|off}]] - general purpose partition
    [check|set|complete] - mode, complete set partitioning completed
  WARNING: Partitioning is a write-once setting once it is set to complete.
  Power cycling is required to initialize partitions after set to complete.
mmc bootbus dev boot_bus_width reset_boot_bus_width boot_mode
 - Set the BOOT_BUS_WIDTH field of the specified device
mmc bootpart-resize <dev> <boot part size MB> <RPMB part size MB>
 - Change sizes of boot and RPMB partitions of specified device
mmc partconf dev [boot_ack boot_partition partition_access]
 - Show or change the bits of the PARTITION_CONFIG field of the specified device
mmc rst-function dev value
 - Change the RST_n_FUNCTION field of the specified device
   WARNING: This is a write-once field and 0 / 1 / 2 are the only valid values.
mmc setdsr <value> - set DSR register value

        mmc info 

                直接输入命令 mmc info

        mmc list

                mmc list 命令用于来查看当前开发板一共有几个 MMC 设备.

                输入mmc list

        mmc rescan

                mmc rescan 命令用于扫描当前开发板上所有的 MMC 设备,包括 EMMC SD 卡。

                mmc rescan

        mmc part

                有时候 SD 卡或者 EMMC 会有多个分区,可以使用命令“mmc part”来查看其分区。

                mmc part

        mmc dev

                mmc dev 命令用于切换当前 MMC 设备。

                mmc dev [dev] [part]

        mmc read

                mmc read 命令用于读取 mmc 设备的数据。

                mmc read addr blk# cnt

                 addr 是数据读取到 DRAM 中的地址,blk 是要读取的块起始地址(十六进制),一个块是 512 字节,这里的块和扇区是一个意思,在 MMC 设备中我们通常说扇区,cnt 是要读取的块数量(十六进制)

        mmc write

                mmc write addr blk# cnt                

                原理同上。

EXT 格式文件系统操作命令

        ext4ls

                ext4ls 命令用于查询 EXT4 格式设备的目录和文件信息.

                ext4ls <interface> [<dev[:part]>] [directory]

                interface 是要查询的接口,比如 mmcdev 是要查询的设备号,part 是要查询的分区,directory是要查询的目录。

        ext4load

                extload 命令用于将指定的文件读取到 DRAM 中。

                ext4load <interface>  [<dev[:part]>  [addr [filename [bytes [pos]]]]]

                 interface 为接口,比如 mmcdev 是设备号,part 是分区,addr 是保存在 DRAM 中的起始地址,filename 是要读取的文件名字。bytes 表示读取多少字节的数据,如果 bytes 0 或者省略的话表示读取整个文件。pos 是要读的文件相对于文件首地址的偏移,如果为 0 或者省略的话表示从文件首地址开始读取。

        ext4write

                ext4wirte 命令用于将 DRAM 中的数据写入到 MMC 设备中。

ext4write <interface> <dev[:part]> <addr> <absolute filename path> [sizebytes] [file offset]

        interface 为接口,比如 mmc dev 是设备号; part 是分区; addr 是要写入的数据在 DRAM

中的起始地址;absolute filename path 是写入的数据文件名字,注意是要带有绝对路径,以‘/’ 开始;sizebytes 表示要写入多少字节的数据;file offset 为文件偏移。

BOOT 操作命令

              

=> help ? - alias for 'help' autoscr - run script from memory 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' bootm - boot application image from memory bootp - boot image via network using BootP/TFTP protocol cmp - memory compare coninfo - print console devices and information cp - memory copy crc32 - checksum calculation dhcp - invoke DHCP client to obtain IP/boot params echo - echo args to console erase - erase FLASH memory flinfo - print FLASH memory information go - start application at address 'addr' help - print online help iminfo - print header information for application image imls - list all images found in flash itest - return true/false on integer compare loadb - load binary file over serial line (kermit mode) loads - load S-Record file over serial line loop - infinite loop on address range md - memory display mm - memory modify (auto-incrementing) mtest - simple RAM test mw - memory write (fill) nfs - boot image via network using NFS protocol nm - memory modify (constant address) printenv - print environment variables protect - enable or disable FLASH write protection rarpboot - boot image via network using RARP/TFTP protocol reset - Perform RESET of the CPU run - run commands in an environment variable saveenv - save environment variables to persistent storage setenv - set environment variables sleep - delay execution for some time tftpboot - boot image via network using TFTP protocol version - print monitor version
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值