EmbDev.net

Forum: µC & Digital Electronics SD card lock and unlock


Author: Al pacino Deniro (bigmicro)
Posted on:

Rate this post
0 useful
not useful
Hello guys,

I got my SD card software working fine, but now I have a problem with 
locking a SD card programmaticaly. I use the command CMD42 to set a 
password and to lock and unlock. I've tried several times, but nothing 
seems to happen. Everything seems to work, but it's like just nothing 
happens.

So I was wondering if you guys managed to lock the card with CMD42 (not 
the mechanical switch lock). If you did it, would you please post the 
piece of code here? I hope this feature is not limited, because of not 
having a license for it.

I use the following hardware:
SD-micro of 1GB, normal SD of 1GB
ARM microcontroller (AT91SAM7A3)
IAR 4.41 Compiler.


Thank you very much.

Author: Mike (Guest)
Posted on:

Rate this post
0 useful
not useful
According to SD card specification CMD42 is an optional optional and may 
not be implemented by all manufacturers. What card are you using?

Author: Mike (Guest)
Posted on:
Attached files:

Rate this post
0 useful
not useful
Toshiba states under CMD42:
"CMD42 LOCK_UNLOCK - Card Lock/Unlock Function is not implemented."
So if your card is from Toshiba it would not work. Sandisk, however 
seems to support CMD42

Best regards
Mike

Author: Termite (Guest)
Posted on:

Rate this post
0 useful
not useful
The CMD42 is optional in Version 1.01 and 1.10 and mandatory from 
Version 2.00.

Author: Al pacino Deniro (bigmicro)
Posted on:

Rate this post
0 useful
not useful
Thanks for your responses my friends,

I use only Sandisk cards (I use microSD which belongs to Version 2.00 
and higer) but that seems not to work. Also I can't find any software 
for WinXP to do a software lock based on password for those SD cards, 
just to make sure that it works.

It's realy strange that there is almost no information about it except 
in the Sandisk documentation (which is very limited to text only).

Hope someone can tell me more about it.

Author: Termite (Guest)
Posted on:

Rate this post
0 useful
not useful
Ther are some informations to the SD-card commands on 
http://www.sdcard.org/about/memory_card/pls/

see 4.3.7 Card Lock/Unlock Operation

have you checked Card Status after sendig the command? perhaps ther are 
some information wat is going wrong.

see 4.10.1 Card Status for more information

Author: Al pacino Deniro (bigmicro)
Posted on:

Rate this post
0 useful
not useful
Hi Termite,

I already have done that, that's how I managed to read/write SDHC cards.
That's why it's a real problem to me, because using the documentation is 
the only information I have about lock/unlock the SD card. It's a bit 
confusing...

Please if someone else implement the lock/unlock piece, please share 
with me the source, or at least what things should I do. Cause it 
doesn't work accoording to the Simplify spec doc from Sandisk.

Thank you.

Author: Termite (Guest)
Posted on:

Rate this post
0 useful
not useful
Please check the card State after sending the lock comand.
After locking a card you have to unplug the card to check if the lock is 
working.

please check if you are in the correct state to send the command. You 
can see it in the card state.

please check block length and paswort length. you know that you have to 
send the compleat block length (2^n) data for the command? you have to 
set block length befor sending the command data. and you have to send as 
many data you have specified in block length. non used data can be 
filled with dummy byts.

Author: Al pacino Deniro (bigmicro)
Posted on:

Rate this post
0 useful
not useful
Thanks Termite,

Ok, there can be several reasons why it couldn't work.
Like you said, the length of datablok. I just used 4 bytes, one is for 
mode, one is for passwordlen and two for the password. I used as 
password: 0xAAAA.
But I also include 2 bytes of CRC16 value, but set datablock length is 
just 4 bytes. I get no error, the response of CMD42 = 
0b00000000000000000000100100000000
When I ask the card for the card-status I get: 
0b00000000000000000000110100000000

Another reason could be that I switched off CRC check at the very 
beginning, while CMD42 uses CRC16 on the dataline.

Author: Al pacino Deniro (bigmicro)
Posted on:

Rate this post
0 useful
not useful
Hello,

Has anyone tried the software lock/unlock command (CMD42) succesfully?
Because I don't, and I'm so tired and stressed of waisting my boss's 
time.
I've tried everything, but that damned command is not working for me.
I realy hope someone can give me a golden tip.

Thank you.

Author: Al pacino Deniro (bigmicro)
Posted on:

Rate this post
0 useful
not useful
Hello guys,

I recently tried to get lock/unlock the SD card again, but with no 
succes.
So is there anybody who got the lock/unlock working for the SD card?

I've searched the whole web, read SD documentation again and again with 
another guy from my work, but I still can't manage to get it work. Also 
it seems there is nobody on this planet who manages to lock an SD card 
with a password and than unlock it again. Even Linux or Windows don't 
have the possibility to protect the SD card with lock command. Also 
there is no software that can do that, even commercial ones.

So I seriously doubt wether CMD42 (lock/unlock) is actually working. So 
I dare to challenge really good embedded experts that they can't get the 
CMD42 working. So experts, prove me I'm totally wrong, I really offer 
you to disgrace me as much as you can.

Thank you.

Author: 135790 135790 (Company: 246810) (chairang)
Posted on:
Attached files:

Rate this post
0 useful
not useful
HI
I tested the lock/unlock function ,and it worked.
I used to want to help you ,but I'am an Chinese and I don't understand 
German-language, I tryed to login, but don't know how to login.
Today while I try again, I find it's in English, my English is poor, but 
I know some simple words.
At first you should check out whether your SD card support lock/unlock. 
I have three SD cards tested, two from panasonic(32MB) and one from 
kingston(2GB),it seems the old panasonic card does not support this 
function, and the new kongston SD works well.
You can use a mobile phone to check it. I don't know why Windows doesn't 
support, but my Linux phone(MOTO E6)supports. If the SD card support, 
you would see a "password protection".
I use the MOTO E6 to lock my card, and use STM32F103VBT6 to unlock, then 
use STM32 to lock and E6 to unlock, both works well.
I use the SPI mode.
If I cound help you, please email chairang<at>126.com

Author: Asif (Guest)
Posted on:

Rate this post
0 useful
not useful
Yes

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.