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.
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.
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().
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.
Can you share sketch from your screen?
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 ![]()
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
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.
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.
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.
SdSpiCard-CSD-Unlock.ino (2.47 KB)
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.
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!
SD-Locker_v2.ino (29.9 KB)