uboot相关命令及用法

时间:2022-03-05 13:15:00

进入uboot时,在命令行上敲“?” ,回车就会打印出在uboot里可用的命令:

#?
?       - alias for 'help'
base    - print or set address offset
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
bootvx  - Boot vxWorks from an ELF image
checkcrash- check ATAGS from crash and dump to file
chpart  - change active partition
cmp     - memory compare
cp      - memory copy
crc32   - checksum calculation
echo    - echo args to console
efuse   - opt efuse data
env     - environment handling commands
exit    - exit script
ext4load- load binary file from a Ext2 filesystem
ext4ls  - list files in a directory (default /)
false   - do nothing, unsuccessfully
fastboot- fastboot
fatinfo - print information about filesystem
fatload - load binary file from a dos filesystem
fatls   - list files in a directory (default /)
fatwrite- write file into a dos filesystem
go      - start application at address 'addr'
gpio    - input/set/clear/toggle gpio pins
help    - print command description/usage
i2c     - I2C sub-system
jtag    - jtag system
loop    - infinite loop on address range
md      - memory display
mm      - memory modify (auto-incrementing address)
mmc     - MMC sub system
mmcinfo - display MMC info
mtdparts- define flash/nand partitions
mtest   - simple RAM read/write test
mw      - memory write (fill)
nand    - NAND sub-system
nboot   - boot from NAND device
nm      - memory modify (constant address)
nu7     - nu7 sub system
pmic    - pmic interface
printenv- print environment variables
reset   - Perform RESET of the CPU
run     - run commands in an environment variable
saveenv - save environment variables to persistent storage
setenv  - set environment variables
showvar - print local hushshell variables
source  - run script from memory
test    - minimal test like /bin/sh
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
usb     - USB sub-system
usbboot - boot from USB device
version - print monitor, compiler and linker version

我们想要查看其中某个命令的用法时,在命令行上敲入“命令名 ?”即可,如“mmc ?”:

#mmc ?

mmc - MMC sub system

Usage:
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 read用来读取mmc内容到内存,

mmc write用来写入内存内容到mmc中

具体用法,

mmc read <device num> addr blk# cnt [partition]

mmc write <device num> addr blk# cnt [partition]

mmc list

device num是mmc的设备号,可以通过mmc list查询

addr是内存地址

blk# 是mmc内的块号

cnt 块数目

使用范例:

mmc write 2 0x90000000 0x600 0x10

把内存0x90000000开始,长度为16x512大小的数据,写入到第2个mmc设备块偏移位置为0x600处

mmc read 2 0x90000000 0x600 0x10

把第二个mmc设备块偏移为0x600处开始,长度为16x512大小的数据,读出到内存0x90000000处

从外置mmc卡load uImage文件:

#mmc list
SD/MMC:
SD/MMC: #mmc dev
mmc0 is current device #fatload mmc : 0x82007fc0 uImage
#pri
#run default_bootargs
只设pmic vdd:
pmic vdd 设置bootargs
#setenv bootargs console=ttyS0, root=/dev/mmcblk1p2 rw rootwait gpu=384M mem=792M video=nusmartfb:${resolution}-${dispformat} 706_hw_ver= init=/init quiet no_console_suspend 设置default_bootargs
#setenv default_bootargs console=ttyS0, root=/dev/mmcblk1p2 rw rootwait gpu=384M mem=792M video=nusmartfb:${resolution}-${dispformat} 706_hw_ver= init=/init quiet no_console_suspend #ext4load mmc : 0x82007fc0 uImage #bootm