What is the 'erased' value of a memory location on an sdhc card?

0

I am writing to a micro sd card (SDHC) for an embedded application. The application needs to be able to write very quickly to the card in real time.

I have seen that erasing the memory blocks beforehand makes the write a lot faster. Unfortunately I am struggling to get the erase command (and ACMD23) to work as the driver provided for the development board I am using is not complete.

Is there any way to erase the card by maybe writing an 'erased' value to the memory blocks beforehand? For example, if after erasing a block it becomes 0x12345678 can I just write this value instead to make it erased in order to get around using the erase command? Or is there some other way that the card marks a block as erased?

Thanks

I have tried writing 0xffffffff as the erased value but it has not helped.

sdhc
asked on Stack Overflow Jun 17, 2019 by alexv9

1 Answer

1

I think you're misunderstanding how flash memory works.

Flash memory has blocks which are way bigger than what typical filesystems expect. Additionally, they have a limited number of erase cycles. Hence, the flash controller provides an abstraction that maps virtual sectors to physical blocks.

A sector that is "erased" is not actively erased at all. It's just unmapped, and an empty block (if available) is mapped in its place. In the background, the flash controller shuffles sectors around and erases physical blocks as they become wholly unused.

As you can see, the quality of the flash controller matters here. It's not even a driver issue, typically. The driver just sends the command; the flash controller executes them. If you need better performance, get a better SD card.

answered on Stack Overflow Jun 17, 2019 by MSalters

User contributions licensed under CC BY-SA 3.0