Go Down

Topic: Some success with writeCID (Read 58386 times) previous topic - next topic


Hi all,

I need to program the CID of SD cards. I found couple of cheap SD cards that accepts CMD26. I use Arduino Uno to communicate with the SD card. I can also see my CMD26 changes the CID time to time with garbage values (not always). I need to know the way to set the CID reliably. I'm using SD2Card library (with modifications) to do this. Can someone let me know the byte sequences that I need to send to the SD card in order to write the CID?

Thanks in advance,


Why do you want to write the CID?

normally the CID is used for identification & protection of apps on SDcard  IIRC?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)


I need to copy protect my application + impress my friends. I don't think its a difficult task. Unfortunately information is not readily available for a DIYer like me.


Jul 15, 2011, 02:51 pm Last Edit: Jul 15, 2011, 03:02 pm by fat16lib Reason: 1
CMD26 is reserved.  If your card allows CMD26, it may not work properly.

CMD26 should not be supported in SPI mode.

From the SD association:


Programming of the card
identification register. This
command shall be issued only
once. The card contains
hardware to prevent this
operation after the first
programming. Normally this
command is reserved for the



I know the docs say CMD26 is reserved and it will not work on SPI mode etc... Obviously some SD manufacturers are not bothered. I don't think it is illegal to write to CID or to exploit the cheaper SD card features provided against the spec.

If no one has used CMD26, then anyone know how to use CMD27? I think CMD26 will  also work the same way with required data size.




Can someone help me on this ?



When you use CMD27 you must only change the writable part of the CSD.  The other data must match the read only part in the CSD. 

You must use the correct value for the CRC field in the register.

These are the three bits you can change but only TMP_WRITE_PROTECT can changed back.

Defines whether the contents is original (=0) or has been copied (=1). Setting this bit to 1 indicates that
the card content is a copy. The COPY bit is a one time programmable bit except ROM card.
Permanently protects the entire card content against overwriting or erasing (all write and erase
commands for this card are permanently disabled). The default value is 0, i.e. not permanently write
Temporarily protects the entire card content from being overwritten or erased (all write and erase
commands for this card are temporarily disabled). This bit can be set and reset. The default value is 0,
i.e. not write protected.


Thanks fat16lib for the reply.

OK I understand that I need to be careful when writing to CSD as PERM_WRITE_PROTECT will make my SD unusable (unless I have anything useful for reading). My query is how do I use CMD27.

I can use SD2Card cardCommand(27, 0) and get the response. How do I write the data that goes into the register?

if (ret = cardCommand(27, 0))
   Serial.print("CMD27 failed :");
   Serial.println(ret, HEX);
    return false;
   Serial.println("CMD27 worked");

spiSend(data1); // send 1st byte
spiSend(data2); // send 2nd byte

Will this work ? Doesn't want to try this and ruin the card.

Thanks again


Hi fat16lib, looks like you are my only hope.


Any improvement on modyfing SD CID registers?


Hi all,

There's been inquiries on what happened on this project. This is to update all of you who are still searching for a solution.

I was not able to continue on this project after the roadblock I came across. I would love to hear  from anyone who got it working. As per SD cards, go for cheap / unbranded SD cards, they will most probably support CID to be written.



Mar 29, 2014, 12:06 am Last Edit: Apr 02, 2014, 10:10 pm by Arduinux Reason: 1
Hi all.
Ok, I want to take a chance.
I need some informations, though.
Somebody wrote about cheap MMC or SD cards.
I guess they could even be counterfeit or fake cards but which they allow CMD26.
So, someone could tell what cards (brand and model or manufacturer) surely accept CMD26?
Honestly I tried to find them but no joy.
Where have you found them?
That said it would be possible go ahead otherwise we are stuck no way out and without any possibility, hence it's game over.
Another thing which could be important and useful to know is the way you need to send CMD26.
I wonder if you need to send it in SPI mode or MMC mode.
I guess the correct way is through SPI mode.
This is because I know Arduino generally manages SD/MMC in that way and here in the beginning of the thread someone wrote about modified SD2Card library in order to change/rewrite CID.
Though I could be wrong on this.
Any answers based on your experience will be welcome.
Thanks in advance!



Hey you had any further progress changing the CID?


Hi Bucky101,
sadly no, no progress.
I'm pretty sure I'd be able to do the job but unluckily I can't find the right SD/MMC.
I have contacted many manufacturer but nobody gave me even only one single piece.
They ask to buy a lot of pieces, only few pieces are out of business on their point of view so they don't sold few pieces.
All this stuck me.
That is.
But I don't give up!



After few months of research and development I finally figured out how get this working.
hranmuthu, I was able to send CMD26 via SPI and got permanent result (New CID)
But it's more complex then just sending the command
I was able to succeed with 2 major manufacturers out of 4 and each controller needs different methods.
It is possible but very time consuming since you will need to come up with different ways for different controllers. Also Creating something (Universal) that will work with every controller is almost impossible.

Go Up