Skip to content

Commit

Permalink
dpcmd.c
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Apr 20, 2021
1 parent b99e9db commit 13be619
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 34 deletions.
24 changes: 23 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="3.00"
Ver="4.00"
CreateDate="2007-September-25"
Locale="2052">
<Portofolio
Expand Down Expand Up @@ -15773,6 +15773,28 @@ RDIDCommand="0x9F"
Timeout="480"
JedecDeviceID="0x9D601A"
ManufactureID="0x9D"

DeviceID="0x19"
ChipSizeInKByte="65536"
SectorSizeInByte="4096"
PageSizeInByte="256"
BlockSizeInByte="65536"
AddrWidth="4"

IDNumber="3"
RDIDCommand="0x9F"/>
<Chip TypeName="IS25LP512MG"
ICType="SPI_NOR"
Class="W25Qxx_Large"
UniqueID="0x9D6020"
Description="512 Mbit Serial Flash Memory"
Manufacturer="ISSI"
ManufactureUrl="www.issi.com"
Voltage="3.3V"
Clock="133MHz"
Timeout="480"
JedecDeviceID="0x9D6020"
ManufactureID="0x9D"
DeviceID="0x19"
ChipSizeInKByte="65536"
SectorSizeInByte="4096"
Expand Down
1 change: 1 addition & 0 deletions Macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ typedef struct ChipInfo {
#define SUPPORT_WINBOND_W25Bxx "W25Bxx"
#define SUPPORT_WINBOND_W25Pxx "W25Pxx"
#define SUPPORT_WINBOND_W25Pxx_Large "W25Pxx_Large"
#define SUPPORT_WINBOND_W25Qxx_Large "W25Qxx_Large"
#define SUPPORT_WINBOND_W25Xxx "W25Xxx"
#endif

Expand Down
18 changes: 12 additions & 6 deletions SerialFlash.c
Original file line number Diff line number Diff line change
Expand Up @@ -1694,7 +1694,7 @@ int S70FSxxx_Large_Enable4ByteAddrMode(int Enable4Byte, int Index)
//Simon: unused ???
int SerialFlash_Enable4ByteAddrMode(int bEnable, int Index)
{
if (strstr(Chip_Info.Class, SUPPORT_EON_EN25QHxx_Large) != NULL || strstr(Chip_Info.Class, SUPPORT_MACRONIX_MX25Lxxx_Large) != NULL || strstr(Chip_Info.Class, SUPPORT_WINBOND_W25Pxx_Large) != NULL)
if (strstr(Chip_Info.Class, SUPPORT_EON_EN25QHxx_Large) != NULL || strstr(Chip_Info.Class, SUPPORT_MACRONIX_MX25Lxxx_Large) != NULL || strstr(Chip_Info.Class, SUPPORT_WINBOND_W25Pxx_Large) != NULL || strstr(Chip_Info.Class, SUPPORT_WINBOND_W25Qxx_Large) != NULL)
return CEN25QHxx_LargeEnable4ByteAddrMode(bEnable, Index);
else if (strstr(Chip_Info.Class, SUPPORT_SPANSION_S70FSxx_Large) != NULL)
return S70FSxxx_Large_Enable4ByteAddrMode(bEnable, Index);
Expand Down Expand Up @@ -1762,17 +1762,23 @@ 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) {
else if (strstr(Chip_Info.Class, SUPPORT_SPANSION_S25FLxx_Large) != NULL)
{
if ((g_bIsSF600[Index] == true)||(g_bIsSF700[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_S70FSxx_Large) != NULL) {
if ((g_bIsSF600[Index] == true)||(g_bIsSF700[Index] == true)) {
}
else if (strstr(Chip_Info.Class, SUPPORT_SPANSION_S70FSxx_Large) != NULL)
{
if ((g_bIsSF600[Index] == true)||(g_bIsSF700[Index] == true))
{
return SerialFlash_bulkPipeProgram(AddrRange, vData, PP_4ADDR_256BYTE_S70FS01GS, mcode_ProgramCode_4Adr_S70FSxxx, Index);
} else
}
else
return false;
} else
}
else
return SerialFlash_bulkPipeProgram(AddrRange, vData, mcode_Program, mcode_ProgramCode_4Adr, Index);
}

Expand Down
14 changes: 6 additions & 8 deletions dpcmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ int main(int argc, char* argv[])
unsigned long r;
char *env;

printf("\nDpCmd Linux 1.11.4.%02d Engine Version:\nLast Built on May 25 2018\n\n", GetConfigVer()); // 1. new feature.bug.configS
printf("\nDpCmd Linux 1.11.5.%02d Engine Version:\nLast Built on May 25 2018\n\n", GetConfigVer()); // 1. new feature.bug.configS

g_ucOperation = 0;
GetLogPath(g_LogPath);
Expand Down Expand Up @@ -666,7 +666,7 @@ int main(int argc, char* argv[])
sscanf(optarg, "%d", &g_ucTarget);
break;
case 'c':
g_parameter_vcc = optarg;
g_parameter_vcc = optarg;
sscanf(optarg, "%d", &g_Vcc);
break;
case 'P':
Expand Down Expand Up @@ -1012,8 +1012,7 @@ void cli_classic_usage(bool IsShowExample)
// " note: the sequence is assigned by OS during USB plug-in.\n"
" - 1: Prompt the device ID of programmer connected to USB1.\n"
// " - n: Prompt the device ID of programmer connected to USBn.\n"
" --load-file arg -Load a bin/hex/s19 file and compare with the memory conten.\n"
" -work with --verify only"
" --loadFile-with-verify arg -Load a bin/hex/s19 file and verify with the memory conten.\n"
"\n"
"Miscellaneous options:\n"
" -t [ --timeout ] arg (=300) Timeout value in seconds\n"
Expand Down Expand Up @@ -1206,11 +1205,10 @@ void CloseProject(void)
}

bool DetectChip(void)
{
//printf("DetectChip(void)\n");
{
int dev_cnt = get_usb_dev_cnt();
Chip_Info = GetFirstDetectionMatch(strTypeName,0);
if (g_uiDevNum == 0) {
if (g_uiDevNum == 0) {
for (int i = 0; i < dev_cnt; i++) {
if (!Is_usbworking(i)) {
printf("%s", msg_err_communication);
Expand All @@ -1226,7 +1224,7 @@ bool DetectChip(void)

RawInstructions(i);
}
} else if (g_uiDevNum <= dev_cnt) {
} else if (g_uiDevNum <= dev_cnt) {
if (!Is_usbworking(g_uiDevNum - 1)) {
printf("%s", msg_err_communication);
return false;
Expand Down
6 changes: 3 additions & 3 deletions parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ int Dedi_Search_Chip_Db(char* chTypeName,long RDIDCommand,
CHIP_INFO* Chip_Info,
int search_all)
{
//printf("Dedi_Search_Chip_Db_FirstDetect(RDIDCommand=0x%lx,UniqueID=0x%lx,search_all=%d)\n",RDIDCommand,UniqueID,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;
Expand Down Expand Up @@ -373,8 +373,7 @@ int Dedi_Search_Chip_Db(char* chTypeName,long RDIDCommand,
if (pch != NULL) {
memset(test, '\0', testbufsize);
strcpy(test, pch + strlen("Voltage"));
tok = strtok(test, "\"= \t");
//printf("Voltage = %s\n",tok);
tok = strtok(test, "\"= \t");
if (strcmp(tok, "3.3V") == 0)
Chip_Info_temp.VoltageInMv = 3300;
else if (strcmp(tok, "2.5V") == 0)
Expand Down Expand Up @@ -514,6 +513,7 @@ int Dedi_Search_Chip_Db(char* chTypeName,long RDIDCommand,

int Dedi_Search_Chip_Db_ByTypeName(char* TypeName, CHIP_INFO* Chip_Info)
{
//printf("Dedi_Search_Chip_Db_ByTypeName = %s\n",TypeName);
FILE* fp; /*Declare file pointer variable*/
int found_flag = 0, i;
char file_line_buf[linebufsize], *tok, *file_buf, test[testbufsize];
Expand Down
49 changes: 34 additions & 15 deletions project.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void TurnOFFVpp(int Index)
}

void TurnONVcc(int Index)
{
{
dediprog_set_spi_voltage(g_Vcc, Index);
}

Expand Down Expand Up @@ -430,7 +430,7 @@ bool threadBlankCheck(int Index)
}

bool threadEraseWholeChip(int Index)
{
{
bool result = false;

// power::CAutoVccPower autopowerVcc(m_usb, m_context.power.vcc,Index);
Expand Down Expand Up @@ -1254,30 +1254,38 @@ printf("GetFirstDetectionMatch(%x)\n",Index);
}
#else
CHIP_INFO GetFirstDetectionMatch(char* TypeName,int Index)
{

//printf("GetFirstDetectionMatch_temp(%x)\n",Index);
{
CHIP_INFO binfo;
binfo.UniqueID = 0;
unsigned int g_Vcc_temp = 0;
//char TypeName[1024];

// memset(TypeName, '\0', 1024);

int Found = 0;
int i = 0;
int Loop = 3;
if (strcmp(g_parameter_vcc, "NO") != 0)
Loop = 1;
if (strcmp(g_parameter_vcc, "NO") != 0) //g_parameter_vcc!=NO
Loop = 1;

if(strlen(TypeName)!=0)
g_Vcc_temp = g_Vcc;

for (i = 0; i < Loop; i++) {
if (Found == 1)
{
if(strlen(TypeName)!=0)
g_Vcc = g_Vcc_temp;
break;
if (Loop == 1)
}
if (Loop == 1)
g_Vcc = vcc3_5V;
else
g_Vcc = vcc1_8V - i;
g_Vcc = vcc1_8V - i;

TurnONVcc(Index);
if (Is_usbworking(Index)) {
if (Is_usbworking(Index))
{
if ((g_bIsSF600[Index] == true)||(g_bIsSF700[Index] == true)) {
int startmode;

Expand Down Expand Up @@ -1314,6 +1322,7 @@ CHIP_INFO GetFirstDetectionMatch(char* TypeName,int Index)
binfo.UniqueID = 0;
binfo.TypeName[0] = '\0';
}

return binfo;//*TypeName;
}
#endif
Expand Down Expand Up @@ -1487,6 +1496,15 @@ void SetProgReadCommand(int Index)
mcode_SegmentErase = SE;
mcode_ProgramCode_4Adr = 0x02;
mcode_ReadCode = 0x0C;
} else if (strstr(Chip_Info.Class, SUPPORT_WINBOND_W25Qxx_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;
mcode_ProgramCode_4Adr = 0x02;
mcode_ReadCode = 0x0B;
} else if (strstr(Chip_Info.Class, SUPPORT_ATMEL_45DBxxxB) != NULL) {
mcode_RDSR = 0xD7;
mcode_WRSR = 0;
Expand All @@ -1511,13 +1529,13 @@ void SetProgReadCommand(int Index)
}

bool ProjectInitWithID(CHIP_INFO chipinfo, int Index) // by designated ID
{
{
DownloadAddrRange.start = 0;
DownloadAddrRange.end = Chip_Info.ChipSizeInByte;
InitLED(Index);
// SetTargetFlash(g_StartupMode,Index); //for SF600 Freescale issue
SetProgReadCommand(Index);
if (strcmp(g_parameter_vcc, "NO") == 0) {
if (strcmp(g_parameter_vcc, "NO") == 0) {
switch (Chip_Info.VoltageInMv) {
case 1800:
g_Vcc = vcc1_8V;
Expand All @@ -1530,15 +1548,16 @@ bool ProjectInitWithID(CHIP_INFO chipinfo, int Index) // by designated ID
break;
}
}

return true;
}

bool ProjectInit(int Index) // by designated ID
{
//printf("bool ProjectInit(%d)\n",Index);
{
Chip_Info = GetFirstDetectionMatch(strTypeName,Index);
if (Chip_Info.UniqueID == 0)
{
return false;
}
return ProjectInitWithID(Chip_Info, Index);
}
2 changes: 1 addition & 1 deletion usbdriver.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ int BulkPipeWrite(unsigned char* pBuff, unsigned int size, unsigned int timeOut,
}

int dediprog_set_spi_voltage(int v, int Index)
{
{
int ret = 0;
// int voltage_selector;
CNTRPIPE_RQ rq;
Expand Down

0 comments on commit 13be619

Please sign in to comment.