My phone is corrupting memory cards while trying to write data. I want to make my microSD read-only or write protect it (even if phone is not the reason). Searching on Google returns the solutions to remove protection. Is there any way to make microSD read-only OR write protect it?
Asked
Active
Viewed 2,813 times
5
-
interesting question. apparently it can be done, though there is no physical switch on microSD: http://en.wikipedia.org/wiki/Secure_Digital#Card_security – Colin Pickard Feb 25 '14 at 21:08
-
I think there might be some binary codes, headers etc that we can write onto the memory card partition to make it read-only??? – LifeH2O Feb 26 '14 at 00:22
-
2A lead: https://github.com/BertoldVdb/sdtool . – Kamil Maciorowski Jun 08 '17 at 21:09
-
[1/2] @KamilMaciorowski thanks _so much_ for that lead! For posterity, in case that repo vanishes: it looks like setting high the **fourth bit of the fifteenth byte of the CSD** write-protects a card (`csd[14]&=~0x30;csd[14]|=0x10;`); setting high the fourth _and third_ bits of that byte may render the card _permanently_ read-only (`csd[14]&=~0x30;csd[14]|=0x20;`), and setting low the fourth _(and third?)_ bit/s un-write-protects it (`csd[14]&=~0x30;`). – JamesTheAwesomeDude Mar 01 '20 at 08:00
-
[2/2] see §5.3 of [the SD Phys Spec](http://users.ece.utexas.edu/~valvano/EE345M/SD_Physical_Layer_Spec.pdf) for what the CSD, itself, is; see **Tables 5-16 and 5-14** (advised by **Figure 3-7 and preceding text**) to understand where Bertold got his information from. The spec isn't exactly intuitive: inter-byte endianness is little, but intra-byte (inter-bit) endianness is big. It's convoluted, but my analysis is that Bertold's program checks out. (At the very least: apparently it's working as written for at least some people, so it's probably "correct" in an important way.) – JamesTheAwesomeDude Mar 01 '20 at 08:26
-
(I will break this rudimentary documentation out into an answer if/when I get my hands on a _spare_ µSD to jigger around with) – JamesTheAwesomeDude Mar 01 '20 at 08:29
-
Another lead: [MMC(1)](https://manpages.debian.org/stable/mmc-utils/mmc.1.en.html), has the advantage of being a "canned" solution already commonly available thru any package manager—though it [may have been superseded](https://superuser.com/q/889164/165335) by Bertold's sdtool – JamesTheAwesomeDude Mar 05 '20 at 21:35
-
Answer here>>>>https://superuser.com/questions/1580787/how-to-write-protect-sd-card – Moab Aug 26 '20 at 17:21