目前很多板卡都是用emmc来存储文件,所以熟悉u-boot中的mmc操作命令还是很有必要的。
在u-boot下键入mmc,会显示mmc命令的操作格式:
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
- 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
1.mmc list :查询系统中可用的mmc设备;
U-Boot> mmc list
FSL_SDHC: 0 (eMMC) //系统中可用的mmc设备只有一个,编号为0;
2.mmc dev:设置当前用来操作的mmc设备;
U-Boot> mmc dev 0 //设置当前设备为mmc 0
switch to partitions #0, OK
mmc0(part 0) is current device
3.mmc info: 显示当前mmc设备的信息;
U-Boot> mmc info
Device: FSL_SDHC
Manufacturer ID: d6
OEM: 103
Name: 88A39
Tran Speed: 52000000
Rd Block Len: 512 //重点关注下块大小和容量
MMC version 4.0
High Capacity: Yes
Capacity: 7.3 GiB
Bus Width: 8-bit
Erase Group Size: 512 KiB
4.mmc erase 0x600 0x4000
从mmc设备块编号为0x600处开始,擦除长度为0x4000 x 512大小(Block Len 指定)的数据;
5.mmc write 0x10100000 0x600 0x4000
把内存0x10100000开始,长度为0x4000 x 512大小的数据,写入到当前mmc设备块编号为0x600处;
6.mmc read 0x10100000 0x600 0x4000
从当前mmc设备块偏移为0x600处开始,长度为0x4000 x 512大小的数据,读入到内存0x10100000处;