Tiny Core Linux

Tiny Core Base => TCB Q&A Forum => Topic started by: Zill on October 15, 2015, 02:26:08 PM

Title: SD card write protect switch
Post by: Zill on October 15, 2015, 02:26:08 PM
I have installed Tiny Core 5.4 on an SD card(SanDisk Extreme Plus).  I have done this because I want to have a physical switch for controlling if data can or cannot be written to the card.  If I slide the switch into the read only mode and then boot my system, I am still able to write to the memory card.  I had assumed that the switch stopped writes from happening at the card level, but this is making me question my assumption.  Is there a driver that I need to install to recognize the SD card switch?
Title: Re: SD card write protect switch
Post by: Rich on October 15, 2015, 03:11:32 PM
Hi Zill
I believe the write protection is handled by the card reader:
http://4.bp.blogspot.com/-Ab0KBUr3IN0/UtJuA9WF92I/AAAAAAAAB0A/Vm6nZRFzGoc/s1600/Pi+SD+Card+damanged+with+card.jpg
Title: Re: SD card write protect switch
Post by: Zill on October 20, 2015, 01:08:27 PM
I tried several different units and it seems that all of them ignore the write protect switch.  In looking around I found some information (http://superuser.com/questions/354473/is-the-lock-mechanism-on-an-sd-card-hardware-firmware-or-software-driver-os) that says the write protect switch is a trigger to the OS, and it is up to the OS to recognize it.  Based off of this I have two different ideas: either the SD card reader is not reporting the switch to the OS (which sucks because I can't change the internal hardware of these units), or that Tiny Core is not currently configured to recognize the switch and thus mark the card as protected.  I have looked at a few instructions for other Linux systems, but they don't seem to work for Tiny Core.  While I keep looking, if anyone could help point me in the write direction for testing if Tiny Core sees the write protect switch or not I would be most appreciative.
Title: Re: SD card write protect switch
Post by: Rich on October 20, 2015, 11:54:49 PM
Hi Zill
You could try using the  hdparm  utility and see what it reports:
Code: [Select]
tc@box:~/guilib/grabber/grabber-1.1$ hdparm -r /dev/sda3

/dev/sda3:
 readonly       =  0 (off)
tc@box:~/guilib/grabber/grabber-1.1$
Replace  sda3  with your device.
Title: Re: SD card write protect switch
Post by: Zill on October 21, 2015, 03:22:10 PM
So with the switch in the lock position and running the hdparm command it pops up saying that readonly = 0.  I guess that means that is the hardware causing problems and I will have to come up with something else.  Thanks for the help Rich.