Skip to content

Commit

Permalink
fixBug
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Jan 11, 2023
1 parent 47b7c8d commit c384851
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 29 deletions.
21 changes: 20 additions & 1 deletion ChipInfoDb.dedicfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<DediProgChipDatabase
Description="DediProg Pro Supported memory info"
Creator="DediProg Pro"
Ver="6.00"
Ver="7.00"
CreateDate="2007-September-25"
Locale="2052">
<Portofolio
Expand Down Expand Up @@ -9023,6 +9023,25 @@
AddrWidth="3"
IDNumber="3"
RDIDCommand="0x9F" />
<Chip TypeName="GD25LQ16E"
ICType="SPI_NOR"
Class="M25Pxx"
UniqueID="0xC86015"
Description="16 Mbit, Low Voltage, Serial Flash Memory With 100MHz SPI Bus Interface"
Manufacturer="GigaDevice"
ManufactureUrl="www.gigadevice.com"
Voltage="3.3V"
Clock="100MHz"
Timeout="40"
ManufactureID="0xC8"
JedecDeviceID="0xC86015"
AlternativeID="0x14"
ChipSizeInKByte="2048"
SectorSizeInByte="65536"
PageSizeInByte="256"
AddrWidth="3"
IDNumber="3"
RDIDCommand="0x9F" />
<Chip TypeName="GD25Q32"
ICType="SPI_NOR"
Class="M25Pxx"
Expand Down
8 changes: 4 additions & 4 deletions FlashCommand.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,14 @@ int FlashCommand_TransceiveOut(unsigned char* v, int len, int has_result_in, int

int FlashCommand_TransceiveIn(unsigned char* v, int len, int Index)
{
CNTRPIPE_RQ rq;

CNTRPIPE_RQ rq;
rq.Function = URB_FUNCTION_VENDOR_ENDPOINT;
rq.Direction = VENDOR_DIRECTION_IN;
rq.Request = TRANSCEIVE;
if (Is_NewUSBCommand(Index)) {
if (Is_NewUSBCommand(Index)) {
rq.Value = 0x01;
rq.Index = NO_REGISTER;
} else {
} else {
rq.Value = CTRL_TIMEOUT;
rq.Index = NO_REGISTER;
}
Expand Down Expand Up @@ -199,6 +198,7 @@ int FlashCommand_SendCommand_SetupPacketForBulkRead(struct CAddressRange* AddrRa
// length in terms of 256 bytes
size_t pageNum = AddrRange->length >> 9;


vInstruction[0] = (unsigned char)(pageNum & 0xff); // lowest byte of length : page number
vInstruction[1] = (unsigned char)((pageNum >> 8) & 0xff); // highest byte of length: page number
vInstruction[2] = (unsigned char)((pageNum >> 16) & 0xff); // reserved
Expand Down
9 changes: 3 additions & 6 deletions dpcmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ int main(int argc, char* argv[])
unsigned long r;
char* env;

printf("\nDpCmd Linux 1.12.11.%02d Engine Version:\nLast Built on October 27 2021\n\n", GetConfigVer()); // 1. new feature.bug.configS
printf("\nDpCmd Linux 1.13.11.%02d Engine Version:\nLast Built on October 27 2021\n\n", GetConfigVer()); // 1. new feature.bug.configS

g_ucOperation = 0;
GetLogPath(g_LogPath);
Expand Down Expand Up @@ -1311,12 +1311,9 @@ bool ListTypes(void)
return Dedi_List_AllChip();
}
bool CheckProgrammerInfo(void)
{
//printf("evy-- CheckProgrammerInfo 1\n");
{
if ((g_ucOperation & CHECK_INFO) != CHECK_INFO)
return false;

//printf("evy-- CheckProgrammerInfo 2\n");
return false;
int dev_cnt = get_usb_dev_cnt();
unsigned int uiFPGAVer = 0;
if (g_uiDevNum == 0) {
Expand Down
7 changes: 4 additions & 3 deletions project.c
Original file line number Diff line number Diff line change
Expand Up @@ -1153,10 +1153,11 @@ bool is_BoardVersionGreaterThan_5_0_0(int Index)
}

bool is_SF100nBoardVersionGreaterThan_5_5_0(int Index)
{
if ((g_firmversion >= FIRMWARE_VERSION(5, 5, 0)) && strstr(g_board_type, "SF100") != NULL)
{
if ((g_firmversion >= FIRMWARE_VERSION(5, 5, 0)) && strstr(g_board_type, "SF100") != NULL)
return true;
return false;

return false;
}

bool is_SF600nBoardVersionGreaterThan_6_9_0(int Index)
Expand Down
46 changes: 31 additions & 15 deletions usbdriver.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ unsigned g_usb_busnum = -1;

bool Is_NewUSBCommand(int Index)
{
if (is_SF100nBoardVersionGreaterThan_5_5_0(Index) || is_SF600nBoardVersionGreaterThan_6_9_0(Index) || is_SF700(Index)) {
//printf("\n====>usbdriver.c ---- Is_NewUSBCommand(Index=%d) == ture\n",Index);
if (is_SF100nBoardVersionGreaterThan_5_5_0(Index) || is_SF600nBoardVersionGreaterThan_6_9_0(Index) || is_SF700(Index)) {
return true;
}
}
return false;
}
extern unsigned char GetFPGAVersion(int Index);
Expand Down Expand Up @@ -66,8 +65,7 @@ void usb_db_init(void)
}

void AssignSF600orSF700var(int Index)
{
//printf("\n===>usbdrive.c --- IsSF600\n");
{
if (Index == -1)
Index = DevIndex;

Expand All @@ -86,20 +84,19 @@ void AssignSF600orSF700var(int Index)
rq.Value = 0;
rq.Index = 0;
rq.Length = 32;

if (InCtrlRequest(&rq, vBuffer, 32, Index) == SerialFlash_FALSE)
return;
return;

memcpy(g_board_type, &vBuffer[0], 8);
//memcpy(g_firmversion,&vBuffer[10],8);
sscanf((char*)&vBuffer[8], "V:%d.%d.%d", &fw[0], &fw[1], &fw[2]);
g_firmversion = ((fw[0] << 16) | (fw[1] << 8) | fw[2]);

if (strstr(g_board_type, "SF700") != NULL)
g_bIsSF700[Index] = true;

if (strstr(g_board_type, "SF700") != NULL)
g_bIsSF700[Index] = true;
else if (strstr(g_board_type, "SF600") != NULL)
{
{
if (strstr(g_board_type, "SF600PG2") != NULL)
{
g_bIsSF600PG2[Index] = true;
Expand All @@ -108,7 +105,7 @@ void AssignSF600orSF700var(int Index)
{
g_bIsSF600[Index] = true;
}
}
}


GetFPGAVersion(Index);
Expand Down Expand Up @@ -199,11 +196,12 @@ int OutCtrlRequest(CNTRPIPE_RQ* rq, unsigned char* buf, unsigned long buf_size,

int InCtrlRequest(CNTRPIPE_RQ* rq, unsigned char* buf, unsigned long buf_size, int Index)
{
int requesttype;
int ret = 0;
unsigned int requesttype;
unsigned int ret = 0;

if ((rq->Function != URB_FUNCTION_VENDOR_ENDPOINT) && ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true)))
return true;

if (Index == -1)
Index = DevIndex;

Expand All @@ -229,7 +227,25 @@ int InCtrlRequest(CNTRPIPE_RQ* rq, unsigned char* buf, unsigned long buf_size, i
printf("no device");
}

if (ret != buf_size) {
if (ret != 0 /*!= buf_size*/)
return ret;
else
{

#if 0

printf("InCtrlRequest ---ret=%X\n",ret);
printf("evInCtrlRequesty ---Control Pipe output error!\n");
printf("InCtrlRequest ---rq->Direction=%lX\n",rq->Direction);
printf("InCtrlRequest ---rq->Function=%X\n",rq->Function);
printf("InCtrlRequest ---rq->Request=%X\n",rq->Request);
printf("InCtrlRequest ---rq->Value=%X\n",rq->Value);
printf("InCtrlRequest ---rq->Index=%X\n",rq->Index);
printf("InCtrlRequest ---rq->Length=%lX\n",rq->Length);
printf("InCtrlRequest ---buf_size=%lX\n",buf_size);
printf("InCtrlRequest ---buf[0]=%X\n",buf[0]);
//printf("g_bIsSF600=%d\n",g_bIsSF600);
#endif
printf("Control Pipe input error!\n");
return -1;
}
Expand Down

0 comments on commit c384851

Please sign in to comment.