mirror of
https://github.com/sharkcz/rkdeveloptool.git
synced 2024-11-22 14:06:47 +01:00
1.support erase block forcely
2.fix create gpt bug Signed-off-by: liuyi <liuyi@rock-chips.com>
This commit is contained in:
parent
9870459553
commit
e541b7bbff
16
RKDevice.cpp
16
RKDevice.cpp
@ -584,7 +584,7 @@ bool CRKDevice::Boot_VendorRequest( DWORD requestCode, PBYTE pBuffer, DWORD dwDa
|
|||||||
iRet = m_pComm->RKU_DeviceRequest(requestCode, pBuffer, dwDataSize);
|
iRet = m_pComm->RKU_DeviceRequest(requestCode, pBuffer, dwDataSize);
|
||||||
return (iRet == ERR_SUCCESS) ? true : false;
|
return (iRet == ERR_SUCCESS) ? true : false;
|
||||||
}
|
}
|
||||||
int CRKDevice::EraseAllBlocks()
|
int CRKDevice::EraseAllBlocks(bool force_block_erase)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
UINT uiBlockCount;
|
UINT uiBlockCount;
|
||||||
@ -599,14 +599,16 @@ int CRKDevice::EraseAllBlocks()
|
|||||||
DWORD dwLayerID;
|
DWORD dwLayerID;
|
||||||
dwLayerID = LocationID;
|
dwLayerID = LocationID;
|
||||||
ENUM_CALL_STEP emCallStep = CALL_FIRST;
|
ENUM_CALL_STEP emCallStep = CALL_FIRST;
|
||||||
if ((m_bEmmc)||(m_bDirectLba)) {
|
if (!force_block_erase) {
|
||||||
if (!EraseEmmc()) {
|
if ((m_bEmmc)||(m_bDirectLba)) {
|
||||||
if (m_pLog) {
|
if (!EraseEmmc()) {
|
||||||
m_pLog->Record("<LAYER %s> ERROR:EraseAllBlocks-->EraseEmmc failed", m_layerName);
|
if (m_pLog) {
|
||||||
|
m_pLog->Record("<LAYER %s> ERROR:EraseAllBlocks-->EraseEmmc failed", m_layerName);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
return -1;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
if ( m_flashInfo.bFlashCS & (1 << i) ) {
|
if ( m_flashInfo.bFlashCS & (1 << i) ) {
|
||||||
|
@ -93,7 +93,7 @@ public:
|
|||||||
bool PowerOffDevice();
|
bool PowerOffDevice();
|
||||||
bool CheckChip();
|
bool CheckChip();
|
||||||
bool GetFlashInfo();
|
bool GetFlashInfo();
|
||||||
int EraseAllBlocks();
|
int EraseAllBlocks(bool force_block_erase=false);
|
||||||
bool SetObject(CRKImage *pImage, CRKComm *pComm, CRKLog *pLog);
|
bool SetObject(CRKImage *pImage, CRKComm *pComm, CRKLog *pLog);
|
||||||
string GetLayerString(DWORD dwLocationID);
|
string GetLayerString(DWORD dwLocationID);
|
||||||
CRKDevice(STRUCT_RKDEVICE_DESC &device);
|
CRKDevice(STRUCT_RKDEVICE_DESC &device);
|
||||||
|
22
main.cpp
22
main.cpp
@ -630,7 +630,10 @@ bool get_lba_from_gpt(u8 *master, char *pszName, u64 *lba, u64 *lba_end)
|
|||||||
}
|
}
|
||||||
if (bFound) {
|
if (bFound) {
|
||||||
*lba = le64_to_cpu(gptEntry->starting_lba);
|
*lba = le64_to_cpu(gptEntry->starting_lba);
|
||||||
*lba_end = le64_to_cpu(gptEntry->ending_lba);
|
if (gptMasterHead->last_usable_lba == gptEntry->ending_lba)
|
||||||
|
*lba_end = 0xFFFFFFFF;
|
||||||
|
else
|
||||||
|
*lba_end = le64_to_cpu(gptEntry->ending_lba);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -1039,7 +1042,9 @@ bool write_gpt(STRUCT_RKDEVICE_DESC &dev, char *szParameter)
|
|||||||
printf("\r\n");
|
printf("\r\n");
|
||||||
return bSuccess;
|
return bSuccess;
|
||||||
}
|
}
|
||||||
vecItems[vecItems.size()-1].uiItemSize = total_size_sector - 33;
|
if (vecItems[vecItems.size()-1].uiItemSize!=0xFFFFFFFF)
|
||||||
|
total_size_sector = vecItems[vecItems.size()-1].uiItemOffset + vecItems[vecItems.size()-1].uiItemSize + 33
|
||||||
|
//vecItems[vecItems.size()-1].uiItemSize = total_size_sector - 33;
|
||||||
//3.generate gpt info
|
//3.generate gpt info
|
||||||
create_gpt_buffer(master_gpt, vecItems, vecUuid, total_size_sector);
|
create_gpt_buffer(master_gpt, vecItems, vecUuid, total_size_sector);
|
||||||
memcpy(backup_gpt, master_gpt + 2* SECTOR_SIZE, 32 * SECTOR_SIZE);
|
memcpy(backup_gpt, master_gpt + 2* SECTOR_SIZE, 32 * SECTOR_SIZE);
|
||||||
@ -2561,6 +2566,7 @@ bool erase_ubi_block(STRUCT_RKDEVICE_DESC &dev, u32 uiOffset, u32 uiPartSize)
|
|||||||
int iRet;
|
int iRet;
|
||||||
DWORD *pID=NULL;
|
DWORD *pID=NULL;
|
||||||
|
|
||||||
|
printf("Erase ubi in, offset=0x%08x,size=0x%08x!\r\n",uiOffset,uiPartSize);
|
||||||
if (!check_device_type(dev, RKUSB_LOADER | RKUSB_MASKROM))
|
if (!check_device_type(dev, RKUSB_LOADER | RKUSB_MASKROM))
|
||||||
return false;
|
return false;
|
||||||
pComm = new CRKUsbComm(dev, g_pLogObject, bRet);
|
pComm = new CRKUsbComm(dev, g_pLogObject, bRet);
|
||||||
@ -2602,7 +2608,7 @@ bool erase_ubi_block(STRUCT_RKDEVICE_DESC &dev, u32 uiOffset, u32 uiPartSize)
|
|||||||
else
|
else
|
||||||
uiEraseBlock = uiPartSize / info.usBlockSize + 1;
|
uiEraseBlock = uiPartSize / info.usBlockSize + 1;
|
||||||
|
|
||||||
|
printf("Erase block start, offset=0x%08x,count=0x%08x!\r\n",uiStartBlock,uiEraseBlock);
|
||||||
uiErasePos=uiStartBlock;
|
uiErasePos=uiStartBlock;
|
||||||
while (uiEraseBlock>0)
|
while (uiEraseBlock>0)
|
||||||
{
|
{
|
||||||
@ -2695,9 +2701,9 @@ bool write_sparse_lba(STRUCT_RKDEVICE_DESC &dev, UINT uiBegin, UINT uiSize, char
|
|||||||
FILE *file = NULL;
|
FILE *file = NULL;
|
||||||
bool bRet, bSuccess = false, bFirst = true;
|
bool bRet, bSuccess = false, bFirst = true;
|
||||||
int iRet;
|
int iRet;
|
||||||
u64 iTotalWrite = 0, iFileSize = 0;
|
u64 iTotalWrite = 0, iFileSize = 0,dwChunkDataSize;
|
||||||
UINT iRead = 0, uiTransferSec, curChunk, i;
|
UINT iRead = 0, uiTransferSec, curChunk, i;
|
||||||
UINT dwChunkDataSize, dwMaxReadWriteBytes, dwTransferBytes, dwFillByte, dwCrc;
|
UINT dwMaxReadWriteBytes, dwTransferBytes, dwFillByte, dwCrc;
|
||||||
BYTE pBuf[SECTOR_SIZE * DEFAULT_RW_LBA];
|
BYTE pBuf[SECTOR_SIZE * DEFAULT_RW_LBA];
|
||||||
sparse_header header;
|
sparse_header header;
|
||||||
chunk_header chunk;
|
chunk_header chunk;
|
||||||
@ -2776,7 +2782,7 @@ bool write_sparse_lba(STRUCT_RKDEVICE_DESC &dev, UINT uiBegin, UINT uiSize, char
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CHUNK_TYPE_FILL:
|
case CHUNK_TYPE_FILL:
|
||||||
dwChunkDataSize = chunk.chunk_sz * header.blk_sz;
|
dwChunkDataSize = (u64)chunk.chunk_sz * header.blk_sz;
|
||||||
if (!EatSparseData(file, (PBYTE)&dwFillByte, 4)) {
|
if (!EatSparseData(file, (PBYTE)&dwFillByte, 4)) {
|
||||||
goto Exit_WriteSparseLBA;
|
goto Exit_WriteSparseLBA;
|
||||||
}
|
}
|
||||||
@ -2817,7 +2823,7 @@ bool write_sparse_lba(STRUCT_RKDEVICE_DESC &dev, UINT uiBegin, UINT uiSize, char
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CHUNK_TYPE_DONT_CARE:
|
case CHUNK_TYPE_DONT_CARE:
|
||||||
dwChunkDataSize = chunk.chunk_sz * header.blk_sz;
|
dwChunkDataSize = (u64)chunk.chunk_sz * header.blk_sz;
|
||||||
iTotalWrite += dwChunkDataSize;
|
iTotalWrite += dwChunkDataSize;
|
||||||
uiTransferSec = ((dwChunkDataSize % SECTOR_SIZE == 0) ? (dwChunkDataSize / SECTOR_SIZE) : (dwChunkDataSize / SECTOR_SIZE + 1));
|
uiTransferSec = ((dwChunkDataSize % SECTOR_SIZE == 0) ? (dwChunkDataSize / SECTOR_SIZE) : (dwChunkDataSize / SECTOR_SIZE + 1));
|
||||||
uiBegin += uiTransferSec;
|
uiBegin += uiTransferSec;
|
||||||
@ -3217,7 +3223,7 @@ bool handle_command(int argc, char* argv[], CRKScan *pScan)
|
|||||||
|
|
||||||
bSuccess = true;
|
bSuccess = true;
|
||||||
if (is_ubifs_image(argv[3]))
|
if (is_ubifs_image(argv[3]))
|
||||||
bSuccess = erase_ubi_block(dev, part_offset, part_size);
|
bSuccess = erase_ubi_block(dev, part_offset, part_size);
|
||||||
if (bSuccess)
|
if (bSuccess)
|
||||||
bSuccess = write_lba(dev, part_offset, argv[3]);
|
bSuccess = write_lba(dev, part_offset, argv[3]);
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user