Go Down

Topic: SD card CSD register change bits (CMD27) (Read 5332 times) previous topic - next topic

Alex640

Mar 09, 2016, 04:34 pm Last Edit: Mar 09, 2016, 04:40 pm by Alex640
Hello, does anyone know any examples for change the bits in CSD ?

CMD27 0x5B    // change the bits in CSD

Change bit 12 (TMP_WRITE_PROTECT) to get SD card write protected and no.




fat16lib

#1
Mar 10, 2016, 03:51 pm Last Edit: Mar 10, 2016, 03:59 pm by fat16lib
You need to read the CSD, change the bit and write the CSD back.  You must also update the CRC.

I didn't include a writeReg/writeCSD function in SdFat since you can also permanently write protect the card.

You can see how to make writeCSD() by looking at writeData().

yuretz

Hello, does anyone know any examples for change the bits in CSD ?

CMD27 0x5B    // change the bits in CSD

Change bit 12 (TMP_WRITE_PROTECT) to get SD card write protected and no.




Can you share sketch from your screen?

mikrotron

fat16lib would,you do me a favor and show how a writeCSD or writeCID WOULD look? I think one simply have to issue the command as usual, then wait for a ready to receive token from the card and send the bytes needed (16).
But i really need some example code please :-)

chucktodd

fat16lib would,you do me a favor and show how a writeCSD or writeCID WOULD look? I think one simply have to issue the command as usual, then wait for a ready to receive token from the card and send the bytes needed (16).
But i really need some example code please :-)

Send him some $.

You need it, his time is not free, What is it worth to you?

He has already given you advice for free, spend 'your time' learning. He has already given his reasoning for NOT publishing a registerWrite() function because of the damage/danger potential. 

'favors' are owed, what have you done for him?

Chuck.
Currently built mega http server, Now converting it to ESP32.

digitalpbk

Have forked the SDFS library and added the writeCSD and writeRegister function. Please use it at your own risk.

Thanks fat16 aka greiman for the awesome library.

https://github.com/digitalpbk/SdFs

migera

Only a few bits of the CSD register are writable (many are read-only - see datasheet). Changing these bits is a trivial task, especially with the SdFs library. An example is attached. This sketch posibles view state and allows you to reset the tmp_write_protect bit (as example). However, keep in mind that this is not a panacea for restoring the working efficiency of cards. There are many reasons for incorrect operation and complete inoperability of memory cards that are in no way connected with write protection mechanisms in the registry CSD.

Nico_TheDecoder

Nice work!


It is also possible to lock/unlock an SD/µSD card with a password.

See link: https://www.seanet.com/~karllunt/sdlocker2.html

But it could be naughty to implement the CSD PWD function, so it is as easy to use as tmp_write_protect.

Code: [Select]

m_csd.v1.tmp_write_protect = 0; // SET TMP OFF
m_csd.v2.tmp_write_protect = 0; // SET TMP OFF
sd.card()->writeCSD(&m_csd); // SAVE CSD DATA!



Here's an example of what I mean by CSD PWD (SD-Locker_v2.ino)

Note that, this is not my code!


Go Up