General > General Technical Chat
Erasing Flash Memory
(1/1)
mbarszcz:
As we know, the default state of erasable memory (EPROMs, NAND flash, etc) is 0xFF, but are those values what is actually exposed to the PC/device in the case of SD or CF cards? When a PC writes a file full of zeroes, is that actually writing 0x00 to the flash memory, or is it writing 0xFF?
If you were to look at a brand new SD card with a hex editor on a PC, would it be full of 0x00 or 0xFF?
ataradov:
SD Cards are typically sold pre-formatted, so they could contain anything.
SD Card specification actually defines a bit in the status registers that tells the host the values after executing the erase command. So it is up to the card vendor to decide what they want to show as a "erased" state.
Specifically section 4.3.5.1 "Erase" of the "Physical Layer Simplified Specification" (https://www.sdcard.org/downloads/pls/index.html) says this:
--- Quote ---The data at the card after an erase operation is either '0' or '1', depends on the card vendor.
The SCR register bit DATA_STAT_AFTER_ERASE (bit 55) defines whether it is '0' or '1'.
--- End quote ---
Peabody:
As Alex says, the erased state depends on the manufacturer. I suspect the actual erased state is always FF, but some manufacturers could have an inverter stuck in there.
The much-hailed SD Formatter app provided by the SD Association offers an "Overwrite" option, which I've confirmed does actually write zeroes to the entire card instead of erasing it. They don't offer an Erase option, at least not on the Windows version.
If you have a DSLR or other fancy camera that offers a "low level" format, that will erase the card, and then you can look at it in your hex editor and see how it reads back. In the Arduino world there is a library called SdFat which includes an Example called SdFormatter.ino. That sketch does erase the card, and tells you what Alex's bit 55 says.
mbarszcz:
Thanks for the information. Interesting that it can vary by manufacturer. I just got a new SanDisk Extreme MicroSD card today, and it was filled with zeros.
Navigation
[0] Message Index
Go to full version