Skip to content

Commit

Permalink
optimize MT25Qxxx
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Jun 8, 2018
1 parent 2611a20 commit 5447e2a
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 24 deletions.
117 changes: 97 additions & 20 deletions SerialFlash.c
Original file line number Diff line number Diff line change
Expand Up @@ -1336,40 +1336,40 @@ bool CN25Qxxx_LargeRDFSR(unsigned char *cSR, int Index)
*cSR = vBuffer;
return SerialFlash_TRUE;
}
bool CN25Qxxx_Large_doWRVCR(unsigned char sVCR,int Index)
bool CN25Qxxx_Large_doWRVCR(unsigned char ucVCR,int Index)
{
unsigned char vInstruction[2]; //size 1

SerialFlash_waitForWIP(Index);
SerialFlash_waitForWEL(Index);
vInstruction[0]=0x81;
vInstruction[1]=sVCR&0xFF;
vInstruction[1]=ucVCR&0xFF;

FlashCommand_TransceiveOut(&vInstruction,2,false,Index);

SerialFlash_waitForWIP(Index);

unsigned char sRDVCR=0xFF;
unsigned char ucRDVCR=0xFF;

int numOfRetry = 5 ;
unsigned char re;
//do{
CN25Qxxx_Large_doRDVCR(&sRDVCR,Index);
do{
CN25Qxxx_Large_doRDVCR(&ucRDVCR,Index);
Sleep(100);
// }while(sRDVCR !=sVCR && numOfRetry-- > 0);
}while(ucRDVCR !=ucVCR && numOfRetry-- > 0);

//if(numOfRetry<=0)
// return false;
if(numOfRetry<=0)
return false;

return true;
}


bool CN25Qxxx_Large_doRDVCR(unsigned char *sVCR,int Index)
bool CN25Qxxx_Large_doRDENVCR(unsigned char *ucENVCR,int Index)
{
CNTRPIPE_RQ rq ;
unsigned char vInstruction; //size 1
vInstruction=0x85;
vInstruction=0x65;

rq.Function = URB_FUNCTION_VENDOR_ENDPOINT ;
rq.Direction = VENDOR_DIRECTION_OUT ;
Expand Down Expand Up @@ -1407,10 +1407,86 @@ bool CN25Qxxx_Large_doRDVCR(unsigned char *sVCR,int Index)
rq.Length = 1;

if(InCtrlRequest(&rq, &vBuffer, 1, Index) == SerialFlash_FALSE)
return SerialFlash_FALSE ;
*ucENVCR = vBuffer;
return SerialFlash_TRUE;

}


bool CN25Qxxx_Large_doWRENVCR(unsigned char ucENVCR,int Index)
{
unsigned char vInstruction[2]; //size 1

SerialFlash_waitForWIP(Index);
SerialFlash_waitForWEL(Index);
vInstruction[0]=0x61;
vInstruction[1]=ucENVCR&0xFF;

FlashCommand_TransceiveOut(&vInstruction,2,false,Index);

SerialFlash_waitForWIP(Index);

unsigned char ucRDENVCR=0xFF;

int numOfRetry = 5 ;
unsigned char re;
do{
CN25Qxxx_Large_doRDENVCR(&ucRDENVCR,Index);
Sleep(100);
}while(ucRDENVCR !=ucENVCR && numOfRetry-- > 0);

if(numOfRetry<=0)
return false;

return true;
}


bool CN25Qxxx_Large_doRDVCR(unsigned char *ucVCR,int Index)
{
CNTRPIPE_RQ rq ;
unsigned char vInstruction; //size 1
vInstruction=0x85;

rq.Function = URB_FUNCTION_VENDOR_ENDPOINT ;
rq.Direction = VENDOR_DIRECTION_OUT ;
rq.Request = TRANSCEIVE ;
if(Is_NewUSBCommand(Index))
{
rq.Value = RESULT_IN ;
rq.Index = RFU ;
}
else
{
rq.Value = RFU ;
rq.Index = RESULT_IN ;
}
rq.Length = 1;//(unsigned long) 1 ;

if(OutCtrlRequest(&rq, &vInstruction, 1, Index) == SerialFlash_FALSE)
return SerialFlash_FALSE ;
///printf("evy &vBuffer=%x",&vBuffer);
///printf("evy vBuffer=%x",vBuffer);
*sVCR = vBuffer;

// second control packet : fetch data
unsigned char vBuffer;
rq.Function = URB_FUNCTION_VENDOR_ENDPOINT ;
rq.Direction = VENDOR_DIRECTION_IN ;
rq.Request = TRANSCEIVE ;
if(Is_NewUSBCommand(Index))
{
rq.Value = 1;
rq.Index = 0;
}
else
{
rq.Value = CTRL_TIMEOUT ;
rq.Index = NO_REGISTER ;
}
rq.Length = 1;

if(InCtrlRequest(&rq, &vBuffer, 1, Index) == SerialFlash_FALSE)
return SerialFlash_FALSE ;
*ucVCR = vBuffer;
return SerialFlash_TRUE;

}
Expand Down Expand Up @@ -2223,26 +2299,27 @@ bool SerialFlash_StartofOperation(int Index)
if(strstr(Chip_Info.Class,SUPPORT_NUMONYX_N25Qxxx_Large_2Die) != NULL ||
strstr(Chip_Info.Class,SUPPORT_NUMONYX_N25Qxxx_Large_4Die) != NULL ||
strstr(Chip_Info.Class,SUPPORT_NUMONYX_N25Qxxx_Large) != NULL)
{
g_micron_usVCR=0xFF;
if(CN25Qxxx_Large_doWRVCR(g_micron_usVCR,Index)==false)
{
if(CN25Qxxx_Large_doWRVCR(0xFB,Index)==false)
return false;
if(CN25Qxxx_Large_doWRENVCR(0xFF,Index)==false)
return false;
else
return true;
return true;
}
return true;
return true;
}


bool SerialFlash_EndofOperation(int Index)
{
return true;
if(strstr(Chip_Info.Class,SUPPORT_NUMONYX_N25Qxxx_Large_2Die) != NULL ||
strstr(Chip_Info.Class,SUPPORT_NUMONYX_N25Qxxx_Large_4Die) != NULL ||
strstr(Chip_Info.Class,SUPPORT_NUMONYX_N25Qxxx_Large) != NULL)
{

return true;
}
return true;
}

8 changes: 5 additions & 3 deletions SerialFlash.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,15 @@ int SerialFlash_is_protectbits_set(int Index);
bool SST25xFxxA_protectBlock(int bProtect,int Index);
bool SST25xFxx_protectBlock(int bProtect,int Index);
bool AT25FSxxx_protectBlock(int bProtect,int Index);
bool CEN25QHxx_LargeEnable4ByteAddrMode(bool Enable4Byte,int Index);
bool CEN25QHxx_LargeEnable4ByteAddrMode(bool Enable4Byte,int Index);
bool CN25Qxxx_LargeRDFSR(unsigned char *cSR, int Index);
bool CN25Qxxx_LargeEnable4ByteAddrMode(bool Enable4Byte,int Index);
bool CN25Qxxx_MutipleDIe_LargeWREAR(unsigned char cSR, int Index);
bool CN25Qxxx_MutipleDIe_LargeRDEAR(unsigned char *cSR, int Index);
bool CN25Qxxx_Large_doRDVCR(unsigned char *sVCR,int Index);
bool CN25Qxxx_Large_doWRVCR(unsigned char sVCR,int Index);
bool CN25Qxxx_Large_doRDVCR(unsigned char *ucVCR,int Index);
bool CN25Qxxx_Large_doWRVCR(unsigned char ucVCR,int Index);
bool CN25Qxxx_Large_doRDENVCR(unsigned char *ucENVCR,int Index);
bool CN25Qxxx_Large_doWRENVCR(unsigned char ucENVCR,int Index);

size_t GetChipSize(void);
size_t GetPageSize(void);
Expand Down
2 changes: 1 addition & 1 deletion dpcmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ int main(int argc, char *argv[])

//signal(SIGINT, sin_handler);

printf("\nDpCmd Linux 1.7.1.%02d Engine Version:\nLast Built on May 25 2018\n\n",GetConfigVer()); //1. new feature.bug.config
printf("\nDpCmd Linux 1.8.1.%02d Engine Version:\nLast Built on May 25 2018\n\n",GetConfigVer()); //1. new feature.bug.config

g_ucOperation=0;
GetLogPath(g_LogPath);
Expand Down

0 comments on commit 5447e2a

Please sign in to comment.