mirror of
https://github.com/sharkcz/rkdeveloptool.git
synced 2024-11-22 14:06:47 +01:00
wl to support sparse image
Signed-off-by: liuyi <liuyi@rock-chips.com>
This commit is contained in:
parent
1eeab6be5a
commit
ae4252f085
26
main.cpp
26
main.cpp
@ -42,7 +42,7 @@ u8 test_gpt_head[] = {
|
|||||||
void usage()
|
void usage()
|
||||||
{
|
{
|
||||||
printf("\r\n---------------------Tool Usage ---------------------\r\n");
|
printf("\r\n---------------------Tool Usage ---------------------\r\n");
|
||||||
printf("Help:\t\t\t-h or --version\r\n");
|
printf("Help:\t\t\t-h or --help\r\n");
|
||||||
printf("Version:\t\t-v or --version\r\n");
|
printf("Version:\t\t-v or --version\r\n");
|
||||||
printf("DownloadBoot:\t\tdb <Loader>\r\n");
|
printf("DownloadBoot:\t\tdb <Loader>\r\n");
|
||||||
printf("UpgradeLoader:\t\tul <Loader>\r\n");
|
printf("UpgradeLoader:\t\tul <Loader>\r\n");
|
||||||
@ -2284,7 +2284,7 @@ Exit_ReadLBA:
|
|||||||
}
|
}
|
||||||
bool erase_partition(CRKUsbComm *pComm, UINT uiOffset, UINT uiSize)
|
bool erase_partition(CRKUsbComm *pComm, UINT uiOffset, UINT uiSize)
|
||||||
{
|
{
|
||||||
UINT uiErase=2048*64;
|
UINT uiErase=1024*32;
|
||||||
bool bSuccess = true;
|
bool bSuccess = true;
|
||||||
int iRet;
|
int iRet;
|
||||||
while (uiSize)
|
while (uiSize)
|
||||||
@ -2359,11 +2359,7 @@ bool write_sparse_lba(STRUCT_RKDEVICE_DESC &dev, UINT uiBegin, UINT uiSize, char
|
|||||||
dwMaxReadWriteBytes = DEFAULT_RW_LBA * SECTOR_SIZE;
|
dwMaxReadWriteBytes = DEFAULT_RW_LBA * SECTOR_SIZE;
|
||||||
pComm = new CRKUsbComm(dev, g_pLogObject, bRet);
|
pComm = new CRKUsbComm(dev, g_pLogObject, bRet);
|
||||||
if (bRet) {
|
if (bRet) {
|
||||||
bRet = erase_partition(pComm, uiBegin, uiSize);
|
|
||||||
if (!bRet) {
|
|
||||||
printf("%s failed, erase partition error\r\n", __func__);
|
|
||||||
goto Exit_WriteSparseLBA;
|
|
||||||
}
|
|
||||||
file = fopen(szFile, "rb");
|
file = fopen(szFile, "rb");
|
||||||
if( !file ) {
|
if( !file ) {
|
||||||
printf("%s failed, err=%d, can't open file: %s\r\n", __func__, errno, szFile);
|
printf("%s failed, err=%d, can't open file: %s\r\n", __func__, errno, szFile);
|
||||||
@ -2382,7 +2378,13 @@ bool write_sparse_lba(STRUCT_RKDEVICE_DESC &dev, UINT uiBegin, UINT uiSize, char
|
|||||||
iFileSize = header.blk_sz * (u64)header.total_blks;
|
iFileSize = header.blk_sz * (u64)header.total_blks;
|
||||||
iTotalWrite = 0;
|
iTotalWrite = 0;
|
||||||
curChunk = 0;
|
curChunk = 0;
|
||||||
|
if (uiSize==(u32)-1)
|
||||||
|
uiSize = ALIGN(iFileSize, SECTOR_SIZE);
|
||||||
|
bRet = erase_partition(pComm, uiBegin, uiSize);
|
||||||
|
if (!bRet) {
|
||||||
|
printf("%s failed, erase partition error\r\n", __func__);
|
||||||
|
goto Exit_WriteSparseLBA;
|
||||||
|
}
|
||||||
while(curChunk < header.total_chunks)
|
while(curChunk < header.total_chunks)
|
||||||
{
|
{
|
||||||
if (!EatSparseChunk(file, chunk)) {
|
if (!EatSparseChunk(file, chunk)) {
|
||||||
@ -2786,8 +2788,12 @@ bool handle_command(int argc, char* argv[], CRKScan *pScan)
|
|||||||
uiBegin = strtoul(argv[2], &pszEnd, 0);
|
uiBegin = strtoul(argv[2], &pszEnd, 0);
|
||||||
if (*pszEnd)
|
if (*pszEnd)
|
||||||
printf("Begin is invalid, please check!\r\n");
|
printf("Begin is invalid, please check!\r\n");
|
||||||
else
|
else {
|
||||||
bSuccess = write_lba(dev, uiBegin, argv[3]);
|
if (is_sparse_image(argv[3]))
|
||||||
|
bSuccess = write_sparse_lba(dev, (u32)uiBegin, (u32)-1, argv[3]);
|
||||||
|
else
|
||||||
|
bSuccess = write_lba(dev, (u32)uiBegin, argv[3]);
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
printf("Parameter of [WL] command is invalid, please check help!\r\n");
|
printf("Parameter of [WL] command is invalid, please check help!\r\n");
|
||||||
} else if(strcmp(strCmd.c_str(), "WLX") == 0) {
|
} else if(strcmp(strCmd.c_str(), "WLX") == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user