现在的位置: 首页 > 综合 > 正文

SD卡中block和sector的含义

2019年03月23日 ⁄ 综合 ⁄ 共 1639字 ⁄ 字号 评论关闭

http://blog.csdn.net/conanyang/article/details/6856613

近期在写SD卡驱动程序。经查阅datasheet后,整理如下:

首先要了解的是: SD卡协议中 与 HardDisk(文件系统)的block和sector不一个意思。

SD可协议见《Part_1_Physical_Layer_Simplified_Specification_Ver_3.01_Final_100518.pdf》(点击下载

SD卡中block和sector的含义如下:

block :  A number of bytes, basic data transfer unit (SD中最小的读写单位)。
❤❤

block length 可以被 SET_BLOCKLEN (CMD16)设置 。

SDHC and SDXC block length 

协议原文:

7.2.3 Data Read
The SPI mode supports single block read and Multiple Block read operations (CMD17 or CMD18 in the
SD Memory Card protocol). Upon reception of a valid read command the card will respond with a
response token followed by a data token (refer to Figure 7-3). In case of Standard Capacity Card, the
size in the data token is determined by the block length set by SET_BLOCKLEN (CMD16).  In case of
SDHC and SDXC Cards, block length is fixed to  512 Bytes regardless of the block length set by
CMD16.

sector:  A number of blocks, basic erase unit (SD擦除单位) ❤❤

可以设置为N*block

协议原文:

 SECTOR_SIZE 
The size of an erasable sector. The content of this register is a 7-bit binary coded value, defining the
number of write blocks (see WRITE_BL_LEN). The actual size is computed by increasing this number
by one. A value of zero means one write block, 127 means 128 write blocks.

Linux内核文件系统block与硬盘sector关系:

在系统运行过程中,有时会遇到下面打印信息,报告读写某个扇区错误

kernel: end_request: I/O error, dev sdg, sector 2252148039
kernel: end_request: I/O error, dev sdc, sector 3297222879

1、这个扇区(sector)的含义是什么?和硬盘上的sector是一回事吗?

2、Sector和文件系统中的Block有什么关系?

3、而在我们上层应用读写的是文件内偏移量pos,pos与block/Sector之间有什么关系?

文件偏移量pos,是针对文件本身而言,即文件内的偏移。

Block是文件系统上的概念,一般文件系统block大小为4K。

Sector是磁介质硬盘最小单元,一般为512字节。

(ysmz4:结论就是,谁知道你所在的block和sector到底啥关系,问村长~~)

Block值一般与sector值是不相等的。


/**********************************
*           专注于芯的博客               *
*     --电子设计知识库,软件库     *
**********************************/

抱歉!评论已关闭.