Skip to content

Commit

Permalink
dpcmd.c
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Nov 15, 2022
1 parent 859f335 commit bcc000f
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 74 deletions.
21 changes: 21 additions & 0 deletions ChipInfoDb.dedicfg
Original file line number Diff line number Diff line change
Expand Up @@ -23958,6 +23958,27 @@ BlockSizeInByte="65536"
AddrWidth="4"
RDIDCommand="0x9F"/>

<Chip TypeName="GD25LB256E"
ICType="SPI_NOR"
Description="1.8V Uniform Sector"
Manufacturer="GigaDevice"
ManufactureUrl="www.gigadevice.com"
Voltage="1.8V"
Clock="133MHz"
Timeout="300"
ProgramIOMethod="SPQD_RSWQW"
ManufactureID="0xC8"
JedecDeviceID="0xC86719"
UniqueID="0xC86719"
DeviceID="0xC818"
IDNumber="3"
Class="M25Pxx_Large"
ChipSizeInKByte="32768"
PageSizeInByte="256"
SectorSizeInByte="4096"
BlockSizeInByte="65536"
AddrWidth="4"
RDIDCommand="0x9F"/>

<Chip TypeName="KH25U25639F"
ICType="SPI_NOR"
Expand Down
1 change: 1 addition & 0 deletions Macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ typedef struct ChipInfo {
#ifdef SUPPORT_ST
#define SUPPORT_ST_M25PExx "M25PExx"
#define SUPPORT_ST_M25Pxx "M25Pxx"
#define SUPPORT_ST_M25Pxx_Large "M25Pxx_Large"
#define SUPPORT_ST_M45PExx "M45PExx"
#define SUPPORT_NUMONYX_Alverstone "Alverstone"
#define SUPPORT_NUMONYX_N25Qxxx_Large "N25Qxxx_Large"
Expand Down
24 changes: 11 additions & 13 deletions SerialFlash.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ extern int m_boEnWriteQuadIO;
extern CHIP_INFO Chip_Info;
extern volatile bool g_bIsSF600[16];
extern volatile bool g_bIsSF700[16];
extern volatile bool g_bIsSF600PG2[16];
extern bool Is_NewUSBCommand(int Index);

unsigned char mcode_WRSR = 0x01;
Expand Down Expand Up @@ -1778,20 +1779,19 @@ int SerialFlash_rangeProgram(struct CAddressRange* AddrRange, unsigned char* vDa
if (strstr(Chip_Info.Class, SUPPORT_ATMEL_45DBxxxB) != NULL || strstr(Chip_Info.Class, SUPPORT_ATMEL_45DBxxxD) != NULL)
return AT45rangeProgram(AddrRange, vData, mcode_Program, mcode_ProgramCode_4Adr, Index);
else if (strstr(Chip_Info.Class, SUPPORT_SPANSION_S25FLxx_Large) != NULL) {
if ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true))
if ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true) || (g_bIsSF600PG2[Index] == true))
return SerialFlash_bulkPipeProgram(AddrRange, vData, PP_4ADR_256BYTE, mcode_ProgramCode_4Adr, Index);
else
return SerialFlash_bulkPipeProgram(AddrRange, vData, PP_4ADDR_256BYTE_12, mcode_ProgramCode_4Adr, Index);
} else if (strstr(Chip_Info.Class, SUPPORT_SPANSION_S25FLxxL_Large) != NULL) {

return SerialFlash_bulkPipeProgram(AddrRange, vData, PP_4ADR_256BYTE, mcode_ProgramCode_4Adr_12, Index);
} else if (strstr(Chip_Info.Class, SUPPORT_SPANSION_S70FSxx_Large) != NULL) {
if ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true)) {
if ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true)|| (g_bIsSF600PG2[Index] == true)) {
return SerialFlash_bulkPipeProgram(AddrRange, vData, PP_4ADDR_256BYTE_S70FS01GS, mcode_ProgramCode_4Adr_12, Index);
} else
return false;
} else {

} else {
return SerialFlash_bulkPipeProgram(AddrRange, vData, mcode_Program, mcode_ProgramCode_4Adr, Index);
}
}
Expand All @@ -1800,14 +1800,14 @@ int SerialFlash_rangeRead(struct CAddressRange* AddrRange, unsigned char* vData,
{
//printf("SerialFlash_rangeRead");
if (strstr(Chip_Info.Class, SUPPORT_SPANSION_S25FLxx_Large) != NULL) {
if ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true))
if ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true)|| (g_bIsSF600PG2[Index] == true))
return SerialFlash_bulkPipeRead(AddrRange, vData, BULK_4BYTE_FAST_READ, mcode_ReadCode, Index);
else
return SerialFlash_bulkPipeRead(AddrRange, vData, BULK_4BYTE_FAST_READ_MICRON, mcode_ReadCode, Index);
} else if (strstr(Chip_Info.Class, SUPPORT_SPANSION_S25FLxxL_Large) != NULL) {
return SerialFlash_bulkPipeRead(AddrRange, vData, BULK_4BYTE_FAST_READ_MICRON, mcode_ReadCode_0C, Index);
} else if (strstr(Chip_Info.Class, SUPPORT_SPANSION_S70FSxx_Large) != NULL) {
if ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true))
if ((g_bIsSF600[Index] == true) || (g_bIsSF700[Index] == true)|| (g_bIsSF600PG2[Index] == true))
return SerialFlash_bulkPipeRead(AddrRange, vData, BULK_4BYTE_FAST_READ, mcode_ReadCode_0C, Index);
else
return false;
Expand Down Expand Up @@ -2106,7 +2106,7 @@ int SerialFlash_bulkPipeProgram(struct CAddressRange* AddrRange, unsigned char*
if (SerialFlash_EnableQuadIO(true, m_boEnWriteQuadIO, Index) == SerialFlash_FALSE)
return false;

// printf("WriteMode=%d, WriteCom=%02X\n", modeWrite,WriteCom);
printf("WriteMode=%d, WriteCom=%02X\n", modeWrite,WriteCom);
itr_begin = vData;
switch (modeWrite) {
//transfer how many data each time
Expand All @@ -2122,9 +2122,7 @@ int SerialFlash_bulkPipeProgram(struct CAddressRange* AddrRange, unsigned char*
break;
}

if ((AddrRange->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;
Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
65 changes: 21 additions & 44 deletions board.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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<unsigned char> 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;

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion dpcmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
26 changes: 24 additions & 2 deletions project.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions project.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit bcc000f

Please sign in to comment.