mrbawse
Posts: 5
Joined: Sun Oct 08, 2017 4:59 am

SD card permanently write protected???

Sun Oct 08, 2017 5:10 am

I have a 2x rasp 3's both using 32GB Lexar micro SD cards as the main storage for the Ubuntu Mate OS. After running them for a a few months now doing various projects with each unit. I'd like to start from scratch and format and re-install the Ubuntu OS on both of them. I popped the sd cards into my win10 machine and tried to format the cards using windows. It gave me a cannot format card is write protected error. I checked the switch on the side of the micro to SD adapter and it was in the write position. Tried a partitioning app to format the card, still gave me an error that its write protected...what? I even popped them into my smart phone and tried to get android to format it and even the phone said it couldn't complete the format. I've never encountered this before...anyone seen this?

Thanks

Heater
Posts: 17138
Joined: Tue Jul 17, 2012 3:02 pm

Re: SD card permanently write protected???

Sun Oct 08, 2017 11:58 am

This is normal. Many people have seen this many times over the years. It gets reported hear every week or so. It has happened to me a few times. Although not in the past year or so with the Raspi 3 and Jessie/Stretch.

Nobody has yet identified why this happens or if it is a Pi specific problem, which I suspect it is. Or if there is any plan to fix it.

Ah well.
Memory in C++ is a leaky abstraction .

User avatar
jahboater
Posts: 6533
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: SD card permanently write protected???

Sun Oct 08, 2017 12:00 pm

I thought this was because the firmware in the card itself had decided the card was faulty and sensibly disabled writes to help preserve any remaining user data.

Heater
Posts: 17138
Joined: Tue Jul 17, 2012 3:02 pm

Re: SD card permanently write protected???

Sun Oct 08, 2017 12:15 pm

That may well be true.

But why is the card going faulty? How come we don't hear millions of users of phones, cameras and other gadgets complaining about this? How come I have built systems with my own lashed up SD card interfaces that have not failed with write-protect?

I suspect some command from the Pi to the card is getting corrupted and interpreted as a write-protect command some times.

One could speculate that it is connected to issues with marginal power supplies that the Pi is particularly sensitive to.
Memory in C++ is a leaky abstraction .

User avatar
jahboater
Posts: 6533
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: SD card permanently write protected???

Sun Oct 08, 2017 1:39 pm

Heater wrote:
Sun Oct 08, 2017 12:15 pm
One could speculate that it is connected to issues with marginal power supplies that the Pi is particularly sensitive to.
That sounds very likely.

Also the additional demands of a full OS, compared to use as a data card in camera or a phone.

I have found these cards to be very reliable.

User avatar
davidcoton
Posts: 5689
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: SD card permanently write protected???

Sun Oct 08, 2017 6:00 pm

Heater wrote:
Sun Oct 08, 2017 12:15 pm
One could speculate that it is connected to issues with marginal power supplies that the Pi is particularly sensitive to.
I don't think the Pi SOC is particularly sensitive. It sits behind at least one and in part two layers of on-board reguation.
Any vulnerability is likely with the parts supplied directly at 5v -- USB, HDMI, and -- oh yes -- SDCard. no, not the SDCard.
Is there any (other) evidence that some/all SDCards are susceptible to problems with a marginal 5V supply?

EDIT -- Factual correction (Thanks Heater)
Last edited by davidcoton on Sun Oct 08, 2017 9:32 pm, edited 1 time in total.
Location: 345th cell on the right of the 210th row of L2 cache

Heater
Posts: 17138
Joined: Tue Jul 17, 2012 3:02 pm

Re: SD card permanently write protected???

Sun Oct 08, 2017 6:20 pm

No, that is wrong. SD cards run from 3.3v.

They can have current demands of 100mA or so.

As such I would expect the regulators on the Pi to be able to handle all this nicely.

Basically we have no idea why the Pi suffers so badly from this SD card write-protect problem. As far as I can tell after all these years nobody has taken it seriously enough to investigate.

I do not buy the idea of excessive demands of a full up OS. Raspbian is not sitting there writing files for the fun of it. When it has happened to me the installations were only days old and hardly used.
Memory in C++ is a leaky abstraction .

User avatar
DougieLawson
Posts: 40583
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: SD card permanently write protected???

Sun Oct 08, 2017 6:32 pm

It's probably due to things like the dphys-swapfile and the fact that cheapo SDCards have a lower number of write cycles before they're worn out.

I've had Raspberries for five years. In that time I've had just one 32GB SDCard go into a read-only bad state (and that was before the RPF folks fixed some of their bugs in the hardware/firmware/bootcode/kernel). My longest running RPi has clocked up more than 936 days (since 3rd Jan 2015) on the same SDCard (can't tell the brand it's a micro SDcard in a RPF branded carrier). Current uptime for that one is 206 days.

So the problem is a) marginal power supplies and b) marginal SDCards with lousy wear levelling.

Chromium plated spinning things and SSD things (with static wear levelling) are always going to be more reliable than NAND flash memory. Filesystems can have an effect due to the way they write their journals and re-write data sectors. If it's a real problem then look at running a read-only rootfs or whether you can run it with f2fs.
Any language using left-hand whitespace for syntax is ridiculous

Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.

Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13588
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: SD card permanently write protected???

Sun Oct 08, 2017 6:45 pm

most often the problem occurs with cheap (or even fake) SD-cards with inferior card controllers, such a controller can initialise a re-shuffling of sectors that it thinks are too often written, to to unused sectors (wear levelling), and if while doing so the power is suddenly pulled the affected sector will become disrupted, and its information becomes lost, in worse cases the card controllers household information (a table of where valid/used sectors are stored) may become invalidated.

In other uses like cameras and such there are not that many re-writes to the same files (sectors), and the card controller is given enough time to complete its wear level actions.

the solution is to, after a shutdown that occurred after a lot of file writing, give the card long enough to complete the wear level actions, which may take many seconds if there are many sectors that need this treatment.

also cheap cards do not do as good a job of waiting to write out data to a sector, as more expensive ones do, which means that many small updates of a file generate many full re-writes of sectors, wearing them out more quickly.

Heater
Posts: 17138
Joined: Tue Jul 17, 2012 3:02 pm

Re: SD card permanently write protected???

Sun Oct 08, 2017 7:18 pm

Every time this topic comes up we get the same hand waving arguments about cheap/fake SD cards, the extra load of an OS and wear leveling.

None of it is conclusive.

My SD cards were not cheap and I have no reason to believe they were fake. Apart from the fact that they failed in the Pi.

My OS load is minimal.

Of course there may be some truth to the hand waving arguments but it looks like we are never going to get to the bottom of this problem. Hand waving is the best we can do.
Memory in C++ is a leaky abstraction .

User avatar
davidcoton
Posts: 5689
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: SD card permanently write protected???

Sun Oct 08, 2017 9:48 pm

Thanks Heater for your correction. However that does make it harder for a poor PSU to affect the SDCard -- it has to be hit hard enough to affect the 3V3 regulator output. That is unlikely to go unnoticed.

So we still have:
  • SDCard problems as the biggest issue reported here. (Has anyone counted posts to confirm that?)
  • Some of these are shown to be associated with power supply problems, particularly incorrect shutdown. (Again, I haven't counted and I don't suppose anyone else has.)
  • Some are thought to be "fake" cards.
  • But some are unexplained.
  • Some problems are temporary, resolved by reformatting (or equivalent). Others seem to be permanent (or maybe the necessary level of reformat hasn't been tried).
Unfortunately this boils down (factually) to anecdote, nicely balanced by other anecdotes about Pis running for longish periods without problems.

FWIW my gut feeling is that there may be some lurking issue, h/w or s/w, that can cause premature SDCard failure. But in such an enormous mess of anecdotal evidence, and an almost complete lack of verifiable details (or even statistics), where can one start an investigation? Should Pi Towers be asking for failed SDCards to be mailed in? Could the Cambridge Post Office survive? :shock: Would a stack of failed SDCards be higher than Pi Towers?
Location: 345th cell on the right of the 210th row of L2 cache

mrbawse
Posts: 5
Joined: Sun Oct 08, 2017 4:59 am

Re: SD card permanently write protected???

Mon Oct 09, 2017 12:52 am

Heater wrote:
Sun Oct 08, 2017 11:58 am
This is normal. Many people have seen this many times over the years. It gets reported hear every week or so. It has happened to me a few times. Although not in the past year or so with the Raspi 3 and Jessie/Stretch.

Nobody has yet identified why this happens or if it is a Pi specific problem, which I suspect it is. Or if there is any plan to fix it.

Ah well.
Well glad to hear I'm not the only one, not so glad to read all of the responses indicating no definitive answer as to why this is happening. I'll chime in that I"m not using a cheap/fake SD card either. As this was a name brand card maker and it wasn't their base model of card either. Wondering if I can claim warranty on this. I guess I need to expect from here on out that there a good possibility that my pi3 will eat my next SD purchase so don't plan on re-using it ;) . I read on a ubuntu forum that some people had luck using Gparted in the ubuntu live OS to fix their cards, but no luck with mine.

User avatar
HawaiianPi
Posts: 6143
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: SD card permanently write protected???

Mon Oct 09, 2017 4:07 am

Many of the better brand cards have several years warranty. Samsung is something like 5 or 10 years, depending on the model. So it would be good to file a warranty claim. You may get a replacement card, but even if the claim is denied, the reasons might shed some light on what's happening to the cards.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

Heater
Posts: 17138
Joined: Tue Jul 17, 2012 3:02 pm

Re: SD card permanently write protected???

Mon Oct 09, 2017 5:04 am

There are two major concerns here:

1) Corruption of the Linux file system.

This might be caused by sudden power outage or whatever. It is fixable with a disk check, fsck. Or by burning a whole new image to the card.

2) Failure of the SD card.

Generally by going write protected. This is not recoverable with fsck, parted or any such higher level tool.

Of course failure of SD card blocks in 2) can give rise to the symptoms of 1)

Case 1) I'm not inclined to worry about. It's a pain but recoverable easily enough.

Case 2) is the concern and calls for some investigation.

Has anyone ever written a program for the Pi that can read and/or write the write-protect registers of an SD card? If we had that it might be a start at finding out what is going on.

Such a program is possible. This guy does it with an micro-controller board, built to do nothing but that:
https://hackaday.com/2014/01/18/the-tin ... rd-locker/
https://github.com/Nephiel/sdlocker-tiny

I presume this could be done from a Pi as well.
Memory in C++ is a leaky abstraction .

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13588
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: SD card permanently write protected???

Mon Oct 09, 2017 11:35 am

Heater wrote:
Mon Oct 09, 2017 5:04 am
There are two major concerns here:

1) Corruption of the Linux file system.

This might be caused by sudden power outage or whatever. It is fixable with a disk check, fsck. Or by burning a whole new image to the card.
Nope, if the corruption resulted in data loss fsck cannot repair that

hippy
Posts: 8952
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: SD card permanently write protected???

Mon Oct 09, 2017 12:42 pm

Heater wrote:
Sun Oct 08, 2017 12:15 pm
I suspect some command from the Pi to the card is getting corrupted and interpreted as a write-protect command some times.
davidcoton wrote:
Sun Oct 08, 2017 9:48 pm
FWIW my gut feeling is that there may be some lurking issue, h/w or s/w, that can cause premature SDCard failure.
Having written my own SD card interface code for a microcontroller, and having inadvertently invoked the Write Protect and card no longer recognisable behaviour while doing that, I am inclined to agree with the analysis that it may be a Pi software or hardware issue rather than it being cheap cards, wearing them out, wear levelling issues or power supply.

Such a view may also be supported by reports on the forum of card failures and corruption when booting read-only systems, and after reboots when following proper shutdown procedures and using what appear to be good quality cards.
Heater wrote:
Sun Oct 08, 2017 6:20 pm
As far as I can tell after all these years nobody has taken it seriously enough to investigate.
That is perhaps understandable. It is easy to blame users and, when most people don't have problems, it is always tempting to believe there are no systemic issues and it must be a user issue. There can be understandable reluctance to say there may be an issue until that has been proven. We saw the same with the LAN 1V8 and USB issues.

As everyone seems to acknowledge; "it's a well known issue" but there seems to be no conclusive evidence as to what the cause actually is.

Ways to investigate the SD Card issue have been suggested in past threads where those issues have been reported. I don't know if any investigations have been undertaken or if they had any conclusive results or not.

In the circumstances, and with lack of evidence to the contrary, we can only take it that it is the user who is at fault, not the Pi or its software or hardware.

Heater
Posts: 17138
Joined: Tue Jul 17, 2012 3:02 pm

Re: SD card permanently write protected???

Mon Oct 09, 2017 12:57 pm

mahjongg,
Nope, if the corruption resulted in data loss fsck cannot repair that
Obviously.

Perhaps I was not clear. When I said "fixable" there I was meaning the SD card is recoverable and reusable. As opposed to this write-protect issue which renders the cards trash.
Memory in C++ is a leaky abstraction .

hommar
Posts: 191
Joined: Sat Mar 25, 2017 1:55 pm
Location: Russia, Yekaterinburg

Re: SD card permanently write protected???

Mon Oct 09, 2017 10:13 pm

Heater wrote:
Sun Oct 08, 2017 12:15 pm
But why is the card going faulty? How come we don't hear millions of users of phones, cameras and other gadgets complaining about this? How come I have built systems with my own lashed up SD card interfaces that have not failed with write-protect?
1) in Phone SD is not main storage
2) more users do not know about why their phones do not work
3) I have some Android-phones with R/O internal /dev/mmcblk. It's my phones. I used it as small PC (used browser and over soft every days many hours)

PS on RPi I use f2fs, because it's long-life for SD
Last edited by hommar on Mon Oct 09, 2017 10:28 pm, edited 3 times in total.

User avatar
Ronaldlees
Posts: 294
Joined: Sat Apr 16, 2016 4:28 pm
Location: North Carolina, US
Contact: Website

Re: SD card permanently write protected???

Mon Oct 09, 2017 10:23 pm

There's not been much documented testing of this issue. It's likely that the reason - at least partly - is that these card's manufacturers are very tight lipped about the protocols and firmware. I guess that's due to the "S" in SD. If they gave away the game, they'd just have to sell "D" cards.

There are some (let's say "alternative") sites on the net where you can get so-called SD repair utilities. Since these utils don't come from the manufacturer, they are of course non-supported (or worse). Using them is not my advice. AFAIK, one has to know the firmware update protocol, and have knowledge about the firmware itself. There was one manufacturer (I think Cypress, but don't remember for sure) - that did have a fix-it util that would renew the firmware and/or reset the card to the factory internal state. Some of this nowadays may be baked into hardware. So really it's a case of keeping the beans in the bag, so to speak ...
I am the Umbrella man

beagle123
Posts: 3
Joined: Sat Aug 23, 2014 8:18 pm

Re: SD card permanently write protected???

Mon Nov 25, 2019 7:06 am

i just had a Transcend 32GB card went read only on me.
I have had this card for about 5 years for use in a Dash Cam system. One day it just quit on me.
In windows 10, I can still delete files, but as soon as it is removed and plugged back in, the files reappear. Formatting it gives an error saying it can't be formatted.

After some digging around I found this, apparently the SD card has internal write protect fuse. It is there in the event of potential card failing, it can still preserve the files. So there you go. Time to shop for a new card I guess.

SD Specifications Part 1

Physical Layer

Simplified Specification

Version 4.10 January 22, 2013

4.3.6 Write Protect Management

Three write protect methods are supported in the SD Memory Card as follows:

Mechanical write protect switch (Host responsibility only)
Card internal write protect (Card's responsibility)
Password protection card lock operation.


Shyamal
Posts: 1
Joined: Mon Dec 30, 2019 6:36 am

Re: SD card permanently write protected???

Mon Dec 30, 2019 6:41 am

I used the SD card reader slot in my laptop. It worked for me.. No more "write protected" message :)

Return to “General discussion”