Skip to content

Commit

Permalink
dpcmd.c
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Nov 21, 2017
1 parent 4c17007 commit 44e1885
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 19 deletions.
7 changes: 4 additions & 3 deletions SerialFlash.c
Original file line number Diff line number Diff line change
Expand Up @@ -1722,7 +1722,7 @@ int SerialFlash_bulkPipeRead(struct CAddressRange *AddrRange, unsigned char *vDa
}
}
else
{
{
pageNum = AddrRange->length >> 9 ;
FlashCommand_SendCommand_SetupPacketForBulkRead(AddrRange, modeRead,ReadCom,Index);
for(i = 0; i < pageNum; ++ i)
Expand All @@ -1732,13 +1732,14 @@ int SerialFlash_bulkPipeRead(struct CAddressRange *AddrRange, unsigned char *vDa
{
return false ;
}
//memcpy(vData + i*ret, v, ret);
//memcpy(vData + i*ret, v, ret);
}
}
if(SerialFlash_EnableQuadIO(false,m_boEnReadQuadIO,Index) == SerialFlash_FALSE)
return false;
SerialFlash_Enable4ByteAddrMode(false, Index);
return true ;
{
return true ; }
}


Expand Down
21 changes: 12 additions & 9 deletions 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.3.1.%02d Engine Version:\nLast Built on Sep 22 2017\n\n",GetConfigVer()); //1. new feature.bug.config
printf("\nDpCmd Linux 1.3.2.%02d Engine Version:\nLast Built on Sep 22 2017\n\n",GetConfigVer()); //1. new feature.bug.config

g_ucOperation=0;
GetLogPath(g_LogPath);
Expand Down Expand Up @@ -1333,17 +1333,20 @@ void do_DisplayOrSave(void)
if(g_uiDevNum==0)
{
for(int icnt=0;icnt<dev_cnt;icnt++)
{
{

if(strcmp(g_parameter_read, "STDOUT")==0)
{
int i,Len=UploadAddrRange.end-UploadAddrRange.start;
printf("\n");
printf("Hex value display (starting from 0x%02X, 0x%02zXbytes in total): \n",g_uiAddr,g_uiLen);
printf("Hex value display (starting from 0x%02X, 0x%02zX bytes in total): \n",g_uiAddr,g_uiLen);
for(i=0; i<Len; i++)
{
{
if((i%16==0) && i != 0)
printf("\n");
printf("%02X ",pBufferForLastReadData[icnt]);
{
printf("\n");
}
printf("%02X ",*(pBufferForLastReadData[icnt]+i));
}
printf("\n\n");
}
Expand All @@ -1364,17 +1367,17 @@ void do_DisplayOrSave(void)
}
}
else if(g_uiDevNum!=0)
{
{
if(strcmp(g_parameter_read, "STDOUT")==0)
{
int i,Len=UploadAddrRange.end-UploadAddrRange.start;
printf("\n");
printf("Hex value display (starting from 0x%02X, 0x%02zXbytes in total): \n",g_uiAddr,g_uiLen);
printf("Hex value display (starting from 0x%02X, 0x%02zX bytes in total): \n",g_uiAddr,g_uiLen);
for(i=0; i<Len; i++)
{
if((i%16==0) && i != 0)
printf("\n");
printf("%02X ",pBufferForLastReadData[g_uiDevNum-1]);
printf("%02X ",*(pBufferForLastReadData[g_uiDevNum-1]+i));
}
printf("\n\n");
}
Expand Down
26 changes: 19 additions & 7 deletions project.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,15 +437,16 @@ bool threadEraseWholeChip(int Index)
}

bool threadReadRangeChip(struct CAddressRange range,int Index)
{
{
bool result = true;
struct CAddressRange AddrRound;

SetIOMode(false,Index);

AddrRound.start= (range.start &(~(0x1FF)));
AddrRound.end=((range.end +0x1FF) & (~(0x1FF)));
AddrRound.length=AddrRound.end-AddrRound.start;
AddrRound.length=AddrRound.end-AddrRound.start;

unsigned char *pBuffer = malloc(AddrRound.length);

if(pBufferForLastReadData[Index]==NULL)
Expand All @@ -463,13 +464,16 @@ bool threadReadRangeChip(struct CAddressRange range,int Index)
}

result = SerialFlash_rangeRead(&AddrRound, pBuffer, Index);

if(result)
{
UploadAddrRange.start = range.start;
UploadAddrRange.end= range.end;
UploadAddrRange.length = range.end-range.start;
memcpy(pBufferForLastReadData[Index],pBuffer+ (UploadAddrRange.start & 0x1FF),UploadAddrRange.length);
}

}

free(pBuffer);

return result;
Expand Down Expand Up @@ -530,7 +534,7 @@ bool threadConfiguredReadChip(int Index)
}
else if(0 == addr.start && (0 == addr.length))
{
result = threadReadChip(Index);
result = threadReadChip(Index);
}
else
{
Expand Down Expand Up @@ -897,7 +901,15 @@ void threadRun(void* Type)
int Index=thread_data->USBIndex;
g_is_operation_successful[Index] = true;
bool is_greater_than_5_0_0 = is_BoardVersionGreaterThan_5_0_0(Index);


int dwUID=ReadUID(Index);
if( g_uiAddr==0 && g_uiLen ==0)
{
if((dwUID / 600000)==0)
printf("\nDevice %d (DP%06d):",Index,dwUID);
else
printf("\nDevice %d (SF%06d):",Index,dwUID);
}

if( opType==UPDATE_FIRMWARE )
{
Expand Down Expand Up @@ -997,6 +1009,7 @@ void Run(OPERATION_TYPE type,int DevIndex)
{
for(int i=0;i<dev_cnt;i++)
{

thread_data[i]=(THREAD_STRUCT*)malloc(sizeof(THREAD_STRUCT));
thread_data[i]->type=type;
bAuto[i]=false;
Expand All @@ -1009,8 +1022,7 @@ void Run(OPERATION_TYPE type,int DevIndex)
{
thread_data[DevIndex-1]=(THREAD_STRUCT*)malloc(sizeof(THREAD_STRUCT));
thread_data[DevIndex-1]->type=type;
bAuto[DevIndex-1]=false;
printf("\nSlot %d (%06d)",DevIndex,ReadUID(DevIndex-1));
bAuto[DevIndex-1]=false;
thread_data[DevIndex-1]->USBIndex=DevIndex-1; //0;
pthread_create(&id,NULL,(void *) threadRun,(void*)thread_data[DevIndex-1]);
}
Expand Down

0 comments on commit 44e1885

Please sign in to comment.