您尚未登录。

楼主 # 2021-07-02 09:52:24

qianfan
会员
注册时间: 2019-11-29
已发帖子: 38
积分: 106.5

emmc设置伪SLC模式

最近拿到一个板子, 上面搭载了8G的emmc (IS21ES08G), 但是从开机信息上面看到, 程序只能用到3.6G. 本着折腾的精神, 特意研究下这个东西.

从u-boot的控制台下使用mmc info查看下emmc的基本信息:

=> mmc info
Device: NUC970 eMMC
Manufacturer ID: 9d
OEM: 101
Name: IS008
Tran Speed: 26000000
Rd Block Len: 512
MMC version 5.0
High Capacity: Yes
Capacity: 3.6 GiB
Bus Width: 4-bit
Erase Group Size: 512 KiB
HC WP Group Size: 8 MiB
User Capacity: 3.6 GiB ENH WRREL
User Enhanced Start: 0 Bytes
User Enhanced Size: 3.6 GiB
Boot Capacity: 4 MiB ENH
RPMB Capacity: 4 MiB ENH

从mmc info中可以看到信息一栏: User Capacity: 3.6 GiB ENH WRREL, 注意这个地方的ENH. 查阅emmc的手册, 看到这这样的描述:

Supports Enhanced Mode where the device can be configured as pseudo-SLC (pSLC) for higher
read/write performance, endurance, and reliability.

但是手册中也没有明确指出使用pSLC模式下, 性能和擦写次数会有多大变化. 切换的方式是写ECSD寄存器: 兼容JEDEC标准.

The Extended CSD register defines the Device properties and selected modes. It is 512 bytes long. The most significant
320 bytes are the Properties segment, which defines the Device capabilities and cannot be modified by the host. The
lower 192 bytes are the Modes segment, which defines the configuration the Device is working in. These modes can
be changed by the host by means of the SWITCH command. For details, refer to section 7.4 of the JEDEC Standard
Specification No.JESD84-B50.

emmc的规范中描述了emmc的分区, 我们能够操作的分区是User Data Area. 可以从这里面划定出一块区域设置为ENH模式, 也就是设置为pSLC, 区域的大小必须是WPG size的倍数. WPG的大小在mmc info中已经列出来了, 为8M. 需要注意的是, 这个分区的设置是OTP的, 一旦设置一次之后就不能够更改, 因此设置的时候关于地址和大小一定要慎重.

emmc_partition.jpg

使用mmc hwpartition划定分区

正好我们有用emmc的产品, 找出一个来做下试验. 阅读下u-boot中关于hwpartition的代码:

	"mmc hwpartition <USER> <GP> <MODE> - does hardware partitioning\n"
	"  arguments (sizes in 512-byte blocks):\n"
	"   USER - <user> <enh> <start> <cnt> <wrrel> <{on|off}>\n"
	"	: sets user data area attributes\n"
	"   GP - <{gp1|gp2|gp3|gp4}> <cnt> <enh> <wrrel> <{on|off}>\n"
	"	: general purpose partition\n"
	"   MODE - <{check|set|complete}>\n"
	"	: mode, complete set partitioning completed\n"
	"  WARNING: Partitioning is a write-once setting once it is set to complete.\n"
	"  Power cycling is required to initialize partitions after set to complete.\n"

参数中cnt是以扇区)512字节)为单位计算的, 我从mmc info中读出mmc的容量是7.3G, 不是一个整数. 看代码中会计算并判断这个cnt是不是在有效范围内, 因此可以先随便填一个比较大的数字, u-boot会提示最大可用的WPG个数.

=> mmc hwpartition user enh 0 15269888 wrrel on
Partition configuration:
        User Enhanced Start: 0 Bytes
        User Enhanced Size: 7.3 GiB
        User partition write reliability: on
        No GP1 partition
        No GP2 partition
        No GP3 partition
        No GP4 partition
Total enhanced size exceeds maximum (932 > 466)
Failed!

前面也提到WPG的大小是8M, user data共有466个WPG, 因此可以设置的容量是8M * 466 = 3909091328字节, 换算成扇区是7634944.

=> mmc hwpartition user enh 0 7634944 wrrel on complete
Partition configuration:
        User Enhanced Start: 0 Bytes
        User Enhanced Size: 3.6 GiB
        User partition write reliability: on
        No GP1 partition
        No GP2 partition
        No GP3 partition
        No GP4 partition
Partitioning successful, power-cycle to make effective

设置完之后, 对emmc重新上电, 使用mmc info读取出来的容量就是3.6G了, 整个user data区域已经全部设置成pSLC模式.

=> mmc info
Device: NUC970 eMMC
Manufacturer ID: 9d
OEM: 101
Name: IS008
Tran Speed: 26000000
Rd Block Len: 512
MMC version 5.0
High Capacity: Yes
Capacity: 3.6 GiB
Bus Width: 4-bit
Erase Group Size: 512 KiB
HC WP Group Size: 8 MiB
User Capacity: 3.6 GiB ENH WRREL
User Enhanced Start: 0 Bytes
User Enhanced Size: 3.6 GiB
Boot Capacity: 4 MiB ENH
RPMB Capacity: 4 MiB ENH

离线

#1 2021-07-04 11:05:19

995pc
会员
注册时间: 2020-05-30
已发帖子: 54
积分: 3

Re: emmc设置伪SLC模式

看的有点似懂非懂,楼主的确折腾,精神可嘉。
Flash磁盘中,厂家会隐藏一些FLASH实际容量,用作坏块备份,提高使用寿命。
不知这个伪SLC模式,是不是就是相同道理,还是算法上的区别而已?

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn