diff --git a/ChipInfoDb.dedicfg b/ChipInfoDb.dedicfg
index ecf27eb..0d098ae 100755
--- a/ChipInfoDb.dedicfg
+++ b/ChipInfoDb.dedicfg
@@ -17573,6 +17573,29 @@ ICType="SPI_NOR"
+
+
+
RDIDCommand="0x9F"/>
+
+
start & 0xff);
vInstruction[7] = ((AddrRange->start >> 8) & 0xff);
@@ -131,7 +133,7 @@ int FlashCommand_SendCommand_SetupPacketForBulkWrite(struct CAddressRange* AddrR
vInstruction[14] = (AddressMode & 0xff);
rq.Value = 0;
rq.Index = 0;
- rq.Length = (unsigned long)(16);
+ rq.Length = (unsigned long)(15);
} else {
rq.Value = (unsigned short)(AddrRange->start & 0xffff); // 16 bits LSB
rq.Index = (unsigned short)((AddrRange->start >> 16) & 0xffff); // 16 bits MSB
diff --git a/SerialFlash.c b/SerialFlash.c
index b1ff698..7fabf04 100755
--- a/SerialFlash.c
+++ b/SerialFlash.c
@@ -1716,7 +1716,7 @@ int SerialFlash_Enable4ByteAddrMode(int bEnable, int Index)
return CN25Qxxx_LargeEnable4ByteAddrMode(bEnable, Index);
else if (strstr(Chip_Info.Class, SUPPORT_SPANSION_S25FLxx_Large) != NULL)
return CS25FLxx_LargeEnable4ByteAddrMode(bEnable, Index);
- else
+ else if(Chip_Info.ChipSizeInByte > 0x1000000)
return Universal_LargeEnable4ByteAddrMode(bEnable, Index);
return SerialFlash_TRUE;
}
diff --git a/board.c b/board.c
index 9e4aabe..0fe6b20 100755
--- a/board.c
+++ b/board.c
@@ -12,7 +12,7 @@ volatile bool g_bIsSF700 = false;
volatile bool g_bIsSF600PG2 = false;
extern char g_board_type[8];
extern char g_FPGA_ver[8];
-extern char g_FW_ver[8];
+extern char g_FW_ver[10];
extern char g_HW_ver[8];
extern int g_firmversion;
extern unsigned int g_IO1Select;
@@ -22,6 +22,41 @@ extern bool Is_NewUSBCommand(int Index);
// extern int is_SF100nBoardVersionGreaterThan_5_2_0(int Index);
// extern int is_SF600nBoardVersionGreaterThan_6_9_0(int Index);
+bool ReadSF700AndSF600PG2SN(unsigned char* Data, int Index)
+{
+ CNTRPIPE_RQ rq;
+ unsigned char vBuffer[6];
+
+ rq.Function = URB_FUNCTION_VENDOR_ENDPOINT;
+ rq.Direction = VENDOR_DIRECTION_OUT;
+ rq.Request = 0x71;
+ rq.Value = 0;
+ rq.Index = 0;
+ rq.Length = 6;
+
+
+ vBuffer[0]=0;
+ vBuffer[1]=0;
+ vBuffer[2]=0;
+ vBuffer[3]=2;
+ vBuffer[4]=0;
+ vBuffer[5]=0;
+
+//must read twice
+ if (OutCtrlRequest(&rq, vBuffer, 6, Index) == SerialFlash_FALSE)
+ return false;
+
+ unsigned char vBufferSN[512];
+ BulkPipeRead(vBufferSN, USB_TIMEOUT, Index);
+
+ if (OutCtrlRequest(&rq, vBuffer, 6, Index) == SerialFlash_FALSE)
+ return false;
+
+ BulkPipeRead(vBufferSN, USB_TIMEOUT, Index);
+
+ memcpy(Data, vBufferSN, 16);
+ return true;
+}
bool ReadOnBoardFlash(unsigned char* Data, bool ReadUID, int Index)
{
CNTRPIPE_RQ rq;
@@ -71,13 +106,7 @@ void QueryBoard(int Index)
return;
}
- memcpy(g_board_type, &vBuffer[0], 8);
-
- unsigned char ucData;
- if((strstr(g_board_type, "SF600PG2") != NULL))
- {
- printf(" evy UpdateSF600Flash\n");
- }
+ memcpy(g_board_type, &vBuffer[0], 8);
}
unsigned int GetFPGAVersion(int Index)
@@ -290,7 +319,7 @@ bool LeaveSF600Standalone(bool Enable, int Index)
if (OutCtrlRequest(&rq, &vBuffer, 0, Index) == SerialFlash_FALSE) {
return false;
}
-
+ Sleep(100);
return true;
}
@@ -323,7 +352,19 @@ unsigned int ReadUID(int Index)
unsigned int dwUID = 0;
unsigned char vUID[16];
- if ((g_bIsSF600 == true) || (g_bIsSF700 == true) || (g_bIsSF600PG2 == true)) {
+ if ((g_bIsSF700 == true) || (g_bIsSF600PG2 == true)) {
+ if (ReadSF700AndSF600PG2SN(vUID, Index) == false)
+ return false;
+//Sleep(200);
+ //if (ReadSF700AndSF600PG2SN(vUID, Index) == false)
+ // return false;
+
+ dwUID = (unsigned int)vUID[2] << 16 | (unsigned int)vUID[1] << 8 | vUID[0];
+ return dwUID;
+
+ }
+
+ if ((g_bIsSF600 == true) ) {
if (ReadOnBoardFlash(vUID, false, Index) == false)
return false;
if (g_bIsSF600 == true)
@@ -332,7 +373,7 @@ unsigned int ReadUID(int Index)
dwUID = (unsigned int)vUID[2] << 16 | (unsigned int)vUID[1] << 8 | vUID[0];
return dwUID;
}
-
+
CNTRPIPE_RQ rq;
unsigned char vBuffer[3];
@@ -346,7 +387,7 @@ unsigned int ReadUID(int Index)
if (InCtrlRequest(&rq, vBuffer, 3, Index) == SerialFlash_FALSE) {
return false;
- }
+ }
dwUID = (unsigned int)vBuffer[0] << 16 | (unsigned int)vBuffer[1] << 8 | vBuffer[2];
return dwUID;
@@ -732,33 +773,44 @@ bool GetFirmwareVer(int Index)
{
CNTRPIPE_RQ rq;
- unsigned char vBuffer[26];
+ unsigned char vBuffer[32];
+ unsigned int BufferSize =32;
+ if((g_bIsSF600== false) && (g_bIsSF700 == false) && (g_bIsSF600PG2 == false))
+ BufferSize = 16;
+
// first control packet
rq.Function = URB_FUNCTION_VENDOR_ENDPOINT;
rq.Direction = VENDOR_DIRECTION_IN;
rq.Request = PROGINFO_REQUEST;
rq.Value = 0;
rq.Index = 0;
- rq.Length = 26;
+ rq.Length = BufferSize;
- if (!OutCtrlRequest(&rq, vBuffer, 26, Index))
+ if (!OutCtrlRequest(&rq, vBuffer, BufferSize, Index))
return false;
-
+
if (!Is_usbworking(Index)) {
printf("Do not find SFxx programmer!!\n");
return false;
}
-
- memcpy(g_board_type, &vBuffer[0], 8);
- memcpy(g_FW_ver, &vBuffer[10], 7);
+
+ memcpy(g_board_type, &vBuffer[0], 8);
if (strstr(g_board_type, "SF600PG2") != NULL)
- memcpy(g_HW_ver, &vBuffer[20], 4);
- if (strstr(g_board_type, "SF600") != NULL)
- memcpy(g_HW_ver, &vBuffer[20], 4);
- if (strstr(g_board_type, "SF700") != NULL)
- memcpy(g_HW_ver, &vBuffer[21], 4);
+ {
+ memcpy(g_FW_ver, &vBuffer[12], 9);
+ memcpy(g_HW_ver, &vBuffer[25], 5);
+ }
+ else
+ {
+ memcpy(g_FW_ver, &vBuffer[10], 7);
+ if (strstr(g_board_type, "SF600") != NULL)
+ memcpy(g_HW_ver, &vBuffer[20], 4);
+ if (strstr(g_board_type, "SF700") != NULL)
+ memcpy(g_HW_ver, &vBuffer[21], 4);
+ }
+
return true;
}
@@ -902,8 +954,7 @@ bool UpdateSF600Flash_FPGA(const char* sFilePath, int Index)
Package[2] = ((fw_info.SecondSize >> 16) & 0xff);
Package[3] = ((fw_info.SecondSize >> 24) & 0xff);
- if (!OutCtrlRequest(&rq, Package, 4, Index)) {
- printf("Error: 1\n");
+ if (!OutCtrlRequest(&rq, Package, 4, Index)) {
free(pBuffer);
return false;
}
@@ -915,8 +966,7 @@ bool UpdateSF600Flash_FPGA(const char* sFilePath, int Index)
rq.Index = (unsigned short)((fw_info.SecondSize >> 16) & 0xffff);
rq.Length = 0;
- if (!OutCtrlRequest(&rq, pBuffer, 0, Index)) {
- printf("Error: 2\n");
+ if (!OutCtrlRequest(&rq, pBuffer, 0, Index)) {
free(pBuffer);
return false;
}
diff --git a/dpcmd.c b/dpcmd.c
index 8fc470d..dc07ddd 100755
--- a/dpcmd.c
+++ b/dpcmd.c
@@ -84,7 +84,7 @@ unsigned long g_ucOperation;
struct memory_id g_ChipID;
char g_board_type[8];
char g_FPGA_ver[8];
-char g_FW_ver[8];
+char g_FW_ver[10];
char g_HW_ver[8];
int g_firmversion;
@@ -408,13 +408,13 @@ void GetLogPath(char* pBuf)
void EnterStandaloneMode(int Index)
{
- if ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true))
+ if ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true)|| (g_bIsSF600PG2[Index] == true))
LeaveSF600Standalone(false, Index);
}
void LeaveStandaloneMode(int Index)
{
- if ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true))
+ if ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true)|| (g_bIsSF600PG2[Index] == true))
LeaveSF600Standalone(true, Index);
}
@@ -775,8 +775,12 @@ int main(int argc, char* argv[])
}
int dwUID = ReadUID(g_uiDevNum - 1);
if (g_bIsSF700[g_uiDevNum - 1] == true) {
- printf("\nDevice %d (SF7%05X):\tdetecting chip\n", g_uiDevNum, dwUID);
- } else if ((dwUID / 600000) > 0) {
+ printf("\nDevice %d (SF7%05d):\tdetecting chip\n", g_uiDevNum, dwUID);
+ } else if (g_bIsSF600PG2[g_uiDevNum - 1] == true) {
+ printf("\nDevice %d (S6B%05d):\tdetecting chip\n", g_uiDevNum, dwUID);
+ } else if ((g_bIsSF600[g_uiDevNum - 1] == true) && (dwUID / 600000) > 0) {
+ printf("\nDevice %d (SF%06d):\tdetecting chip\n", g_uiDevNum, dwUID);
+ } else if ((dwUID / 100000) > 0) {
printf("\nDevice %d (SF%06d):\tdetecting chip\n", g_uiDevNum, dwUID);
} else {
printf("\nDevice %d (DP%06d):\tdetecting chip\n", g_uiDevNum, dwUID);
@@ -801,8 +805,12 @@ int main(int argc, char* argv[])
int dwUID = ReadUID(i);
if (g_bIsSF700[i] == true) {
- printf("\nDevice %d (SF7%05X):\tdetecting chip\n", i + 1, dwUID);
- } else if ((dwUID / 600000) > 0) {
+ printf("\nDevice %d (SF7%05d):\tdetecting chip\n", i + 1, dwUID);
+ } else if (g_bIsSF600PG2[i] == true) {
+ printf("\nDevice %d (S6B%05d):\tdetecting chip\n", i + 1, dwUID);
+ } else if ((g_bIsSF600[i] == true) && (dwUID / 600000) > 0) {
+ printf("\nDevice %d (SF%06d):\tdetecting chip\n", i + 1, dwUID);
+ } else if ((dwUID / 100000) > 0) {
printf("\nDevice %d (SF%06d):\tdetecting chip\n", i + 1, dwUID);
} else {
printf("\nDevice %d (DP%06d):\tdetecting chip\n", i + 1, dwUID);
@@ -1283,7 +1291,7 @@ void SetSPIClock(int Index)
void SetVcc(int Index)
{
// sscanf(g_parameter_vcc,"%d",&g_Vcc);
- if (!(g_Vcc <= 3800 && g_Vcc >= 1800 && ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true))))
+ if (!(g_Vcc <= 3800 && g_Vcc >= 1800 && ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true) || (g_bIsSF600PG2[Index] == true))))
g_Vcc = (0x10 | (g_Vcc & 0x03));
}
@@ -1335,14 +1343,18 @@ bool CheckProgrammerInfo(void)
for (int i = 0; i < dev_cnt; i++) {
int dwUID = ReadUID(i);
if (g_bIsSF700[i] == true)
- printf("%d,\tSF7%05X\n", i + 1, dwUID);
- else if ((dwUID / 600000) == 0)
- printf("%d,\tDP%06d\n", i + 1, dwUID);
- else
+ printf("%d,\tSF7%05d\n", i + 1, dwUID);
+ else if (g_bIsSF600PG2[i] == true)
+ printf("%d,\tS6B%05d\n", i + 1, dwUID);
+ else if ((g_bIsSF600[i] == true) && (dwUID / 600000) > 0)
printf("%d,\tSF%06d\n", i + 1, dwUID);
-
- uiFPGAVer = GetFPGAVersion(i);
- GetFirmwareVer(i);
+ else if ((dwUID / 100000) > 0)
+ printf("%d,\tSF%06d\n", i + 1, dwUID);
+ else
+ printf("%d,\tDP%06d\n", i + 1, dwUID);
+
+ uiFPGAVer = GetFPGAVersion(i);
+ GetFirmwareVer(i);
if (g_bIsSF600[i]) {
if (CheckSDCard(i))
printf(" Programmer type : SF600Plus\n");
@@ -1356,6 +1368,11 @@ bool CheckProgrammerInfo(void)
printf(" Firmware version : %s\n", g_FW_ver);
printf(" FPGA version : 0x%04x\n", uiFPGAVer);
printf(" Hardware version : %s\n", g_HW_ver);
+ } else if (g_bIsSF600PG2[i]) {
+ printf(" Programmer type : SF600Plus-G2\n");
+ printf(" Firmware version : %s\n", g_FW_ver);
+ printf(" FPGA version : 0x%04x\n", uiFPGAVer);
+ printf(" Hardware version : %s\n", g_HW_ver);
} else //SF100
{
printf(" Programmer type : SF100\n");
@@ -1367,8 +1384,12 @@ bool CheckProgrammerInfo(void)
} else {
int dwUID = ReadUID(g_uiDevNum - 1);
if (g_bIsSF700[g_uiDevNum - 1] == true) {
- printf("\nDevice %d (SF7%05X):\n", g_uiDevNum, dwUID);
- } else if ((dwUID / 600000) > 0) {
+ printf("\nDevice %d (SF7%05d):\n", g_uiDevNum, dwUID);
+ } else if (g_bIsSF600PG2[g_uiDevNum - 1] == true) {
+ printf("\nDevice %d (S6B%05d):\n", g_uiDevNum, dwUID);
+ } else if ((g_bIsSF600[g_uiDevNum - 1] == true) && (dwUID / 600000) > 0) {
+ printf("\nDevice %d (SF%06d):\n", g_uiDevNum, dwUID);
+ } else if ((dwUID / 100000) > 0) {
printf("\nDevice %d (SF%06d):\n", g_uiDevNum, dwUID);
} else {
printf("\nDevice %d (DP%06d):\n", g_uiDevNum, dwUID);
@@ -1388,6 +1409,11 @@ bool CheckProgrammerInfo(void)
printf(" Firmware version : %s\n", g_FW_ver);
printf(" FPGA version : 0x%x\n", uiFPGAVer);
printf(" Hardware version : %s\n", g_HW_ver);
+ } else if (g_bIsSF600PG2[g_uiDevNum - 1]) {
+ printf(" Programmer type : SF600Plus-G2\n");
+ printf(" Firmware version : %s\n", g_FW_ver);
+ printf(" FPGA version : 0x%x\n", uiFPGAVer);
+ printf(" Hardware version : %s\n", g_HW_ver);
} else //SF100
{
printf(" Programmer type : SF100\n");
@@ -1451,11 +1477,15 @@ void ListSFSerialID(void)
for (unsigned int i = 0; i < dev_cnt; i++) {
dwUID = ReadUID(i);
if (g_bIsSF700[i] == true)
- printf("%d,\tSF7%05X\n", i + 1, dwUID);
- else if ((dwUID / 600000) == 0)
- printf("%d,\tDP%06d\n", i + 1, dwUID);
- else
+ printf("%d,\tSF7%05d\n", i + 1, dwUID);
+ else if (g_bIsSF600PG2[i] == true)
+ printf("%d,\tS6B%05d\n", i + 1, dwUID);
+ else if ((g_bIsSF600[i] == true) && (dwUID / 600000) > 0)
+ printf("%d,\tSF%06d\n", i + 1, dwUID);
+ else if ((dwUID / 100000) > 0)
printf("%d,\tSF%06d\n", i + 1, dwUID);
+ else
+ printf("%d,\tDP%06d\n", i + 1, dwUID);
}
} else {
if (g_uiDeviceID > dev_cnt)
@@ -1463,11 +1493,15 @@ void ListSFSerialID(void)
else {
dwUID = ReadUID(g_uiDeviceID - 1);
if (g_bIsSF700[g_uiDeviceID - 1] == true)
- printf("%d,\tSF7%05X\n", g_uiDeviceID, dwUID);
- else if ((dwUID / 600000) == 0)
- printf("%d,\tDP%06d\n", g_uiDeviceID, dwUID);
- else
+ printf("%d,\tSF7%05d\n", g_uiDeviceID, dwUID);
+ else if (g_bIsSF600PG2[g_uiDeviceID - 1] == true)
+ printf("%d,\tS6B%05d\n", g_uiDeviceID, dwUID);
+ else if ((g_bIsSF600[g_uiDeviceID - 1] == true) && (dwUID / 600000) > 0)
+ printf("%d,\tSF%06d\n", g_uiDeviceID, dwUID);
+ else if ((dwUID / 100000) > 0)
printf("%d,\tSF%06d\n", g_uiDeviceID, dwUID);
+ else
+ printf("%d,\tDP%06d\n", g_uiDeviceID, dwUID);
}
}
}
@@ -1799,20 +1833,28 @@ bool CalChecksum(void)
int dwUID = ReadUID(i);
if (g_uiAddr == 0 && g_uiLen == 0) {
if (g_bIsSF700[i] == true)
- printf("\nDevice %d (SF7%05X):", i + 1, dwUID);
- else if ((dwUID / 600000) == 0)
- printf("\nDevice %d (DP%06d):", i + 1, dwUID);
- else
+ printf("\nDevice %d (SF7%05d):", i + 1, dwUID);
+ else if (g_bIsSF600PG2[i] == true)
+ printf("\nDevice %d (S6B%05d):", i + 1, dwUID);
+ else if ((g_bIsSF600[i] == true) && (dwUID / 600000) > 0)
+ printf("\nDevice %d (SF%06d):", i + 1, dwUID);
+ else if ((dwUID / 100000) > 0)
printf("\nDevice %d (SF%06d):", i + 1, dwUID);
+ else
+ printf("\nDevice %d (DP%06d):", i + 1, dwUID);
printf("Checksum of the whole chip(address starting from: 0x%X, 0x%zX bytes in total): %08X\n", g_uiAddr, Chip_Info.ChipSizeInByte, CRC32(pBufferForLastReadData[i], Chip_Info.ChipSizeInByte));
} else {
if (g_bIsSF700[i] == true)
- printf("\nDevice %d (SF7%05X):", i + 1, ReadUID(i));
- else if ((dwUID / 600000) == 0)
- printf("\nDevice %d (DP%06d):", i + 1, ReadUID(i));
- else
+ printf("\nDevice %d (SF7%05d):", i + 1, ReadUID(i));
+ else if (g_bIsSF600PG2[i] == true)
+ printf("\nDevice %d (S6B%05d):", i + 1, ReadUID(i));
+ else if ((g_bIsSF600[i] == true) && (dwUID / 600000) > 0)
printf("\nDevice %d (SF%06d):", i + 1, ReadUID(i));
+ else if ((dwUID / 100000) > 0)
+ printf("\nDevice %d (SF%06d):", i + 1, ReadUID(i));
+ else
+ printf("\nDevice %d (DP%06d):", i + 1, ReadUID(i));
printf("Checksum(address starting from: 0x%X, 0x%zX bytes in total): %08X\n", g_uiAddr, g_uiLen, CRC32(pBufferForLastReadData[i], min(g_uiLen, Chip_Info.ChipSizeInByte)));
}
@@ -1821,20 +1863,28 @@ bool CalChecksum(void)
int dwUID = ReadUID(g_uiDevNum - 1);
if (g_uiAddr == 0 && g_uiLen == 0) {
if (g_bIsSF700[g_uiDevNum - 1] == true)
- printf("\nDevice %d (SF7%05X):", g_uiDevNum, ReadUID(g_uiDevNum - 1));
- else if ((dwUID / 600000) == 0)
- printf("\nDevice %d (DP%06d):", g_uiDevNum, ReadUID(g_uiDevNum - 1));
- else
+ printf("\nDevice %d (SF7%05d):", g_uiDevNum, ReadUID(g_uiDevNum - 1));
+ else if (g_bIsSF600PG2[g_uiDevNum - 1] == true)
+ printf("\nDevice %d (S6B%05d):", g_uiDevNum, ReadUID(g_uiDevNum - 1));
+ else if ((g_bIsSF600[g_uiDevNum - 1] == true) && (dwUID / 600000) > 0)
printf("\nDevice %d (SF%06d):", g_uiDevNum, ReadUID(g_uiDevNum - 1));
+ else if ((dwUID / 100000) > 0)
+ printf("\nDevice %d (SF%06d):", g_uiDevNum, ReadUID(g_uiDevNum - 1));
+ else
+ printf("\nDevice %d (DP%06d):", g_uiDevNum, ReadUID(g_uiDevNum - 1));
printf("Checksum of the whole chip(address starting from: 0x%X, 0x%zX bytes in total): %08X\n", g_uiAddr, Chip_Info.ChipSizeInByte, CRC32(pBufferForLastReadData[g_uiDevNum - 1], Chip_Info.ChipSizeInByte));
} else {
if (g_bIsSF700[g_uiDevNum - 1] == true)
- printf("\nDevice %d (SF7%05X):", g_uiDevNum, ReadUID(g_uiDevNum - 1));
- else if ((dwUID / 600000) == 0)
- printf("\nDevice %d (DP%06d):", g_uiDevNum, ReadUID(g_uiDevNum - 1));
- else
+ printf("\nDevice %d (SF7%05d):", g_uiDevNum, ReadUID(g_uiDevNum - 1));
+ else if (g_bIsSF600PG2[g_uiDevNum - 1] == true)
+ printf("\nDevice %d (S6B%05d):", g_uiDevNum, ReadUID(g_uiDevNum - 1));
+ else if ((g_bIsSF600[g_uiDevNum - 1] == true) && (dwUID / 600000) > 0)
printf("\nDevice %d (SF%06d):", g_uiDevNum, ReadUID(g_uiDevNum - 1));
+ else if ((dwUID / 100000) > 0)
+ printf("\nDevice %d (SF%06d):", g_uiDevNum, ReadUID(g_uiDevNum - 1));
+ else
+ printf("\nDevice %d (DP%06d):", g_uiDevNum, ReadUID(g_uiDevNum - 1));
printf("Checksum(address starting from: 0x%X, 0x%zX bytes in total): %08X\n", g_uiAddr, g_uiLen, CRC32(pBufferForLastReadData[g_uiDevNum - 1], min(g_uiLen, Chip_Info.ChipSizeInByte)));
}
} else
@@ -1878,22 +1928,30 @@ bool Wait(const char* strOK, const char* strFail)
for (int i = 0; i < dev_cnt; i++) {
int dwUID = ReadUID(i);
if (g_bIsSF700[i] == true)
- printf("\nDevice %d (SF7%05X):", i + 1, dwUID);
- else if ((dwUID / 600000) == 0)
- printf("\nDevice %d (DP%06d):", i + 1, dwUID);
- else
+ printf("\nDevice %d (SF7%05d):", i + 1, dwUID);
+ else if (g_bIsSF600PG2[i] == true)
+ printf("\nDevice %d (S6B%05d):", i + 1, dwUID);
+ else if ((g_bIsSF600[i] == true) && (dwUID / 600000) > 0)
+ printf("\nDevice %d (SF%06d):", i + 1, dwUID);
+ else if ((dwUID / 100000) > 0)
printf("\nDevice %d (SF%06d):", i + 1, dwUID);
+ else
+ printf("\nDevice %d (DP%06d):", i + 1, dwUID);
printf("%s\n", g_is_operation_successful[i] ? strOK : strFail);
g_bStatus = g_is_operation_successful[i];
}
} else if (g_uiDevNum <= dev_cnt) {
int dwUID = ReadUID(g_uiDevNum - 1);
if (g_bIsSF700[g_uiDevNum - 1] == true)
- printf("\nDevice %d (SF7%05X):", g_uiDevNum, dwUID);
- else if ((dwUID / 600000) == 0)
- printf("\nDevice %d (DP%06d):", g_uiDevNum, dwUID);
- else
+ printf("\nDevice %d (SF7%05d):", g_uiDevNum, dwUID);
+ else if (g_bIsSF600PG2[g_uiDevNum - 1] == true)
+ printf("\nDevice %d (S6B%05d):", g_uiDevNum, dwUID);
+ else if ((g_bIsSF600[g_uiDevNum - 1] == true) && (dwUID / 600000) > 0)
printf("\nDevice %d (SF%06d):", g_uiDevNum, dwUID);
+ else if ((dwUID / 100000) > 0)
+ printf("\nDevice %d (SF%06d):", g_uiDevNum, dwUID);
+ else
+ printf("\nDevice %d (DP%06d):", g_uiDevNum, dwUID);
printf("%s\n", g_is_operation_successful[g_uiDevNum - 1] ? strOK : strFail);
g_bStatus = g_is_operation_successful[g_uiDevNum - 1];
diff --git a/parse.c b/parse.c
index 0f1ea46..db21d9e 100755
--- a/parse.c
+++ b/parse.c
@@ -51,231 +51,13 @@ long fsize(FILE* fp)
fseek(fp, prev, SEEK_SET); // go back to where we were
return sz;
}
-#if 0
-int Dedi_Search_Chip_Db(long RDIDCommand,
- long UniqueID,
- CHIP_INFO* Chip_Info,
- int search_all)
-{
-
-printf("evy- Dedi_Search_Chip_Db(RDIDCommand=0x%lx,UniqueID=0x%lx,search_all=%d)\n",RDIDCommand,UniqueID,search_all);
- FILE* fp; /*Declare file pointer variable*/
- int found_flag = 0;
- char file_line_buf[linebufsize], *tok, *file_buf, test[testbufsize];
- char* pch;
- long sz = 0;
- if ((fp = openChipInfoDb()) == NULL)
- return 1;
- sz = fsize(fp);
- file_buf = (char*)malloc(sz);
-
- memset(file_buf, '\0', sz);
- /*Read into the buffer contents within thr file stream*/
-
- while (fgets(file_line_buf, linebufsize, fp) != NULL) {
- pch = strstr(file_line_buf, "TypeName");
- if (pch != NULL) {
- if (found_flag == 1)
- break;
- memset(test, '\0', testbufsize);
- strcpy(test, pch + strlen("TypeName"));
- tok = strtok(test, "\"= \t");
- Chip_Info->TypeName[0] = '\0';
- Chip_Info->Class[0] = '\0';
- Chip_Info->UniqueID = 0;
- Chip_Info->Description[0] = '\0';
- Chip_Info->Manufacturer[0] = '\0';
- Chip_Info->ManufactureUrl[0] = '\0';
- Chip_Info->ProgramIOMethod[0] = '\0';
- Chip_Info->Voltage[0] = '\0';
- Chip_Info->Clock[0] = '\0';
- Chip_Info->ManufactureID = 0;
- Chip_Info->JedecDeviceID = 0;
- Chip_Info->AlternativeID = 0;
- Chip_Info->ChipSizeInByte = 0;
- Chip_Info->SectorSizeInByte = 0;
- Chip_Info->BlockSizeInByte = 0;
- Chip_Info->PageSizeInByte = 0;
- Chip_Info->AddrWidth = 0;
- Chip_Info->IDNumber = 0;
- Chip_Info->RDIDCommand = 0;
- Chip_Info->MaxErasableSegmentInByte = 0;
- Chip_Info->DualID = false;
- Chip_Info->VppSupport = 0;
- Chip_Info->MXIC_WPmode = false;
- Chip_Info->Timeout = 0;
- // end of struct init
- strcpy(Chip_Info->TypeName, tok);
- continue;
- }
-
- pch = strstr(file_line_buf, "Class");
- if (pch != NULL) {
- memset(test, '\0', testbufsize);
- strcpy(test, pch + strlen("Class"));
- tok = strtok(test, "\"= \t");
- // printf("evy- Class = %s\n",tok);
- strcpy(Chip_Info->Class, tok);
- continue;
- }
- pch = strstr(file_line_buf, "UniqueID");
- if (pch != NULL) {
- memset(test, '\0', testbufsize);
- strcpy(test, pch + strlen("UniqueID"));
- tok = strtok(test, "\"= \t");
- //printf("evy- UniqueID = 0x%lx\n",strtol(tok,NULL,16));
- Chip_Info->UniqueID = strtol(tok, NULL, 16);
- if ((UniqueID == Chip_Info->UniqueID))
- found_flag = 1;
- continue;
- }
- pch = strstr(file_line_buf, "Manufacturer");
- if (pch != NULL) {
- memset(test, '\0', testbufsize);
- strcpy(test, pch + strlen("Manufacturer"));
- tok = strtok(test, "\"= \t");
- //printf("evy- Manufacturer = %s\n",tok);
- strcpy(Chip_Info->Manufacturer, tok);
- continue;
- }
- pch = strstr(file_line_buf, "Voltage");
- if (pch != NULL) {
- memset(test, '\0', testbufsize);
- strcpy(test, pch + strlen("Voltage"));
- tok = strtok(test, "\"= \t");
- //printf("evy- Voltage = %s\n",tok);
- if (strcmp(tok, "3.3V") == 0)
- Chip_Info->VoltageInMv = 3300;
- else if (strcmp(tok, "2.5V") == 0)
- Chip_Info->VoltageInMv = 2500;
- else if (strcmp(tok, "1.8V") == 0)
- Chip_Info->VoltageInMv = 1800;
- else
- Chip_Info->VoltageInMv = 3300;
- continue;
- }
- pch = strstr(file_line_buf, "JedecDeviceID");
- if (pch != NULL) {
- memset(test, '\0', testbufsize);
- strcpy(test, pch + strlen("JedecDeviceID"));
- tok = strtok(test, "\"= \t");
- //printf("evy- JedecDeviceID = 0x%lx\n",strtol(tok,NULL,16));
- Chip_Info->JedecDeviceID = strtol(tok, NULL, 16);
- if ((UniqueID == Chip_Info->JedecDeviceID)) {
- found_flag = 1;
- }
- continue;
- }
- pch = strstr(file_line_buf, "ChipSizeInKByte");
- if (pch != NULL) {
- memset(test, '\0', testbufsize);
- strcpy(test, pch + strlen("ChipSizeInKByte"));
- tok = strtok(test, "\"= \t");
- //printf("evy- ChipSizeInKByte = %ld\n",strtol(tok,NULL,10));
- Chip_Info->ChipSizeInByte = strtol(tok, NULL, 10) * 1024;
- continue;
- }
- pch = strstr(file_line_buf, "SectorSizeInByte");
- if (pch != NULL) {
- memset(test, '\0', testbufsize);
- strcpy(test, pch + strlen("SectorSizeInByte"));
- tok = strtok(test, "\"= \t");
- //printf("evy- SectorSizeInByte = %ld\n",strtol(tok,NULL,10));
- Chip_Info->SectorSizeInByte = strtol(tok, NULL, 10);
- continue;
- }
- pch = strstr(file_line_buf, "BlockSizeInByte");
- if (pch != NULL) {
- memset(test, '\0', testbufsize);
- strcpy(test, pch + strlen("BlockSizeInByte"));
- tok = strtok(test, "\"= \t");
- //printf("evy- BlockSizeInByte = %ld\n",strtol(tok,NULL,10));
- Chip_Info->BlockSizeInByte = strtol(tok, NULL, 10);
- continue;
- }
- pch = strstr(file_line_buf, "PageSizeInByte");
- if (pch != NULL) {
- memset(test, '\0', testbufsize);
- strcpy(test, pch + strlen("PageSizeInByte"));
- tok = strtok(test, "\"= \t");
- //printf("evy- PageSizeInByte = %ld\n",strtol(tok,NULL,10));
- Chip_Info->PageSizeInByte = strtol(tok, NULL, 10);
- continue;
- }
- pch = strstr(file_line_buf, "AddrWidth");
- if (pch != NULL) {
- memset(test, '\0', testbufsize);
- strcpy(test, pch + strlen("AddrWidth"));
- tok = strtok(test, "\"= \t");
- //printf("evy- AddrWidth = %ld\n",strtol(tok,NULL,10));
- Chip_Info->AddrWidth = strtol(tok, NULL, 10);
- continue;
- }
- pch = strstr(file_line_buf, "IDNumber");
- if (pch != NULL) {
- memset(test, '\0', testbufsize);
- strcpy(test, pch + strlen("IDNumber"));
- tok = strtok(test, "\"= \t");
- //printf("evy- IDNumber = %ld\n",strtol(tok,NULL,10));
- Chip_Info->IDNumber = strtol(tok, NULL, 10);
- continue;
- }
- pch = strstr(file_line_buf, "VppSupport");
- if (pch != NULL) {
- memset(test, '\0', testbufsize);
- strcpy(test, pch + strlen("VppSupport"));
- tok = strtok(test, "\"= \t");
- //printf("evy- IDNumber = %ld\n",strtol(tok,NULL,10));
- Chip_Info->VppSupport = strtol(tok, NULL, 10);
- continue;
- }
- pch = strstr(file_line_buf, "RDIDCommand");
- if (pch != NULL) {
- memset(test, '\0', testbufsize);
- strcpy(test, pch + strlen("RDIDCommand"));
- tok = strtok(test, "\"= \t");
- //printf("evy- RDIDCommand = %ld\n",strtol(tok,NULL,10));
- Chip_Info->RDIDCommand = strtol(tok, NULL, 16);
- continue;
- }
- pch = strstr(file_line_buf, "Timeout");
- if (pch != NULL) {
- memset(test, '\0', testbufsize);
- strcpy(test, pch + strlen("Timeout"));
- tok = strtok(test, "\"= \t");
- //printf("evy- Timeout = %ld\n",strtol(tok,NULL,10));
- Chip_Info->Timeout = strtol(tok, NULL, 16);
- continue;
- }
- pch = strstr(file_line_buf, "MXIC_WPmode");
- if (pch != NULL) {
- memset(test, '\0', testbufsize);
- strcpy(test, pch + strlen("MXIC_WPmode"));
- tok = strtok(test, "\"= \t");
- if (strstr(tok, "true") != NULL)
- Chip_Info->MXIC_WPmode = true;
- else
- Chip_Info->MXIC_WPmode = false;
- // starting checking input data
- }
-
- } /*Continue until EOF is encoutered*/
- fclose(fp); /*Close file*/
- Chip_Info->MaxErasableSegmentInByte = max(Chip_Info->SectorSizeInByte, Chip_Info->BlockSizeInByte);
- free(file_buf);
- return found_flag; /*Executed without errors*/
-} /*End main*/
-
-#else
-
int Dedi_Search_Chip_Db(char* chTypeName, long RDIDCommand,
long UniqueID,
CHIP_INFO* Chip_Info,
int search_all)
{
- //printf("evy Dedi_Search_Chip_Db_FirstDetect(RDIDCommand=0x%lx,UniqueID=0x%lx,search_all=%d)\n",RDIDCommand,UniqueID,search_all);
-
+
FILE* fp; /*Declare file pointer variable*/
int found_flag = 0;
char file_line_buf[linebufsize], *tok, *file_buf, test[testbufsize];
@@ -515,9 +297,7 @@ int Dedi_Search_Chip_Db(char* chTypeName, long RDIDCommand,
free(file_buf);
return found_flag; /*Executed without errors*/
} /*End main*/
-
-#endif
-
+
int Dedi_Search_Chip_Db_ByTypeName(char* TypeName, CHIP_INFO* Chip_Info)
{
//printf("Dedi_Search_Chip_Db_ByTypeName = %s\n",TypeName);
diff --git a/project.c b/project.c
index bedef65..993e955 100755
--- a/project.c
+++ b/project.c
@@ -1492,6 +1492,16 @@ void SetProgReadCommand(int Index)
mcode_Read = BULK_FAST_READ;
mcode_Program = PP_32BYTE;
mcode_SegmentErase = 0xD8;
+ } else if (strstr(Chip_Info.Class, SUPPORT_WINBOND_W25Pxx) != NULL) {
+
+ mcode_RDSR = RDSR;
+ mcode_WRSR = WRSR;
+ mcode_ChipErase = CHIP_ERASE;
+ mcode_Program = PAGE_PROGRAM;
+ mcode_Read = BULK_FAST_READ;
+ mcode_SegmentErase = SE;
+ mcode_ProgramCode_4Adr = 0x02;
+ mcode_ReadCode = 0x0B;
} else if (strstr(Chip_Info.Class, SUPPORT_WINBOND_W25Pxx_Large) != NULL) {
mcode_RDSR = RDSR;
mcode_WRSR = WRSR;
diff --git a/usbdriver.c b/usbdriver.c
index abf0c80..47204ba 100755
--- a/usbdriver.c
+++ b/usbdriver.c
@@ -65,7 +65,7 @@ void usb_db_init(void)
}
void AssignSF600orSF700var(int Index)
-{
+{
if (Index == -1)
Index = DevIndex;
@@ -147,14 +147,14 @@ static int FindUSBDevice(void)
}
int OutCtrlRequest(CNTRPIPE_RQ* rq, unsigned char* buf, unsigned long buf_size, int Index)
-{
+{
int requesttype;
int ret = 0;
if (Index == -1)
Index = DevIndex;
- if ((rq->Function != URB_FUNCTION_VENDOR_ENDPOINT) && ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true)))
+ if ((rq->Function != URB_FUNCTION_VENDOR_ENDPOINT) && ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true) || (g_bIsSF600PG2[Index] == true)))
return true;
requesttype = 0x00;
@@ -175,19 +175,7 @@ int OutCtrlRequest(CNTRPIPE_RQ* rq, unsigned char* buf, unsigned long buf_size,
} else {
printf("no device");
}
- if (ret != buf_size) {
-#if 0
- printf("Control Pipe output error!\n");
- printf("rq->Direction=%X\n",rq->Direction);
- printf("rq->Function=%X\n",rq->Function);
- printf("rq->Request=%X\n",rq->Request);
- printf("rq->Value=%X\n",rq->Value);
- printf("rq->Index=%X\n",rq->Index);
- printf("rq->Length=%X\n",rq->Length);
- printf("buf_size=%X\n",buf_size);
- printf("buf[0]=%X\n",buf[0]);
- printf("g_bIsSF600=%d\n",g_bIsSF600);
-#endif
+ if (ret != buf_size) {
printf("Error: %s\n", libusb_strerror(ret));
return -1;
}
@@ -199,7 +187,7 @@ int InCtrlRequest(CNTRPIPE_RQ* rq, unsigned char* buf, unsigned long buf_size, i
unsigned int requesttype;
unsigned int ret = 0;
- if ((rq->Function != URB_FUNCTION_VENDOR_ENDPOINT) && ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true)))
+ if ((rq->Function != URB_FUNCTION_VENDOR_ENDPOINT) && ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true)|| (g_bIsSF600PG2[Index] == true)))
return true;
if (Index == -1)
@@ -256,7 +244,10 @@ int InCtrlRequest(CNTRPIPE_RQ* rq, unsigned char* buf, unsigned long buf_size, i
// part of USB driver , open usb pipes for data transfor
// should be called after usb successfully opens pipes.
int dediprog_start_appli(int Index)
-{
+{
+ if((g_bIsSF600[Index] != false) || (g_bIsSF700[Index] != false) || (g_bIsSF600PG2[Index] != false))
+ return 1;
+
CNTRPIPE_RQ rq;
int ret;
unsigned char vInstruction;
@@ -323,10 +314,9 @@ int BulkPipeRead(unsigned char* pBuff, unsigned int timeOut, int Index)
Index = DevIndex;
unsigned long cnRead = 512;
- ret = libusb_bulk_transfer(dediprog_handle[Index], 2 | LIBUSB_ENDPOINT_IN, pBuff, cnRead, &actual_length, DEFAULT_TIMEOUT);
+ ret = libusb_bulk_transfer(dediprog_handle[Index], 2 | LIBUSB_ENDPOINT_IN, pBuff, cnRead, &actual_length, DEFAULT_TIMEOUT);
if (ret != 0) //libusb_bulk_transfer return false
- return 0;
-
+ return 0;
return cnRead;
}
@@ -344,7 +334,7 @@ int BulkPipeWrite(unsigned char* pBuff, unsigned int size, unsigned int timeOut,
if (Index == -1)
Index = DevIndex;
- ret = libusb_bulk_transfer(dediprog_handle[Index], ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true)) ? 0x01 : 0x02, pData, nWrite, &actual_length, DEFAULT_TIMEOUT);
+ ret = libusb_bulk_transfer(dediprog_handle[Index], ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true)|| (g_bIsSF600PG2[Index] == true)) ? 0x01 : 0x02, pData, nWrite, &actual_length, DEFAULT_TIMEOUT);
nWrite = ret;
return nWrite;
}
@@ -517,8 +507,8 @@ int usb_driver_init(void)
return 0;
}
+ AssignSF600orSF700var(i);
dediprog_start_appli(i);
- AssignSF600orSF700var(i);
result = (dediprog_handle[i] != NULL);
}
} else {
@@ -545,9 +535,9 @@ int usb_driver_init(void)
return 0;
}
- dediprog_start_appli(g_uiDevNum - 1);
AssignSF600orSF700var(g_uiDevNum - 1);
+ dediprog_start_appli(g_uiDevNum - 1);
result = (dediprog_handle[g_uiDevNum - 1] != NULL);
}
@@ -565,41 +555,7 @@ int usb_driver_release(void)
}
return 0;
}
-
-#if 0 //Simon: unit test code
-int usb_driver_test(void)
-{
- struct usb_bus *bus;
- struct usb_device *dev;
-
- unsigned int vid = 0x0483;
- unsigned int pid = 0xdada;
- int device_cnt = 0;
- int ret, i;
- char string[256];
- unsigned char readaddr[3];
- unsigned char writeaddr[3];
- usb_dev_handle *udev;
- usb_dev_init();
-
- device_cnt = FindUSBDevice();
-// printf("\ndevice_cnt =%d\n", device_cnt);
- dediprog_handle = usb_open(&usb_device_entry[device_cnt-1].usb_device_handler);
- ret = libusb_set_configuration(dediprog_handle, 1);
- ret = libusb_claim_interface(dediprog_handle, 0);
- dediprog_start_appli(0);
-
- dediprog_set_spi_voltage(3300);
-
- dediprog_get_chipid(0);
-
- dediprog_set_leds(PASS_ON | BUSY_ON | ERROR_ON);
- usb_close (dediprog_handle);
-
- return 0;
-}
-#endif
-
+
bool Is_usbworking(int Index)
{
usleep(1000); // unknow reson