BigJinge
Posts: 31
Joined: Sat Jul 09, 2016 12:23 pm

microSDHC card : Removing embedded card write protection

Sun Sep 25, 2016 10:28 pm

Hi,

I bought a 16GB microSDHC card a month or so ago and have been using it fine in my Rasp Pi 3.

I've now bought a Rasp Pi Zero 1.3 and went to reuse the memory card.

I used Win32DiskImager again to write the Jessie Lite img and it said that the card is write protected.

I've gone though all the steps, registry change, diskpart, EaseUS, Paragon, even putting the microSDHC card in a full size SD card converter (one with a write protect tab, turned off) and nothing will remove the write protection.

SD cards have an independent software write protect flag. I found this article on how to remove it with a Rasp Pi.

http://www.bertold.org/sdtool/

In a nutshell it says to use the following command to lock the card, ergo I used unlock at the end.

wget http://bertold.org/sdtool/sdtool-rpi -O /tmp/sdtool;chmod +x /tmp/sdtool;/tmp/sdtool /dev/mmcblk0 lock

However.....

When I run this with unlock, it gives the error :
[-] Failed to open MMC block device: Permission denied

The boot card in the Pi is mmcblk0. Same error if I put sudo in front of the command.

Anyone had this issue, used this tool? Different syntax?

Note : This card isn't faulty. It works fine in the Pi 3. It's just locked and I want to wipe it to install Jessie Lite on it, fresh..

UPDATE : The card is permanently locked, any writing to the card after the permanent write protect flag was turned on, is ignored.

Thanks in advance

BigJinge
Last edited by BigJinge on Mon Sep 26, 2016 2:32 pm, edited 2 times in total.

MrEngman
Posts: 3856
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: microSDHC card : Removing embedded card write protection

Sun Sep 25, 2016 11:12 pm

Curious so just tried the command but changed lock to status and got the same error. "Failed to open MMC block device: Permission denied"

So this gives error

Code: Select all

wget http://bertold.org/sdtool/sdtool-rpi -O /tmp/sdtool;chmod +x /tmp/sdtool;/tmp/sdtool /dev/mmcblk0 status
Changed the command adding sudo to change the last part of the command to give sudo /tmp/sdtool /dev/mmcblk0 status like

Code: Select all

wget http://bertold.org/sdtool/sdtool-rpi -O /tmp/sdtool;chmod +x /tmp/sdtool;sudo /tmp/sdtool /dev/mmcblk0 status
and this then worked OK and showed the status.

Code: Select all

[+] Found RCA for /dev/mmcblk0: AAAA.
[+] Card CSD: 400E005A5B590001DBD37F800A404009.
[+] Write protection state: Off.
Hope this helps you.


MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

BigJinge
Posts: 31
Joined: Sat Jul 09, 2016 12:23 pm

Re: microSDHC card : Removing embedded card write protection

Mon Sep 26, 2016 12:14 am

So I tried your updated sudo status version and my card came back with this...

[+] Write protection state : Permanent

I tried with unlock at the end and it said this...

[?] Card is permanently locked. I will try to clear the flag, but it will likely fail
[+] Writing CSD.
[+] Write protection state : Off.

I ran another status just in case...

[+] Write protection state : Permanent

Hmmmmm.

I've read others have had this write protect issue after installing Raspbian then trying to reuse the card. I wonder if Raspbian is locking the card.

Best wishes

BigJinge

BigJinge
Posts: 31
Joined: Sat Jul 09, 2016 12:23 pm

Re: microSDHC card : Removing embedded card write protection

Mon Sep 26, 2016 12:25 am

He's someone else with the permanent write protected lock bit enabled on the card.

viewtopic.php?p=422350#p422350

BigJinge
Posts: 31
Joined: Sat Jul 09, 2016 12:23 pm

Re: microSDHC card : Removing embedded card write protection

Mon Sep 26, 2016 12:55 am

Doing some more digging it appears that if the firmware of an SD card thinks that the data on the card will get corrupted it turns on the permanent write protect flag basically turning the card into a ROM card.

You're not supposed to remove the permanent write flag but that doesn't stop people from trying.

viewtopic.php?p=162205#p162205

wh7qq
Posts: 1340
Joined: Thu Oct 09, 2014 2:50 am

Re: microSDHC card : Removing embedded card write protection

Mon Sep 26, 2016 1:21 am

Funny, I have never encountered this problem with any legitimate SD card. I think the problem lies with Win32DiskImager. It must need a freshly formatted SD card so if you use the SDFormat utility (free from SD Association) or the Linux utility "gparted" to put a new format on the card, it should accept an image just like new.

BigJinge
Posts: 31
Joined: Sat Jul 09, 2016 12:23 pm

Re: microSDHC card : Removing embedded card write protection

Mon Sep 26, 2016 2:04 am

I'll check the other card (exact same type) and see if the Permanent flag is on.

Regarding Win32DiskImager, if it was locking the cards after the img file was pushed then you wouldn't be able to configure the card with raspi-config, which you can.

I've installed OpenCV and others.

Only now I want to format it do I find it perm locked in the card firmware.

drgeoff
Posts: 9898
Joined: Wed Jan 25, 2012 6:39 pm

Re: microSDHC card : Removing embedded card write protection

Mon Sep 26, 2016 7:25 am

wh7qq wrote:I think the problem lies with Win32DiskImager. It must need a freshly formatted SD card so if you use the SDFormat utility (free from SD Association) or the Linux utility "gparted" to put a new format on the card, it should accept an image just like new.
That thinking is incorrect. Win32DiskImager does not require a formatted card.

BigJinge
Posts: 31
Joined: Sat Jul 09, 2016 12:23 pm

Re: microSDHC card : Removing embedded card write protection

Mon Sep 26, 2016 2:23 pm

Follow up.

I checked my other card, and that is fine. The status for that one reads
[+] Write protection state: Off.

Both cards are Lexar 633x microSDHCs

On the card with the issue I created a folder and a txt file, then rebooted the Pi. The folder and txt file had disappeared pointing to the changes were made to RAM but the write commits didn't complete on the card..... due to it being permanently locked.

I've made a support request to Lexar for an exchange.

Return to “Troubleshooting”