~increscent/rkdeveloptool

2fa9750242270ecc5c9fe105bd5e16ce086c7531 — Robert Williams 3 months ago 46bb4c0 main
Messing around with rkdeveloptool
A 471.bin => 471.bin +0 -0
A 472.bin => 472.bin +0 -0
M RKComm.cpp => RKComm.cpp +11 -1
@@ 147,17 147,21 @@ bool CRKUsbComm::RKU_Write(BYTE* lpBuffer, DWORD dwSize)
{
	int  iRet;
	int nWrite;
    printf("RKU_WRITE\r\n");
	iRet = libusb_bulk_transfer((libusb_device_handle *)m_pUsbHandle, m_pipeBulkOut, lpBuffer, dwSize, &nWrite, CMD_TIMEOUT);
	if (iRet != 0) {
	    if (m_log) {
	        m_log->Record("Error:RKU_Write failed, err=%d", iRet);
	    }
        printf("%s\r\n", libusb_error_name(iRet));
        printf("\r\nError:RKU_Write failed, err=%d\r\n", iRet);
	    return false;
	}
    if (nWrite != (int)dwSize) {
       	if (m_log) {
        	m_log->Record("Error:RKU_Write failed, size=%d, read=%d", dwSize, nWrite);
    	}
        printf("Error:RKU_Write failed, size=%d, read=%d", dwSize, nWrite);
        return false;
    }
	return true;


@@ 389,6 393,7 @@ int CRKUsbComm::RKU_ReadFlashInfo(BYTE* lpBuffer, UINT *puiRead)
        if (m_log) {
            m_log->Record("Error:RKU_ReadFlashInfo failed,device not support");
        }
        printf("20\r\n");
        return ERR_DEVICE_NOT_SUPPORT;
    }
	CBW cbw;


@@ 399,6 404,7 @@ int CRKUsbComm::RKU_ReadFlashInfo(BYTE* lpBuffer, UINT *puiRead)

	if(!RKU_Write((BYTE *)&cbw, sizeof(CBW)))
	{
        printf("21\r\n");
		return ERR_DEVICE_WRITE_FAILED;
	}



@@ 406,6 412,7 @@ int CRKUsbComm::RKU_ReadFlashInfo(BYTE* lpBuffer, UINT *puiRead)
	dwRead = RKU_Read_EX(lpBuffer, 512);
	if ((dwRead < 11) || (dwRead > 512))
	{
        printf("21\r\n");
		return ERR_DEVICE_READ_FAILED;
	}
	if (puiRead)


@@ 420,11 427,14 @@ int CRKUsbComm::RKU_ReadFlashInfo(BYTE* lpBuffer, UINT *puiRead)
*/
	if(!RKU_Read((BYTE *)&csw, sizeof(CSW)))
	{
        printf("22\r\n");
		return ERR_DEVICE_READ_FAILED;
	}

	if( !UFI_CHECK_SIGN(cbw, csw) )
	if( !UFI_CHECK_SIGN(cbw, csw) ) {
        printf("23\r\n");
		return ERR_CMD_NOTMATCH;
    }

	return ERR_SUCCESS;
}

M RKDevice.cpp => RKDevice.cpp +11 -0
@@ 6,6 6,7 @@
 */

#include "RKDevice.h"
#include <stdio.h>

const char* szManufName[] =
{


@@ 512,6 513,7 @@ int CRKDevice::DownloadBoot()
	UCHAR i;
	DWORD dwSize, dwDelay;
	PBYTE pBuffer = NULL;
	printf("Entry471Count: %d\n", (int)m_pImage->m_bootObject->Entry471Count);
	for ( i = 0; i < m_pImage->m_bootObject->Entry471Count; i++ ) {
		if ( !m_pImage->m_bootObject->GetEntryProperty(ENTRY471, i, dwSize, dwDelay) ) {
			if (m_pLog) {


@@ 520,6 522,7 @@ int CRKDevice::DownloadBoot()
			return -2;
		}
		if (dwSize>0) {
            printf("dwSize: %d\n\n", dwSize);
			pBuffer = new BYTE[dwSize];
			if ( !m_pImage->m_bootObject->GetEntryData(ENTRY471, i, pBuffer) ) {
				if (m_pLog) {


@@ 528,6 531,9 @@ int CRKDevice::DownloadBoot()
				delete []pBuffer;
				return -3;
			}
            FILE *f = fopen("471.bin", "w");
            fwrite(pBuffer, 1, dwSize, f);
            fclose(f);
			if ( !Boot_VendorRequest(0x0471,pBuffer,dwSize) ) {
				if (m_pLog) {
					m_pLog->Record("<LAYER %s> ERROR:DownloadBoot-->Boot_VendorRequest471 failed,index(%d)", m_layerName, i);


@@ 544,6 550,7 @@ int CRKDevice::DownloadBoot()
		}
	}

	printf("Entry472Count: %d\n", (int)m_pImage->m_bootObject->Entry472Count);
	for ( i=0; i < m_pImage->m_bootObject->Entry472Count; i++ ) {
		if ( !m_pImage->m_bootObject->GetEntryProperty(ENTRY472, i, dwSize, dwDelay) ) {
			if (m_pLog) {


@@ 552,6 559,7 @@ int CRKDevice::DownloadBoot()
			return -2;
		}
		if (dwSize > 0) {
            printf("dwSize: %d\n\n", dwSize);
			pBuffer = new BYTE[dwSize];
			if ( !m_pImage->m_bootObject->GetEntryData(ENTRY472, i, pBuffer) ) {
				if (m_pLog) {


@@ 560,6 568,9 @@ int CRKDevice::DownloadBoot()
				delete []pBuffer;
				return -3;
			}
            FILE *f = fopen("472.bin", "w");
            fwrite(pBuffer, 1, dwSize, f);
            fclose(f);
			if ( !Boot_VendorRequest(0x0472, pBuffer, dwSize) ) {
				if (m_pLog) {
					m_pLog->Record("<LAYER %s> ERROR:DownloadBoot-->Boot_VendorRequest472 failed,index(%d)", m_layerName, i);

M RKImage.cpp => RKImage.cpp +11 -1
@@ 162,10 162,12 @@ CRKImage::CRKImage(string filename, bool &bCheck)
	strcpy(szName, filename.c_str());
	if(stat(szName, &statBuf) < 0) {
		bCheck = false;
        printf("1\r\n");
		return;
	}
	if (S_ISDIR(statBuf.st_mode)) {
		bCheck = false;
        printf("2\r\n");
		return;
	}
	m_fileSize = statBuf.st_size;


@@ 179,6 181,7 @@ CRKImage::CRKImage(string filename, bool &bCheck)
	m_pFile = fopen(szName, "rb");
	if (!m_pFile) {
		bCheck = false;
        printf("3\r\n");
		return;
	}



@@ 190,10 193,12 @@ CRKImage::CRKImage(string filename, bool &bCheck)
		iRead = fread((PBYTE)(&imageHead), 1, sizeof(STRUCT_RKIMAGE_HEAD), m_pFile);
		if (iRead != sizeof(STRUCT_RKIMAGE_HEAD)) {
			bCheck = false;
            printf("4\r\n");
			return;
		}
		if ( imageHead.uiTag != 0x57464B52 ) {
			bCheck = false;
            printf("5\r\n");
			return;
		}
		if ((imageHead.reserved[14] == 'H') && (imageHead.reserved[15] == 'I')) {


@@ 211,11 216,13 @@ CRKImage::CRKImage(string filename, bool &bCheck)
			iRead = fread(m_md5, 1, 32, m_pFile);
			if (iRead != 32) {
				bCheck = false;
                printf("6\r\n");
				return;
			}
			iRead = fread(m_signMd5, 1, nMd5DataSize - 32, m_pFile);
			if (iRead != (nMd5DataSize - 32)) {
				bCheck = false;
                printf("7\r\n");
				return;
			}
		} else {


@@ 223,6 230,7 @@ CRKImage::CRKImage(string filename, bool &bCheck)
			iRead = fread(m_md5, 1, 32, m_pFile);
			if (iRead != 32) {
				bCheck = false;
                printf("8\r\n");
				return;
			}
		}


@@ 252,12 260,14 @@ CRKImage::CRKImage(string filename, bool &bCheck)
	iRead = fread(lpBoot, 1, m_bootSize, m_pFile);
	if (iRead != (int)m_bootSize) {
		bCheck = false;
        printf("9\r\n");
		return;
	}
	bool bRet;
	m_bootObject = new CRKBoot(lpBoot, m_bootSize, bRet);
	if (!bRet) {
		bCheck = false;
        printf("10\r\n");
		return;
	}
	if (bOnlyBootFile) {


@@ 295,4 305,4 @@ int CRKImage::GetMd5Data(PBYTE &lpMd5, PBYTE &lpSignMd5)
bool CRKImage::GetSignFlag()
{
	return m_bSignFlag;
}
\ No newline at end of file
}

A log/log2022-06-30.txt => log/log2022-06-30.txt +21 -0
@@ 0,0 1,21 @@
15:09:19 	Error:InitializeUsb-->open device failed,err=-3
15:27:25 	Error:RKU_DeviceRequest-->DeviceRequest vendor=0x471 failed, err=-1
15:27:25 	<LAYER 1-1> ERROR:DownloadBoot-->Boot_VendorRequest471 failed,index(0)
16:06:36 	Error:RKU_DeviceRequest-->DeviceRequest vendor=0x471 failed, err=-1
16:06:36 	<LAYER 1-1> ERROR:DownloadBoot-->Boot_VendorRequest471 failed,index(0)
16:11:36 	Error:RKU_DeviceRequest-->DeviceRequest vendor=0x471 failed, err=-1
16:11:36 	<LAYER 1-1> ERROR:DownloadBoot-->Boot_VendorRequest471 failed,index(0)
16:14:12 	Error:RKU_DeviceRequest-->DeviceRequest vendor=0x471 failed, err=-1
16:14:12 	<LAYER 1-1> ERROR:DownloadBoot-->Boot_VendorRequest471 failed,index(0)
16:39:38 	Error:RKU_DeviceRequest-->DeviceRequest vendor=0x471 failed, err=-1
16:39:38 	<LAYER 1-1> ERROR:DownloadBoot-->Boot_VendorRequest471 failed,index(0)
16:39:46 	Error:RKU_DeviceRequest-->DeviceRequest vendor=0x471 failed, err=-1
16:39:46 	<LAYER 1-1> ERROR:DownloadBoot-->Boot_VendorRequest471 failed,index(0)
16:40:03 	Error:RKU_DeviceRequest-->DeviceRequest vendor=0x471 failed, err=-1
16:40:03 	<LAYER 1-1> ERROR:DownloadBoot-->Boot_VendorRequest471 failed,index(0)
16:40:07 	Error:RKU_DeviceRequest-->DeviceRequest vendor=0x471 failed, err=-1
16:40:07 	<LAYER 1-1> ERROR:DownloadBoot-->Boot_VendorRequest471 failed,index(0)
16:40:13 	Error:RKU_DeviceRequest-->DeviceRequest vendor=0x471 failed, err=-1
16:40:13 	<LAYER 1-1> ERROR:DownloadBoot-->Boot_VendorRequest471 failed,index(0)
16:43:57 	Error:RKU_DeviceRequest-->DeviceRequest vendor=0x471 failed, err=-1
16:43:57 	<LAYER 1-1> ERROR:DownloadBoot-->Boot_VendorRequest471 failed,index(0)

M main.cpp => main.cpp +1 -1
@@ 1488,7 1488,7 @@ static bool saveEntry(FILE* outFile, char* path, rk_entry_type type,
}

static inline uint32_t convertChipType(const char* chip) {
	char buffer[5];
	char buffer[558];
	memset(buffer, 0, sizeof(buffer));
	snprintf(buffer, sizeof(buffer), "%s", chip);
	return buffer[0] << 24 | buffer[1] << 16 | buffer[2] << 8 | buffer[3];

A pbuffer.bin => pbuffer.bin +0 -0
A rk3128_bootloader_v2.12.bin => rk3128_bootloader_v2.12.bin +0 -0
A rkdeveloptool471 => rkdeveloptool471 +0 -0
A rkdeveloptool472 => rkdeveloptool472 +0 -0