天天看点

UFS深入浅出 第二章 UFS结构 第三节 UFS分区

作者:Flash4U

Section 3 UFS partition

第三节 UFS分区

UFS深入浅出 第二章 UFS结构 第三节 UFS分区

UFS partition concept is similar to that in eMMC. However, it is not exactly the same. In eMMC, the whole user area could be used immediately after initialization. If there are some dedicated purposes to store specific data, some area called General Purpose Partition (aka GPP) could be separated from user space with its own address memory space assigned. GPP number is up to 4 per eMMC specification. Besides that, there are two boots partition and one RPMB partition in eMMC when shipped out from factory. Either GPP, or Boot/RPMB need dedicated Switch Command CMD6 for accessing to their own independent memory space areas.

UFS分区的概念和eMMC相似。但是,又不完全一样。eMMC里面的整个用户区域可以在初始化之后立即使用。如果有特定的目的去存储一些专门的数据,那么可以从用户区域里面的分出一些分配了自己独立寻址空间的区域,称为通用目的区(也叫GPP)。根据eMMC的规范,GPP的数目最多是4个。除此之外出厂的时候在eMMC里还有两个boot分区以及一个RPMB分区。eMMC里不论是GPP,或者是Boot、RPMB,都需要特定的切换指令CMD6来访问它们自己的独立的寻址空间。

UFS partitions do not work that way. In UFS, partitions have a unique name Logical Unit (aka LU). Except one RPMB logical unit, no other Logical Units are assigned by default in UFS from factory,including boot partition. UFS memory space could not be accessed unless it has been separated into pieces with independent memory space and index assigned. Each piece is so called one Logical Unit, short as LU. The process of memory space allocation for each LU is called provisioning.

UFS的分区工作方式不太一样。在UFS里,分区有一个独特的名字逻辑单元(也叫LU)。除了一个RPMB之外,在UFS里包括boot分区在内,没有其他逻辑分区在出厂的时候就默认分配好的。UFS的存储空间在分成带有独立寻址空间和序列号的小块之前,是不能被访问的。每一个小块也就是一个逻辑单元,简写成LU。分配存储空间给每个LU的过程叫做配置(provisioning)。

The job that provisioning does is actually to create a scattered mapping table of memory space LBA for all LU. There are two types of provisioning defined by UFS specification, Full Provisioning and Thin Provisioning. Full Provisioning gives a 1:1 mapping for all physical memory with its corresponding LBA to LU. While Thin provisioning only assigned all LBAs to LUs. Compared to Full Provisioning, Thin provisioning is more flexible to use physical Flash memory so to reducing NAND overhead blocks and save cost. This is also the reason UFS command UNMAP, which is to delete Logical to Physical Address entry to free the dirty data blocks, is only supported in Thin Provisioning as Full Provisioning need to keep those dirty data blocks unless extra physical Flash blocks that are out of UFS exported capacity are provided to replace them. Nowadays, all UFS vendors has no doubt to choose Thin provisioning.

Provisioning的工作实际上是为所有的LU建立一个分散的存储空间LBA的映射表。UFS规范定义了两种Provisioning模式,完全的Full Provisioning以及廋Thin Provisioning。Full Provisioning给出了所有物理存储以及对应的LBA相对于LU的1:1对应关系。而Thin Provisioning只需要分配所有的LBA个LU。和Full Provisioning相比较,Thin Provisioning可以更加灵活的使用物理闪存,从而减少额外的NAND存储块以及减少成本。这也是为什么UFS的UNMAP命令只支持Thin Provisioning方式,UNMAP命令是通过删除逻辑物理地址映射入口来释放脏数据块。因为Full Provision除非有输出容量之外的额外的物理闪存块来替换那些脏数据块,否则就得一直留着它们。今日,所有的UFS厂商都毫无意外的选择Thin Provisioning。

The index assigned is the number of the LU. Hence Logical Unit Number (aka LUN) is used in UFS protocol to address the specific LU. Generally, there are up to 32 LU in UFS, however the real number could be much less than that based on the real storage usage design.

分配给LU的索引是数字号码,所以逻辑单元号(也叫LUN)就被用在UFS协议里面作为定位特定的LU。一般来说,UFS最多有32个LU,然而实际的数目根据实际存储使用的设计可能远小于这个数字。

UFS also inherit the concept of Well-Known Logical Unit (aka W-LU) from SCSI. There are total 4 W-LU in UFS, Device and Report LUN are two W-LU which have the same definition as that in SCSI, while Boot and RPMB are two W-LU which are newly added to implement and comply with eMMC feature. Each W-LU get its fixed number called Well-known Logical Unit Number (aka W-LUN). The fixed number is the reason that these 4 W-LU are well known. Here we only need to remember that 0xB0 is for Boot and 0xC4 is for RPMB.

UFS还集成了源自于SCSI的概念,众所周知的逻辑单元(也叫 W-LU)。UFS里一共有4个W-LU,Device和Report LUN是和SCSI定义一样的概念的W-LU。而Boot和RPMB是新加入的为了实现以及于eMMC特性保持一致的W-LU。每一个W-LU有固定的众所周知的逻辑单元码, 也就是众所周知的逻辑单元码(也叫W-LUN)。这些固定的数字码也是为什么这四个W-LU众所周知的原因。这里我们只需要记住Boot是0xB0以及RPMB是0xC4。

Boot W-LU density is part of the exported capacity of UFS, and size could be assigned up to 64MB each. This is not like eMMC. In eMMC, two boot partitions density is not counted in the exported capacity and usually is fixed for each, like 4MB. This feature gives UFS more flexibility to fit increasing demand of OS boot size requirement. Another notice for Boot W-LUs is, although it has fixed W-LUN 0xB4, it cannot be accessed until it is linked to a certain LU during the provisioning process by setting the UFS register Descriptor. RPMB W-LU is originated and does not have this limitation, W-LUN is 0xC4, which could be accessed directly. The detail will be covered in the UFS register chapter.

Boot W-LU的容量是包含在UFS的输出容量里的,大小可最大分配到64MB。这个和eMMC不一样,在eMMC里,两个Boot分区的容量是不算在输出容量里的,而且大小通常是固定的,比如说4MB。这个特性也给了UFS更多的灵活性来适应操作系统对于Boot分区尺寸逐渐增加的需求。另外一个Boot W-LU需要注意的点是,虽然它有固定的W-LUN 0xB0,但是在通过UFS寄存器设置做Provisioning把它链接到某个LU之前,它是不能访问的。 RPMB W-LU是原生的,没有这个限制,W-LUN是0xC4,直接就可以访问。具体的细节我们会在UFS寄存器的章节里讲。

继续阅读