SD card driver recently writtenProgram. After reading datasheet, sort it as follows:
The first thing you need to know is:SD card ProtocolAndHarddisk (File System)Block and sectorIt does not mean anything.
For sdks, see "Maid physical_layer_simplified_specification_ver_3.020.final_100518.pdf" (click to download)
The meanings of block and sector in the SD card are as follows:
Block:A number of bytes, basic data transfer unit (the smallest read/write unit in SD ).
The block length can beSet_blocklen (Listen 16)Set
.
Sdhc and sdxcBlock
LengthIs a fixed 512 bytes.
Original agreement:
7.2.3 data read
The SPI mode supports single block read and multiple block read Operations (Limit 17 or limit 18 in
SD memory card Protocol). Upon partition tion of a valid READ command the card will respond with
Response token followed by a data token (refer to figure 7-3). In case of standard capacity card,
Size in the Data token is determined by the block length set by set_blocklen (Limit 16). In case
Sdhc and sdxc cards, block length is fixed to 512 bytes regardless of the block length set
201716.
Sector:A number of blocks, basic erase unit (SD erasure Unit)
It can be set to N * blocks.
Original agreement:
Sector_size
The size of an erasable sector. The content of this register is a 7-bit binary coded value, defining
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.
Relationship between Linux Kernel File System blocks and hard disk sector:
When the system is running, the following information is sometimes printed to report errors in reading or writing a sector.
Kernel: end_request: I/O error, Dev SDG, sector 2252148039
Kernel: end_request: I/O error, Dev SDC, sector 3297222879
1. What does this sector mean? Is it the same as the sector on the hard disk?
2. What is the relationship between sector and block in the file system?
3. What is the relationship between POs and block/sector at the file offset read and write in our upper-layer applications?
The file offset POS is for the file itself, that is, the offset in the file.
Block is a concept in a file system. Generally, the block size of a file system is 4 kb.
The sector is the minimum unit of the magnetic media hard disk, generally 512 bytes.
The block value is generally not equal to the sector value.
/**********************************
* Focus on core blogs *
* -- Electronic design knowledge base and software library *
**********************************/