User guide
3.19 Interface for creating SD password
You can create individual passwords for SD/MMC cards by using an external application. The
application is called by the PowerSoftware using a file path and name as second argument. This
file contains the CID of the SD/MMC card. The program is responsible to modify the file so that it
will contain the new password. The maximum length of the file is 16 Bytes. The PowerSoftware will
interpret a return codes of 0 as success. All other return codes will be treated as error. The
following C code demonstrate the a possible external program. In this case the program read in the
CID from the original file, extract the 32 bit serial number according to the SD specification and
then creates a new file with these 4 bytes.
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
int main(int argc, char* argv[])
{
FILE* pFile;
int iReturnCode = 0;
unsigned char a_ucCID[16];
if (argc < 2)
{
pFile = fopen(argv[1],"r+b");
if(pFile == NULL)
{
iReturnCode = 2;
}
else // if(pFile == NULL)
{
int iBytes = fread( a_ucCID,1,16, pFile);
fclose(pFile);
if( iBytes != 16)
{
iReturnCode = 3;
}
else // if( iBytes != 16)
{
fopen(argv[1],"wb");
if(pFile == NULL)
{
iReturnCode = 2;
}
else // if(pFile == NULL)
{
//Extract 32 Bit serial from CID and write to file...
iBytes = fwrite(&a_ucCID[10],1,4, pFile);
58/61