Merge pull request #12 from afaerber/error-msg

Prettify text output
This commit is contained in:
Eddie Cai 2017-05-16 09:06:49 +08:00 committed by GitHub
commit 2b17a44a65

173
main.cpp
View File

@ -66,39 +66,39 @@ void ProgressInfoProc(DWORD deviceLayer, ENUM_PROGRESS_PROMPT promptID, long lon
char szText[256];
switch (promptID) {
case TESTDEVICE_PROGRESS:
sprintf(szText, "Test Device Total(%lld),Current(%lld)", totalValue, currentValue);
sprintf(szText, "Test Device total %lld, current %lld", totalValue, currentValue);
strInfoText = szText;
break;
case LOWERFORMAT_PROGRESS:
sprintf(szText, "Lowerformat Device Total(%lld),Current(%lld)", totalValue, currentValue);
sprintf(szText, "Lowerformat Device total %lld, current %lld", totalValue, currentValue);
strInfoText = szText;
break;
case DOWNLOADIMAGE_PROGRESS:
sprintf(szText, "Download Image Total(%lldK),Current(%lldK)", totalValue/1024, currentValue/1024);
sprintf(szText, "Download Image total %lldK, current %lldK", totalValue/1024, currentValue/1024);
strInfoText = szText;
break;
case CHECKIMAGE_PROGRESS:
sprintf(szText, "Check Image Total(%lldK),Current(%lldK)", totalValue/1024, currentValue/1024);
sprintf(szText, "Check Image total %lldK, current %lldK", totalValue/1024, currentValue/1024);
strInfoText = szText;
break;
case TAGBADBLOCK_PROGRESS:
sprintf(szText, "Tag Bad Block Total(%lld),Current(%lld)", totalValue, currentValue);
sprintf(szText, "Tag Bad Block total %lld, current %lld", totalValue, currentValue);
strInfoText = szText;
break;
case TESTBLOCK_PROGRESS:
sprintf(szText, "Test Block Total(%lld),Current(%lld)", totalValue, currentValue);
sprintf(szText, "Test Block total %lld, current %lld", totalValue, currentValue);
strInfoText = szText;
break;
case ERASEFLASH_PROGRESS:
sprintf(szText, "Erase Flash Total(%lld),Current(%lld)", totalValue, currentValue);
sprintf(szText, "Erase Flash total %lld, current %lld", totalValue, currentValue);
strInfoText = szText;
break;
case ERASESYSTEM_PROGRESS:
sprintf(szText, "Erase System partition Total(%lld),Current(%lld)", totalValue, currentValue);
sprintf(szText, "Erase System partition total %lld, current %lld", totalValue, currentValue);
strInfoText = szText;
break;
case ERASEUSERDATA_PROGRESS:
sprintf(szText, "<LocationID=%x> Erase Userdata partition Total(%lld),Current(%lld)",deviceLayer,totalValue, currentValue);
sprintf(szText, "<LocationID=%x> Erase Userdata partition total %lld, current %lld", deviceLayer, totalValue, currentValue);
strInfoText = szText;
break;
}
@ -271,7 +271,7 @@ bool parse_config_file(const char *pConfigFile, CONFIG_ITEM_VECTOR &vecItem)
file = fopen(pConfigFile, "rb");
if( !file ){
if (g_pLogObject)
g_pLogObject->Record("parse_config_file failed,err=%d,can't open file: %s\r\n", errno, pConfigFile);
g_pLogObject->Record("%s failed, err=%d, can't open file: %s\r\n", __func__, errno, pConfigFile);
return false;
}
int iFileSize;
@ -289,7 +289,7 @@ bool parse_config_file(const char *pConfigFile, CONFIG_ITEM_VECTOR &vecItem)
iRead = fread(pConfigBuf, 1, iFileSize, file);
if (iRead != iFileSize){
if (g_pLogObject)
g_pLogObject->Record("parse_config_file failed,err=%d, read=%d, total=%d\r\n", errno, iRead, iFileSize);
g_pLogObject->Record("%s failed, err=%d, read=%d, total=%d\r\n", __func__, errno, iRead, iFileSize);
fclose(file);
delete []pConfigBuf;
return false;
@ -417,7 +417,7 @@ bool parse_parameter_file(char *pParamFile, PARAM_ITEM_VECTOR &vecItem)
file = fopen(pParamFile, "rb");
if( !file ) {
if (g_pLogObject)
g_pLogObject->Record("parse_parameter_file failed, err=%d, can't open file: %s\r\n", errno, pParamFile);
g_pLogObject->Record("%s failed, err=%d, can't open file: %s\r\n", __func__, errno, pParamFile);
return false;
}
int iFileSize;
@ -434,7 +434,7 @@ bool parse_parameter_file(char *pParamFile, PARAM_ITEM_VECTOR &vecItem)
iRead = fread(pParamBuf, 1, iFileSize, file);
if (iRead != iFileSize) {
if (g_pLogObject)
g_pLogObject->Record("parse_parameter_file failed, err=%d, read=%d, total=%d\r\n", errno,iRead,iFileSize);
g_pLogObject->Record("%s failed, err=%d, read=%d, total=%d\r\n", __func__, errno,iRead,iFileSize);
fclose(file);
delete []pParamBuf;
return false;
@ -608,7 +608,7 @@ bool check_device_type(STRUCT_RKDEVICE_DESC &dev, UINT uiSupportType)
else
{
ERROR_COLOR_ATTR;
printf("The Device did not support this operation!");
printf("The device does not support this operation!");
NORMAL_COLOR_ATTR;
printf("\r\n");
return false;
@ -633,7 +633,7 @@ bool write_gpt(STRUCT_RKDEVICE_DESC &dev, char *szParameter)
printf("\r\n");
return bSuccess;
}
printf("Write gpt...\r\n");
printf("Writing gpt...\r\n");
//1.get flash info
iRet = pComm->RKU_ReadFlashInfo(flash_info);
if (iRet != ERR_SUCCESS) {
@ -678,7 +678,7 @@ bool write_gpt(STRUCT_RKDEVICE_DESC &dev, char *szParameter)
bSuccess = true;
CURSOR_MOVEUP_LINE(1);
CURSOR_DEL_LINE;
printf("Write gpt ok.\r\n");
printf("Writing gpt succeeded.\r\n");
return bSuccess;
}
@ -916,14 +916,14 @@ static bool parseOpts(void) {
if (configPath == (char*)DEF_CONFIG_FILE) {
file = fopen(DEF_CONFIG_FILE, "w");
if (file) {
fprintf(stderr, "create defconfig\n");
fprintf(stderr, "creating defconfig\n");
printOpts(file);
}
}
goto end;
}
printf("start parse\n");
printf("Starting to parse...\n");
if (SCANF_EAT(file) != 0) {
goto end;
@ -1139,7 +1139,7 @@ end:
if (inFile)
fclose(inFile);
if (!ret)
printf("write entry(%s) failed\n", path);
printf("writing entry (%s) failed\n", path);
return ret;
}
@ -1148,21 +1148,21 @@ static bool saveEntry(FILE* outFile, char* path, rk_entry_type type,
uint32_t size;
rk_boot_entry entry;
printf("write:%s\n", path);
printf("writing: %s\n", path);
memset(&entry, 0, sizeof(rk_boot_entry));
getName(fixName ? fixName: path, entry.name);
entry.size = sizeof(rk_boot_entry);
entry.type = type;
entry.dataOffset = *offset;
if (!getFileSize(path, &size)) {
printf("save entry(%s) failed:\n\tcannot get file size.\n", path);
printf("Saving entry (%s) failed:\n\tCannot get file size.\n", path);
return false;
}
if (fix)
size = ((size - 1) / SMALL_PACKET + 1) * SMALL_PACKET;
uint32_t tmp = size % ENTRY_ALIGN;
size += tmp ? (ENTRY_ALIGN - tmp): 0;
printf("align size:%d\n", size);
printf("alignment size: %d\n", size);
entry.dataSize = size;
entry.dataDelay = delay;
*offset += size;
@ -1220,7 +1220,7 @@ static inline uint32_t getChipType(const char* chip) {
end:
printf("type: 0x%x\n", chipType);
if (chipType == RKNONE_DEVICE) {
printf("chip type not support!\n");
printf("chip type not supported!\n");
}
return chipType;
}
@ -1296,59 +1296,59 @@ bool mergeBoot(void) {
outFile = fopen(gOpts.outPath, "wb+");
if (!outFile) {
printf("open out file(%s) failed\n", gOpts.outPath);
printf("Opening output file (%s) failed\n", gOpts.outPath);
goto end;
}
getBoothdr(&hdr);
printf("write hdr\n");
printf("Writing header...\n");
fwrite(&hdr, 1, sizeof(rk_boot_header), outFile);
dataOffset = sizeof(rk_boot_header) +
(gOpts.code471Num + gOpts.code472Num + gOpts.loaderNum) *
sizeof(rk_boot_entry);
printf("write code 471 entry\n");
printf("Writing code 471 entry...\n");
for (i=0; i<gOpts.code471Num; i++) {
if (!saveEntry(outFile, (char*)gOpts.code471Path[i], ENTRY_471, gOpts.code471Sleep,
&dataOffset, NULL, false))
goto end;
}
printf("write code 472 entry\n");
printf("Writing code 472 entry...\n");
for (i=0; i<gOpts.code472Num; i++) {
if (!saveEntry(outFile, (char*)gOpts.code472Path[i], ENTRY_472, gOpts.code472Sleep,
&dataOffset, NULL, false))
goto end;
}
printf("write loader entry\n");
printf("Writing loader entry...\n");
for (i=0; i<gOpts.loaderNum; i++) {
if (!saveEntry(outFile, gOpts.loader[i].path, ENTRY_LOADER, 0,
&dataOffset, gOpts.loader[i].name, true))
goto end;
}
printf("write code 471\n");
printf("Writing code 471...\n");
for (i=0; i<gOpts.code471Num; i++) {
if (!writeFile(outFile, (char*)gOpts.code471Path[i], false))
goto end;
}
printf("write code 472\n");
printf("Writing code 472...\n");
for (i=0; i<gOpts.code472Num; i++) {
if (!writeFile(outFile, (char*)gOpts.code472Path[i], false))
goto end;
}
printf("write loader\n");
printf("Writing loader...\n");
for (i=0; i<gOpts.loaderNum; i++) {
if (!writeFile(outFile, gOpts.loader[i].path, true))
goto end;
}
fflush(outFile);
printf("write crc\n");
printf("Writing crc...\n");
crc = getCrc(gOpts.outPath);
if (!fwrite(&crc, sizeof(crc), 1, outFile))
goto end;
printf("done\n");
printf("Done.\n");
ret = true;
end:
if (outFile)
@ -1375,7 +1375,7 @@ static bool unpackEntry(rk_boot_entry* entry, const char* name,
FILE* outFile = fopen(name, "wb+");
if (!outFile)
goto end;
printf("unpack entry(%s)\n", name);
printf("unpacking entry (%s)\n", name);
fseek(inFile, entry->dataOffset, SEEK_SET);
size = entry->dataSize;
if (!fread(gBuf, size, 1, inFile))
@ -1412,14 +1412,14 @@ bool unpackBoot(char* path) {
rk_boot_header hdr;
if (!fread(&hdr, sizeof(rk_boot_header), 1, inFile)) {
fprintf(stderr, "read header failed\n");
fprintf(stderr, "reading header failed\n");
goto end;
}
printf("471 num:%d, 472 num:%d, loader num:%d\n", hdr.code471Num, hdr.code472Num, hdr.loaderNum);
entryNum = hdr.code471Num + hdr.code472Num + hdr.loaderNum;
entrys = (rk_boot_entry*) malloc(sizeof(rk_boot_entry) * entryNum);
if (!fread(entrys, sizeof(rk_boot_entry) * entryNum, 1, inFile)) {
fprintf(stderr, "read data failed\n");
fprintf(stderr, "reading data failed\n");
goto end;
}
@ -1431,7 +1431,7 @@ bool unpackBoot(char* path) {
entrys[i].type, name, entrys[i].dataOffset,
entrys[i].dataSize);
if (!unpackEntry(entrys + i, name, inFile)) {
fprintf(stderr, "unpack entry(%s) failed\n", name);
fprintf(stderr, "unpacking entry (%s) failed\n", name);
goto end;
}
}
@ -1455,7 +1455,7 @@ bool download_boot(STRUCT_RKDEVICE_DESC &dev, char *szLoader)
pImage = new CRKImage(szLoader, bRet);
if (!bRet){
ERROR_COLOR_ATTR;
printf("Open loader failed,exit download boot!");
printf("Opening loader failed, exiting download boot!");
NORMAL_COLOR_ATTR;
printf("\r\n");
return bSuccess;
@ -1490,17 +1490,17 @@ bool download_boot(STRUCT_RKDEVICE_DESC &dev, char *szLoader)
}
pDevice->SetObject(pImage, pComm, g_pLogObject);
printf("Download boot...\r\n");
printf("Downloading bootloader...\r\n");
iRet = pDevice->DownloadBoot();
CURSOR_MOVEUP_LINE(1);
CURSOR_DEL_LINE;
if (iRet == 0) {
bSuccess = true;
printf("Download boot ok.\r\n");
printf("Downloading bootloader succeeded.\r\n");
}
else
printf("Download boot failed!\r\n");
printf("Downloading bootloader failed!\r\n");
if (pImage)
delete pImage;
@ -1529,7 +1529,7 @@ bool upgrade_loader(STRUCT_RKDEVICE_DESC &dev, char *szLoader)
pImage = new CRKImage(szLoader, bRet);
if (!bRet){
ERROR_COLOR_ATTR;
printf("Open loader failed,exit upgrade loader!");
printf("Opening loader failed, exiting upgrade loader!");
NORMAL_COLOR_ATTR;
printf("\r\n");
goto Exit_UpgradeLoader;
@ -1545,18 +1545,18 @@ bool upgrade_loader(STRUCT_RKDEVICE_DESC &dev, char *szLoader)
goto Exit_UpgradeLoader;
}
printf("Upgrade loader...\r\n");
printf("Upgrading loader...\r\n");
index = pBoot->GetIndexByName(ENTRYLOADER, loaderCodeName);
if (index == -1) {
if (g_pLogObject) {
g_pLogObject->Record("ERROR:upgrade_loader-->Get LoaderCode Entry failed");
g_pLogObject->Record("ERROR: %s --> Get LoaderCode Entry failed", __func__);
}
goto Exit_UpgradeLoader;
}
bRet = pBoot->GetEntryProperty(ENTRYLOADER, index, dwLoaderSize, dwDelay);
if (!bRet) {
if (g_pLogObject) {
g_pLogObject->Record("ERROR:upgrade_loader-->Get LoaderCode Entry Size failed");
g_pLogObject->Record("ERROR: %s --> Get LoaderCode Entry Size failed", __func__);
}
goto Exit_UpgradeLoader;
}
@ -1565,7 +1565,7 @@ bool upgrade_loader(STRUCT_RKDEVICE_DESC &dev, char *szLoader)
memset(loaderCodeBuffer, 0, dwLoaderSize);
if (!pBoot->GetEntryData(ENTRYLOADER, index, loaderCodeBuffer)) {
if (g_pLogObject) {
g_pLogObject->Record("ERROR:upgrade_loader-->Get LoaderCode Data failed");
g_pLogObject->Record("ERROR: %s --> Get LoaderCode Data failed", __func__);
}
goto Exit_UpgradeLoader;
}
@ -1573,7 +1573,7 @@ bool upgrade_loader(STRUCT_RKDEVICE_DESC &dev, char *szLoader)
index = pBoot->GetIndexByName(ENTRYLOADER, loaderDataName);
if (index == -1) {
if (g_pLogObject) {
g_pLogObject->Record("ERROR:upgrade_loader-->Get LoaderData Entry failed");
g_pLogObject->Record("ERROR: %s --> Get LoaderData Entry failed", __func__);
}
delete []loaderCodeBuffer;
return -4;
@ -1582,7 +1582,7 @@ bool upgrade_loader(STRUCT_RKDEVICE_DESC &dev, char *szLoader)
bRet = pBoot->GetEntryProperty(ENTRYLOADER, index, dwLoaderDataSize, dwDelay);
if (!bRet) {
if (g_pLogObject) {
g_pLogObject->Record("ERROR:upgrade_loader-->Get LoaderData Entry Size failed");
g_pLogObject->Record("ERROR: %s --> Get LoaderData Entry Size failed", __func__);
}
goto Exit_UpgradeLoader;
}
@ -1591,7 +1591,7 @@ bool upgrade_loader(STRUCT_RKDEVICE_DESC &dev, char *szLoader)
memset(loaderDataBuffer, 0, dwLoaderDataSize);
if (!pBoot->GetEntryData(ENTRYLOADER,index,loaderDataBuffer)) {
if (g_pLogObject) {
g_pLogObject->Record("ERROR:upgrade_loader-->Get LoaderData Data failed");
g_pLogObject->Record("ERROR: %s --> Get LoaderData Data failed", __func__);
}
goto Exit_UpgradeLoader;
}
@ -1602,7 +1602,7 @@ bool upgrade_loader(STRUCT_RKDEVICE_DESC &dev, char *szLoader)
pIDBData = new BYTE[dwSectorNum*SECTOR_SIZE];
if (!pIDBData) {
ERROR_COLOR_ATTR;
printf("New memory failed!");
printf("Allocating memory failed!");
NORMAL_COLOR_ATTR;
printf("\r\n");
goto Exit_UpgradeLoader;
@ -1611,7 +1611,7 @@ bool upgrade_loader(STRUCT_RKDEVICE_DESC &dev, char *szLoader)
iRet = MakeIDBlockData(loaderDataBuffer, loaderCodeBuffer, pIDBData, usFlashDataSec, usFlashBootSec, dwLoaderDataSize, dwLoaderSize);
if (iRet != 0) {
ERROR_COLOR_ATTR;
printf("Make idblock failed!");
printf("Making idblock failed!");
NORMAL_COLOR_ATTR;
printf("\r\n");
goto Exit_UpgradeLoader;
@ -1622,9 +1622,9 @@ bool upgrade_loader(STRUCT_RKDEVICE_DESC &dev, char *szLoader)
if (iRet == ERR_SUCCESS) {
pComm->Reset_Usb_Device();
bSuccess = true;
printf("Upgrade loader ok.\r\n");
printf("Upgrading loader succeeded.\r\n");
} else {
printf("Upgrade loader failed!\r\n");
printf("Upgrading loader failed!\r\n");
goto Exit_UpgradeLoader;
}
}
@ -1683,7 +1683,7 @@ bool erase_flash(STRUCT_RKDEVICE_DESC &dev)
pDevice->SetObject(pImage, pComm, g_pLogObject);
pDevice->CallBackPointer = ProgressInfoProc;
printf("Start to erase flash...\r\n");
printf("Starting to erase flash...\r\n");
iRet = pDevice->EraseAllBlocks();
if (pDevice)
delete pDevice;
@ -1697,7 +1697,7 @@ bool erase_flash(STRUCT_RKDEVICE_DESC &dev)
CURSOR_MOVEUP_LINE(1);
CURSOR_DEL_LINE;
bSuccess = true;
printf("Erase flash ok.\r\n");
printf("Erasing flash complete.\r\n");
}
return bSuccess;
@ -1716,13 +1716,13 @@ bool test_device(STRUCT_RKDEVICE_DESC &dev)
if (iRet != ERR_SUCCESS) {
if (g_pLogObject)
g_pLogObject->Record("Error: RKU_TestDeviceReady failed, err=%d", iRet);
printf("Test Device Fail!\r\n");
printf("Test Device failed!\r\n");
} else {
bSuccess = true;
printf("Test Device OK.\r\n");
}
} else {
printf("Test Device quit,Creating comm object failed!\r\n");
printf("Test Device quit, creating comm object failed!\r\n");
}
if (pComm) {
delete pComm;
@ -1743,13 +1743,13 @@ bool reset_device(STRUCT_RKDEVICE_DESC &dev, BYTE subCode = RST_NONE_SUBCODE)
if (iRet != ERR_SUCCESS) {
if (g_pLogObject)
g_pLogObject->Record("Error: RKU_ResetDevice failed, err=%d", iRet);
printf("Reset Device Fail!\r\n");
printf("Reset Device failed!\r\n");
} else {
bSuccess = true;
printf("Reset Device OK.\r\n");
}
} else {
printf("Reset Device quit,Creating comm object failed!\r\n");
printf("Reset Device quit, creating comm object failed!\r\n");
}
if (pComm) {
delete pComm;
@ -1773,13 +1773,13 @@ bool read_flash_id(STRUCT_RKDEVICE_DESC &dev)
if (iRet != ERR_SUCCESS) {
if (g_pLogObject)
g_pLogObject->Record("Error: RKU_ReadFlashID failed, err=%d", iRet);
printf("Read flash ID Fail!\r\n");
printf("Reading flash ID failed!\r\n");
} else {
printf("Flash ID: %02X %02X %02X %02X %02X\r\n", flashID[0], flashID[1], flashID[2], flashID[3], flashID[4]);
bSuccess = true;
}
} else {
printf("Read flash ID quit,Creating comm object failed!\r\n");
printf("Read Flash ID quit, creating comm object failed!\r\n");
}
if (pComm) {
delete pComm;
@ -1803,7 +1803,7 @@ bool read_flash_info(STRUCT_RKDEVICE_DESC &dev)
if (iRet != ERR_SUCCESS) {
if (g_pLogObject)
g_pLogObject->Record("Error: RKU_ReadFlashInfo failed, err=%d", iRet);
printf("Read flash Info Fail!\r\n");
printf("Read Flash Info failed!\r\n");
} else {
printf("Flash Info:\r\n");
if (info.bManufCode <= 7) {
@ -1826,7 +1826,7 @@ bool read_flash_info(STRUCT_RKDEVICE_DESC &dev)
bSuccess = true;
}
}else {
printf("Read flash Info quit,Creating comm object failed!\r\n");
printf("Read Flash Info quit, creating comm object failed!\r\n");
}
if (pComm) {
delete pComm;
@ -1849,7 +1849,7 @@ bool read_chip_info(STRUCT_RKDEVICE_DESC &dev)
if (iRet != ERR_SUCCESS) {
if (g_pLogObject)
g_pLogObject->Record("Error: RKU_ReadChipInfo failed, err=%d", iRet);
printf("Read Chip Info Fail!\r\n");
printf("Read Chip Info failed!\r\n");
} else {
string strChipInfo;
g_pLogObject->PrintBuffer(strChipInfo, chipInfo, 16, 16);
@ -1857,7 +1857,7 @@ bool read_chip_info(STRUCT_RKDEVICE_DESC &dev)
bSuccess = true;
}
} else {
printf("Read Chip Info quit,Creating comm object failed!\r\n");
printf("Read Chip Info quit, creating comm object failed!\r\n");
}
if (pComm) {
delete pComm;
@ -1898,17 +1898,17 @@ bool read_lba(STRUCT_RKDEVICE_DESC &dev, UINT uiBegin, UINT uiLen, char *szFile)
fwrite(pBuf, 1, iRead * nSectorSize, file);
if (bFirst){
if (iTotalRead >= 1024)
printf("Read LBA from file (%d%%)\r\n", (iTotalRead / 1024) * 100 / ((uiLen + iTotalRead) / 1024));
printf("Read LBA to file (%d%%)\r\n", (iTotalRead / 1024) * 100 / ((uiLen + iTotalRead) / 1024));
else
printf("Read LBA from file %d%%)\r\n", iTotalRead * 100 / (uiLen + iTotalRead));
printf("Read LBA to file (%d%%)\r\n", iTotalRead * 100 / (uiLen + iTotalRead));
bFirst = false;
} else {
CURSOR_MOVEUP_LINE(1);
CURSOR_DEL_LINE;
if (iTotalRead >= 1024)
printf("Read LBA from file (%d%%)\r\n", (iTotalRead / 1024) * 100 / ((uiLen + iTotalRead) / 1024));
printf("Read LBA to file (%d%%)\r\n", (iTotalRead / 1024) * 100 / ((uiLen + iTotalRead) / 1024));
else
printf("Read LBA from file %d%%)\r\n", iTotalRead * 100 / (uiLen + iTotalRead));
printf("Read LBA to file (%d%%)\r\n", iTotalRead * 100 / (uiLen + iTotalRead));
}
}
else
@ -1923,7 +1923,7 @@ bool read_lba(STRUCT_RKDEVICE_DESC &dev, UINT uiBegin, UINT uiLen, char *szFile)
}
bSuccess = true;
} else {
printf("Read LBA quit,Creating comm object failed!\r\n");
printf("Read LBA quit, creating comm object failed!\r\n");
}
Exit_ReadLBA:
if (pComm) {
@ -1971,7 +1971,7 @@ bool write_lba(STRUCT_RKDEVICE_DESC &dev, UINT uiBegin, char *szFile)
if (iTotalWrite >= 1024)
printf("Write LBA from file (%lld%%)\r\n", (iTotalWrite / 1024) * 100 / (iFileSize / 1024));
else
printf("Write LBA from file %lld%%)\r\n", iTotalWrite * 100 / iFileSize);
printf("Write LBA from file (%lld%%)\r\n", iTotalWrite * 100 / iFileSize);
bFirst = false;
} else {
CURSOR_MOVEUP_LINE(1);
@ -1988,7 +1988,7 @@ bool write_lba(STRUCT_RKDEVICE_DESC &dev, UINT uiBegin, char *szFile)
}
bSuccess = true;
} else {
printf("Write LBA quit,Creating comm object failed!\r\n");
printf("Write LBA quit, creating comm object failed!\r\n");
}
Exit_WriteLBA:
if (pComm) {
@ -2060,21 +2060,21 @@ void tag_spl(char *tag, char *spl)
fclose(file);
len = strlen(spl);
char *tagedspl = new char[len + 5];
strcpy(tagedspl, spl);
strcpy(tagedspl + len, ".tag");
tagedspl[len+4] = 0;
printf("taged spl writed to %s\n", tagedspl);
char *taggedspl = new char[len + 5];
strcpy(taggedspl, spl);
strcpy(taggedspl + len, ".tag");
taggedspl[len+4] = 0;
printf("Writing tagged spl to %s\n", taggedspl);
file = fopen(tagedspl, "wb");
file = fopen(taggedspl, "wb");
if( !file ){
delete []tagedspl;
delete []taggedspl;
delete []Buf;
return;
}
fwrite(Buf, 1, iFileSize+len, file);
fclose(file);
delete []tagedspl;
delete []taggedspl;
delete []Buf;
printf("done\n");
return;
@ -2124,13 +2124,13 @@ bool handle_command(int argc, char* argv[], CRKScan *pScan)
cnt = pScan->Search(RKUSB_MASKROM | RKUSB_LOADER);
if (cnt < 1) {
ERROR_COLOR_ATTR;
printf("No found any rockusb device,please plug device in!");
printf("Did not find any rockusb device, please plug device in!");
NORMAL_COLOR_ATTR;
printf("\r\n");
return bSuccess;
} else if (cnt > 1) {
ERROR_COLOR_ATTR;
printf("Found many rockusb devices,please plug device out!");
printf("Found too many rockusb devices, please plug devices out!");
NORMAL_COLOR_ATTR;
printf("\r\n");
return bSuccess;
@ -2139,7 +2139,7 @@ bool handle_command(int argc, char* argv[], CRKScan *pScan)
bRet = pScan->GetDevice(dev, 0);
if (!bRet) {
ERROR_COLOR_ATTR;
printf("Getting information of rockusb device failed!");
printf("Getting information about rockusb device failed!");
NORMAL_COLOR_ATTR;
printf("\r\n");
return bSuccess;
@ -2181,7 +2181,7 @@ bool handle_command(int argc, char* argv[], CRKScan *pScan)
} else if (argc == 2) {
ret = find_config_item("loader");
if (ret == -1)
printf("No found loader item from config!\r\n");
printf("Did not find loader item in config!\r\n");
else
bSuccess = download_boot(dev, g_ConfigItemVec[ret].szItemValue);
} else
@ -2235,7 +2235,8 @@ bool handle_command(int argc, char* argv[], CRKScan *pScan)
}
}
} else {
printf("command is invalid,please press rkDevelopTool -h to check usage!\r\n");
printf("command is invalid!\r\n");
usage();
}
return bSuccess;
}
@ -2288,7 +2289,7 @@ int main(int argc, char* argv[])
pScan = new CRKScan();
if (!pScan) {
if (g_pLogObject) {
g_pLogObject->Record("Error:failed to Create object for searching device");
g_pLogObject->Record("Error: failed to create object for searching device");
delete g_pLogObject;
}
libusb_exit(NULL);