3
\$\begingroup\$

I'm curious as to how SD cards map the supplied sectors for read/write to physical locations in the flash memory. Is this the real physical address, or is it just a virtual address that the SD controller then maps to the physical location?

I've read that SD cards have a controller which will manipulate writes in such a way that the wear of flash sectors is spread out as much as possible.

The main concern I have is if I have a micro-controller dealing with low-level IO where I read/write to a SD card using the SPI interface (mainly writes). I'm planning on using a PC program to pre-allocate sectors/clusters in a FAT16 formatted SD card at pre-known locations that my micro-controller can use. However, I don't want these sectors/clusters to magically be moved by the SD controller in such a way I have to re-parse the FAT16 file system in order to find where they are. I also don't want to accidentally repeatedly write to the same physical flash sector causing a failure in that one portion of the SD card.

\$\endgroup\$

1 Answer 1

4
\$\begingroup\$

Any moving of sectors that the device performs is translated automatically by the device itself; the data at any given address will read the same even if the device moves it every single time the device is accessed.

(Note that this is not true with MTD devices, which require you to handle... pretty much everything)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.