一. EMMC与 SD卡
uboot 支持 EMMC 和 SD 卡,因此也要提供 EMMC 和 SD 卡的操作命令。
一般认为 EMMC 和 SD 卡是同一个东西,所以没有特殊说明,本文统一使用 MMC 来代指 EMMC 和 SD 卡。
uboot 中常用于操作 MMC 设备的命令为 “mmc”。
二. 文件操作命令
mmc 命令是一系列的命令,其后可以跟不同的参数,输入 “?mmc” 命令即可查看 mmc 有关的命令。开发板uboot命令模式下输入命令 “?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
- 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 info命令
mmc info 命令用于输出当前选中的 mmc info 设备的信息。存在 MMC的情况下。
输入如下:
=> mmc info
Device: FSL_SDHC
Manufacturer ID: 3
OEM: 5344
Name: SC16G
Tran Speed: 50000000
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 14.8 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
2. mmc recan 命令
mmc rescan 命令用于扫描当前开发板上所有的 MMC 设备,包括 EMMC 和 SD 卡,输入
“mmc rescan”即可。 如下所示:
=> mmc rescan
=>
3. mmc list 命令
mmc list 命令用于来查看当前开发板一共有几个 MMC 设备。
操作如下:
=> mmc list
FSL-SDHC: 0
FSL-SDHC: 1 (eMMC)
可以看出当前开发板有两个 MMC 设备:FSL_SDHC:0 和 FSL_SDHC:1 (eMMC),这是因
为我现在用的是 EMMC 版本的核心板,加上 SD 卡一共有两个 MMC 设备,FSL_SDHC:0 是 SD
卡,FSL_SDHC:1(eMMC)是 EMMC。
默认会将 EMMC 设置为当前 MMC 设备,这就是为什么输入“mmc info”查询到的是 EMMC 设备信息,而不是 SD 卡。
4. mmc dev命令
mmc dev 命令用于切换当前 MMC 设备,命令格式如下:
mmc dev [dev] [part]
[dev] 用来设置要切换的 MMC 设备号,
[part] 是分区号。如果不写分区号的话默认为分区 0。
例如,切换到 SD卡,如下:
=> mmc dev 0
switch to partitions #0, OK
mmc0 is current device

文章介绍了在UBoot环境下如何使用mmc命令来操作EMMC和SD卡,包括mmcinfo显示设备信息,mmcrescan扫描设备,mmclist列出设备,以及mmcdev切换当前设备等。默认情况下,EMMC会被设置为当前设备。
1729

被折叠的 条评论
为什么被折叠?



