From bcc000f939e278f3d0bd7eca20eb32905690262b Mon Sep 17 00:00:00 2001 From: root Date: Tue, 15 Nov 2022 17:31:24 +0800 Subject: [PATCH] dpcmd.c --- ChipInfoDb.dedicfg | 21 +++++++++++++++ Macro.h | 1 + SerialFlash.c | 24 ++++++++--------- board.c | 65 +++++++++++++++------------------------------- dpcmd.c | 3 ++- project.c | 26 +++++++++++++++++-- project.h | 1 + usbdriver.c | 34 ++++++++++++++---------- usbdriver.h | 2 +- 9 files changed, 103 insertions(+), 74 deletions(-) diff --git a/ChipInfoDb.dedicfg b/ChipInfoDb.dedicfg index 26886d6..303399a 100755 --- a/ChipInfoDb.dedicfg +++ b/ChipInfoDb.dedicfg @@ -23958,6 +23958,27 @@ BlockSizeInByte="65536" AddrWidth="4" RDIDCommand="0x9F"/> + end / 0x1000000) > (AddrRange->start / 0x1000000)) //(AddrRange.end>0x1000000 && AddrRange.start<0x1000000) - //||(AddrRange.end>0x2000000 && AddrRange.start<0x2000000) - //|| + if ((AddrRange->end / 0x1000000) > (AddrRange->start / 0x1000000)) { struct CAddressRange down_range; struct CAddressRange range_temp; @@ -2191,7 +2189,7 @@ int SerialFlash_bulkPipeRead(struct CAddressRange* AddrRange, unsigned char* vDa int ret = 0; if (!SerialFlash_StartofOperation(Index)) return false; - if (!(strstr(Chip_Info.Class, SUPPORT_NUMONYX_N25Qxxx_Large_2Die) != NULL && strstr(Chip_Info.Class, SUPPORT_NUMONYX_N25Qxxx_Large_4Die) != NULL && ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true)))) + if (!(strstr(Chip_Info.Class, SUPPORT_NUMONYX_N25Qxxx_Large_2Die) != NULL && strstr(Chip_Info.Class, SUPPORT_NUMONYX_N25Qxxx_Large_4Die) != NULL && ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true)|| (g_bIsSF600PG2[Index] == true)))) SerialFlash_Enable4ByteAddrMode(true, Index); if (SerialFlash_EnableQuadIO(true, m_boEnReadQuadIO, Index) == SerialFlash_FALSE) @@ -2214,7 +2212,7 @@ int SerialFlash_bulkPipeRead(struct CAddressRange* AddrRange, unsigned char* vDa loop = (range_temp.end - range_temp.start) / 0x1000000; for (j = 0; j < loop; j++) { - if (((g_bIsSF600[Index] == false) && (g_bIsSF700[Index] == false)) && (strstr(Chip_Info.Class, SUPPORT_NUMONYX_N25Qxxx_Large_2Die) != NULL || strstr(Chip_Info.Class, SUPPORT_NUMONYX_N25Qxxx_Large_4Die) != NULL)) // for sf100 + if (((g_bIsSF600[Index] == false) && (g_bIsSF700[Index] == false)&& (g_bIsSF600PG2[Index] == false)) && (strstr(Chip_Info.Class, SUPPORT_NUMONYX_N25Qxxx_Large_2Die) != NULL || strstr(Chip_Info.Class, SUPPORT_NUMONYX_N25Qxxx_Large_4Die) != NULL)) // for sf100 { unsigned char re = 0; int numOfRetry = 5; @@ -2256,7 +2254,7 @@ int SerialFlash_bulkPipeRead(struct CAddressRange* AddrRange, unsigned char* vDa } } else { unsigned char EAR = (AddrRange->start * 0x1000000) >> 24; - if (((g_bIsSF600[Index] == false) && (g_bIsSF700[Index] == false)) && (strstr(Chip_Info.Class, SUPPORT_NUMONYX_N25Qxxx_Large_2Die) != NULL || strstr(Chip_Info.Class, SUPPORT_NUMONYX_N25Qxxx_Large_4Die) != NULL)) { + if (((g_bIsSF600[Index] == false) && (g_bIsSF700[Index] == false) && (g_bIsSF600PG2[Index] == false)) && (strstr(Chip_Info.Class, SUPPORT_NUMONYX_N25Qxxx_Large_2Die) != NULL || strstr(Chip_Info.Class, SUPPORT_NUMONYX_N25Qxxx_Large_4Die) != NULL)) { unsigned char re = 0; int numOfRetry = 5; do { diff --git a/board.c b/board.c index 920f651..9e4aabe 100755 --- a/board.c +++ b/board.c @@ -9,6 +9,7 @@ volatile bool g_bIsSF600 = false; 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]; @@ -55,59 +56,33 @@ void QueryBoard(int Index) } CNTRPIPE_RQ rq; - unsigned char vBuffer[16]; + unsigned char vBuffer[32]; rq.Function = URB_FUNCTION_VENDOR_ENDPOINT; rq.Direction = VENDOR_DIRECTION_IN; rq.Request = PROGINFO_REQUEST; rq.Value = RFU; rq.Index = 0x00; - rq.Length = (unsigned long)16; - memset(vBuffer, '\0', 16); + rq.Length = (unsigned long)32; + memset(vBuffer, '\0', 32); - if (InCtrlRequest(&rq, vBuffer, 16, Index) == SerialFlash_FALSE) { + if (InCtrlRequest(&rq, vBuffer, 32, Index) == SerialFlash_FALSE) { printf("send fail\n"); return; } - memcpy(g_board_type, &vBuffer[0], 8); - //memcpy(g_FW_ver,&vBuffer[8],8); - //printf("g_FW_ver=%s\n",g_FW_ver); -// printf("g_board_type=%s\n",g_board_type); -// if(strstr(g_board_type,"SF600") != NULL) -// g_bIsSF600=true; -// else -// g_bIsSF600=false; -#if 0 - m_info.fpga_version=GetFPGAVersion(Index); - vector vBuffer1(3) ; - - rq.Function = URB_FUNCTION_VENDOR_OTHER ; - rq.Direction = VENDOR_DIRECTION_IN ; - rq.Request = 0x7; - rq.Value = 0 ; - rq.Index = 0xEF00 ; - rq.Length = 3; - - - if(! m_usb.InCtrlRequest(rq, vBuffer1,Index)) - { - return ; - } - - if(m_info.board_type==L"SF600") - { - ReadOnBoardFlash(false,Index); - m_info.dwUID=(DWORD)m_vUID[0]<<16 | (DWORD)m_vUID[1]<<8 | m_vUID[2]; - } - else - m_info.dwUID=(DWORD)vBuffer1[0]<<16 | (DWORD)vBuffer1[1]<<8 | vBuffer1[2]; -#endif + memcpy(g_board_type, &vBuffer[0], 8); + + unsigned char ucData; + if((strstr(g_board_type, "SF600PG2") != NULL)) + { + printf(" evy UpdateSF600Flash\n"); + } } unsigned int GetFPGAVersion(int Index) { - if ((strstr(g_board_type, "SF600") == NULL) && (strstr(g_board_type, "SF700") == NULL)) + if ((strstr(g_board_type, "SF600PG2") == NULL)&& (strstr(g_board_type, "SF600") == NULL) && (strstr(g_board_type, "SF700") == NULL)) return -1; CNTRPIPE_RQ rq; @@ -348,7 +323,7 @@ unsigned int ReadUID(int Index) unsigned int dwUID = 0; unsigned char vUID[16]; - if ((g_bIsSF600 == true) || (g_bIsSF700 == true)) { + if ((g_bIsSF600 == true) || (g_bIsSF700 == true) || (g_bIsSF600PG2 == true)) { if (ReadOnBoardFlash(vUID, false, Index) == false) return false; if (g_bIsSF600 == true) @@ -449,7 +424,7 @@ unsigned char ReadManufacturerID(int Index) if (!Is_usbworking(Index)) return false; - if ((g_bIsSF600 == true) || (g_bIsSF700 == true)) { + if ((g_bIsSF600 == true) || (g_bIsSF700 == true)|| (g_bIsSF600PG2 == true)) { unsigned char vUID[16]; if (ReadOnBoardFlash(vUID, false, Index) == false) return false; @@ -609,7 +584,7 @@ bool WriteUID(unsigned int dwUID, int Index) if (!Is_usbworking(Index)) return false; - if ((g_bIsSF600 == true) || (g_bIsSF700 == true)) + if ((g_bIsSF600 == true) || (g_bIsSF700 == true)|| (g_bIsSF600PG2 == true)) return true; CNTRPIPE_RQ rq; @@ -649,7 +624,7 @@ bool WriteManufacturerID(unsigned char ManuID, int Index) if (!Is_usbworking(Index)) return false; - if ((g_bIsSF600 == true) || (g_bIsSF700 == true)) + if ((g_bIsSF600 == true) || (g_bIsSF700 == true)|| (g_bIsSF600PG2 == true)) return true; CNTRPIPE_RQ rq; @@ -778,6 +753,8 @@ bool GetFirmwareVer(int Index) memcpy(g_board_type, &vBuffer[0], 8); memcpy(g_FW_ver, &vBuffer[10], 7); + 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) @@ -802,7 +779,7 @@ bool EncrypFirmware(unsigned char* vBuffer, unsigned int Size, int Index) bool UpdateSF600Flash(const char* sFilePath, int Index) { - printf(" evy UpdateSF600Flash\n"); + // printf(" evy UpdateSF600Flash\n"); CNTRPIPE_RQ rq; unsigned char* pBuffer; int pagenum = 0; @@ -961,7 +938,7 @@ bool UpdateFirmware(const char* sFolder, int Index) unsigned int UID = 0; unsigned char ManID = 0; // read status - if ((g_bIsSF600 == true) || (g_bIsSF700 == true)) + if ((g_bIsSF600 == true) || (g_bIsSF700 == true)|| (g_bIsSF600PG2 == true)) return UpdateSF600Firmware(sFolder, Index); dediprog_set_spi_voltage(g_Vcc, Index); diff --git a/dpcmd.c b/dpcmd.c index 6934ee4..f81701a 100755 --- a/dpcmd.c +++ b/dpcmd.c @@ -22,6 +22,7 @@ extern unsigned int g_uiFileChecksum; extern unsigned long g_ulFileSize; extern volatile bool g_bIsSF600[16]; extern volatile bool g_bIsSF700[16]; +extern volatile bool g_bIsSF600PG2[16]; extern unsigned char g_BatchIndex; unsigned int g_Vcc = vcc3_5V; @@ -499,7 +500,7 @@ int main(int argc, char* argv[]) unsigned long r; char* env; - printf("\nDpCmd Linux 1.12.10.%02d Engine Version:\nLast Built on October 27 2021\n\n", GetConfigVer()); // 1. new feature.bug.configS + printf("\nDpCmd Linux 1.12.11.%02d Engine Version:\nLast Built on October 27 2021\n\n", GetConfigVer()); // 1. new feature.bug.configS g_ucOperation = 0; GetLogPath(g_LogPath); diff --git a/project.c b/project.c index f6efe30..49696a2 100755 --- a/project.c +++ b/project.c @@ -27,6 +27,7 @@ extern int m_boEnReadQuadIO; extern int m_boEnWriteQuadIO; extern volatile bool g_bIsSF600[16]; extern volatile bool g_bIsSF700[16]; +extern volatile bool g_bIsSF600PG2[16]; extern char g_board_type[8]; extern int g_firmversion; extern char* g_parameter_vcc; @@ -924,6 +925,8 @@ void threadRun(void* Type) if (g_uiAddr == 0 && g_uiLen == 0) { if (g_bIsSF700[Index] == true) printf("\nDevice %d (SF7%05X):", Index + 1, dwUID); + else if (g_bIsSF600PG2[Index] == true) + printf("\nDevice %d (SPG%05X):", Index + 1, dwUID); else if ((dwUID / 600000) == 0) printf("\nDevice %d (DP%06d):", Index + 1, dwUID); else @@ -1042,7 +1045,7 @@ void SetIOMode(bool isProg, int Index) m_boEnReadQuadIO = 0; m_boEnWriteQuadIO = 0; - if ((g_bIsSF600[Index] == false) && (g_bIsSF700[Index] == false)) + if ((g_bIsSF600[Index] == false) && (g_bIsSF700[Index] == false) && (g_bIsSF600PG2[Index] == false)) return; SetIOModeToSF600(IOValue, Index); @@ -1190,6 +1193,13 @@ bool is_SF700(int Index) } return false; } +bool is_SF600PG2(int Index) +{ + if (strstr(g_board_type, "SF600PG2") != NULL) { + return true; + } + return false; +} #if 0 CHIP_INFO GetFirstDetectionMatch(int Index) { @@ -1282,7 +1292,7 @@ CHIP_INFO GetFirstDetectionMatch(char* TypeName, int Index) TurnONVcc(Index); if (Is_usbworking(Index)) { - if ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true)) { + if ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true)|| (g_bIsSF600PG2[Index] == true)) { int startmode; if (g_StartupMode == STARTUP_APPLI_SF_2) @@ -1492,6 +1502,18 @@ void SetProgReadCommand(int Index) mcode_SegmentErase = SE; mcode_ProgramCode_4Adr = 0x02; mcode_ReadCode = 0x0C; + } else if (strstr(Chip_Info.Class, SUPPORT_ST_M25Pxx_Large) != NULL) { + mcode_RDSR = RDSR; + mcode_WRSR = WRSR; + mcode_ChipErase = CHIP_ERASE; + mcode_Program = PP_4ADR_256BYTE; + mcode_Read = BULK_4BYTE_FAST_READ; + mcode_SegmentErase = SE; + if (strstr(Chip_Info.TypeName, "GD25LB256E") != NULL) + mcode_ProgramCode_4Adr = 0x12; + else + mcode_ProgramCode_4Adr = 0x02; + mcode_ReadCode = 0x0C; } else if (strstr(Chip_Info.Class, SUPPORT_WINBOND_W25Qxx_Large) != NULL) { mcode_RDSR = RDSR; mcode_WRSR = WRSR; diff --git a/project.h b/project.h index 0935644..f9cd004 100755 --- a/project.h +++ b/project.h @@ -47,6 +47,7 @@ bool is_SF600nBoardVersionGreaterThan_6_9_0(int Index); bool is_SF100nBoardVersionGreaterThan_5_2_0(int Index); bool is_SF600nBoardVersionGreaterThan_7_0_1n6_7_0(int Index); bool is_SF700(int Index); +bool is_SF600PG2(int Index); int GetFileFormatFromExt(const char* csPath); #if 0 CHIP_INFO GetFirstDetectionMatch(int Index); diff --git a/usbdriver.c b/usbdriver.c index 9e5e033..31039ac 100755 --- a/usbdriver.c +++ b/usbdriver.c @@ -1,13 +1,14 @@ #include "usbdriver.h" #include "FlashCommand.h" #include "project.h" -#include +#include #include unsigned int m_nbDeviceDetected = 0; unsigned char DevIndex = 0; extern volatile bool g_bIsSF600[16]; extern volatile bool g_bIsSF700[16]; +extern volatile bool g_bIsSF600PG2[16]; extern int g_CurrentSeriase; extern char g_board_type[8]; extern int g_firmversion; @@ -72,20 +73,21 @@ void AssignSF600orSF700var(int Index) g_bIsSF600[Index] = false; g_bIsSF700[Index] = false; + g_bIsSF600PG2[Index] = false; CNTRPIPE_RQ rq; - unsigned char vBuffer[16]; + unsigned char vBuffer[32]; int fw[3]; - memset(vBuffer, '\0', 16); + memset(vBuffer, '\0', 32); rq.Function = URB_FUNCTION_VENDOR_ENDPOINT; rq.Direction = VENDOR_DIRECTION_IN; rq.Request = 0x08; rq.Value = 0; rq.Index = 0; - rq.Length = 16; + rq.Length = 32; - if (InCtrlRequest(&rq, vBuffer, 16, Index) == SerialFlash_FALSE) + if (InCtrlRequest(&rq, vBuffer, 32, Index) == SerialFlash_FALSE) return; memcpy(g_board_type, &vBuffer[0], 8); @@ -93,15 +95,21 @@ void AssignSF600orSF700var(int Index) 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, "SF600") != NULL) - g_bIsSF600[Index] = true; - else - g_bIsSF600[Index] = false; - if (strstr(g_board_type, "SF700") != NULL) - g_bIsSF700[Index] = true; - else - g_bIsSF700[Index] = false; + g_bIsSF700[Index] = true; + + else if (strstr(g_board_type, "SF600") != NULL) + { + if (strstr(g_board_type, "SF600PG2") != NULL) + { + g_bIsSF600PG2[Index] = true; + } + else + { + g_bIsSF600[Index] = true; + } + } + GetFPGAVersion(Index); } diff --git a/usbdriver.h b/usbdriver.h index 72e00ff..e5862d4 100755 --- a/usbdriver.h +++ b/usbdriver.h @@ -3,7 +3,7 @@ #ifndef DEDI_USB_DRIVER #define DEDI_USB_DRIVER -#include +#include #include #include #include