diff options
author | David Chiu <dchiu@synaptics.com> | 2022-05-18 16:24:50 +0800 |
---|---|---|
committer | Vincent Huang <vincenthsw@gmail.com> | 2022-09-28 16:40:25 +0800 |
commit | 492fabbe22dd584a6f8056fc70a7ac3b569d8749 (patch) | |
tree | 1a5e03ae81db401c46c8df4b42ee53cc9070f9d7 | |
parent | 53b3c8437af10831aefea3498549e012f3ff5425 (diff) | |
download | rmi4utils-492fabbe22dd584a6f8056fc70a7ac3b569d8749.tar.gz |
Support checking MSL
-rwxr-xr-x | rmi4update/firmware_image.cpp | 7 | ||||
-rwxr-xr-x | rmi4update/firmware_image.h | 7 | ||||
-rwxr-xr-x | rmi4update/rmi4update.cpp | 41 | ||||
-rwxr-xr-x | rmi4update/rmi4update.h | 7 | ||||
-rw-r--r-- | rmi4update/updateutil.h | 1 |
5 files changed, 56 insertions, 7 deletions
diff --git a/rmi4update/firmware_image.cpp b/rmi4update/firmware_image.cpp index 6b0323e..ecc2af4 100755 --- a/rmi4update/firmware_image.cpp +++ b/rmi4update/firmware_image.cpp @@ -123,6 +123,13 @@ void FirmwareImage::ParseHierarchicalImg() m_firmwareBuildID = extract_long(content + 4); memcpy(m_productID, (content + 0x18), RMI_PRODUCT_ID_LENGTH); m_productID[RMI_PRODUCT_ID_LENGTH] = 0; + if ((descriptor->major_version == 0) && + (descriptor->minor_version > 0)) { + m_hasFirmwareVersion = true; + fprintf(stdout, "General Information version : %d.%d\n", descriptor->major_version, descriptor->minor_version); + m_firmwareVersion = *(content + 0x26) << 8 | *(content + 0x27); + fprintf(stdout, "Firmware version : 0x%x\n", m_firmwareVersion); + } break; case FIXED_LOCATION_DATA_CONTAINER: if (sigature_size != 0) { diff --git a/rmi4update/firmware_image.h b/rmi4update/firmware_image.h index e4279d5..3558b07 100755 --- a/rmi4update/firmware_image.h +++ b/rmi4update/firmware_image.h @@ -110,7 +110,8 @@ class FirmwareImage { public: FirmwareImage() : m_firmwareBuildID(0), m_packageID(0), m_firmwareData(NULL), m_configData(NULL), m_lockdownData(NULL), - m_memBlock(NULL), m_hasSignature(false), m_fldData(NULL), m_fldSize(0), m_globalparaData(NULL), m_globalparaSize(0) + m_memBlock(NULL), m_hasSignature(false), m_fldData(NULL), m_fldSize(0), m_globalparaData(NULL), m_globalparaSize(0), + m_firmwareVersion(0), m_hasFirmwareVersion(false) {} int Initialize(const char * filename); int VerifyImageMatchesDevice(unsigned long deviceFirmwareSize, @@ -128,8 +129,10 @@ public: unsigned long GetFirmwareID() { return m_firmwareBuildID; } unsigned long GetFLDSize() { return m_fldSize; } unsigned long GetGlobalParametersSize() { return m_globalparaSize; } + unsigned short GetFirmwareVersion() { return m_firmwareVersion; } signature_info *GetSignatureInfo() { return m_signatureInfo; } int VerifyImageProductID(char* deviceProductID); + bool IsImageHasFirmwareVersion() { return m_hasFirmwareVersion; } bool HasIO() { return m_io; } ~FirmwareImage(); @@ -164,6 +167,8 @@ private: unsigned long m_fldSize; unsigned char * m_globalparaData; unsigned long m_globalparaSize; + unsigned short m_firmwareVersion; + bool m_hasFirmwareVersion; signature_info m_signatureInfo[BLv7_MAX]; }; diff --git a/rmi4update/rmi4update.cpp b/rmi4update/rmi4update.cpp index 5338234..6091842 100755 --- a/rmi4update/rmi4update.cpp +++ b/rmi4update/rmi4update.cpp @@ -158,6 +158,21 @@ int RMI4Update::UpdateFirmware(bool force, bool performLockdown) } fprintf(stdout, "Enable Flash done V7+...\n"); + if (IsBLv87()) { + if (m_firmwareImage.IsImageHasFirmwareVersion()) { + rc = ReadMSL(); + fprintf(stdout, "MSL : 0x%x\n", m_MSL); + if (m_MSL > m_firmwareImage.GetFirmwareVersion()) { + fprintf(stdout, "MSL checking failed. device(0x%x) > image(0x%x)\n", + m_MSL, m_firmwareImage.GetFirmwareVersion()); + rc = UPDATE_FAIL_MSL_CHECKING; + goto reset; + } else { + fprintf(stdout, "Passing MSL checking\n"); + } + } + } + if (m_bootloaderID[1] >= 10) { fprintf(stdout, "Writing FLD V10...\n"); rc = WriteFLDV7(); @@ -1119,7 +1134,7 @@ int RMI4Update::WriteFlashConfigV7() do { Sleep(20); rmi4update_poll(); - if (IsWriteProtectionSupported()) { + if (IsBLv87()) { if (m_flashStatus == WRITE_PROTECTION) return UPDATE_FAIL_WRITE_PROTECTED; } @@ -1256,7 +1271,7 @@ int RMI4Update::WriteFLDV7() do { Sleep(20); rmi4update_poll(); - if (IsWriteProtectionSupported()) { + if (IsBLv87()) { if (m_flashStatus == WRITE_PROTECTION) return UPDATE_FAIL_WRITE_PROTECTED; } @@ -1450,7 +1465,7 @@ int RMI4Update::EraseFlashConfigV10() do { Sleep(20); rmi4update_poll(); - if (IsWriteProtectionSupported()) { + if (IsBLv87()) { if (m_flashStatus == WRITE_PROTECTION) return UPDATE_FAIL_WRITE_PROTECTED; } @@ -1581,7 +1596,7 @@ int RMI4Update::EraseFirmwareV7() do { Sleep(20); rmi4update_poll(); - if (IsWriteProtectionSupported()) { + if (IsBLv87()) { if (m_flashStatus == WRITE_PROTECTION) return UPDATE_FAIL_WRITE_PROTECTED; } @@ -1989,7 +2004,7 @@ int RMI4Update::WaitForIdle(int timeout_ms, bool readF34OnSucess) return UPDATE_SUCCESS; } -bool RMI4Update::IsWriteProtectionSupported() +bool RMI4Update::IsBLv87() { if ((m_bootloaderID[1] >= 10) || ((m_bootloaderID[1] == 8) && (m_bootloaderID[0] >= 7))){ @@ -1997,3 +2012,19 @@ bool RMI4Update::IsWriteProtectionSupported() } else return false; } + +int RMI4Update::ReadMSL() +{ + int rc; + unsigned char idStr[3]; + unsigned short query9Addr = m_f34.GetQueryBase() + 9; + unsigned char offset; + unsigned char MSL[2]; + + rc = m_device.Read(query9Addr, MSL, sizeof(MSL)); + if (rc != sizeof(MSL)) + return UPDATE_FAIL_READ_F34_QUERIES; + + m_MSL = MSL[0] << 8 | MSL[1]; + return UPDATE_SUCCESS; +} diff --git a/rmi4update/rmi4update.h b/rmi4update/rmi4update.h index cfc5d21..ea87653 100755 --- a/rmi4update/rmi4update.h +++ b/rmi4update/rmi4update.h @@ -195,7 +195,8 @@ private: int GetFirmwareSize() { return m_blockSize * m_fwBlockCount; } int GetConfigSize() { return m_blockSize * m_configBlockCount; } int WriteSignatureV7(enum signature_BLv7 signature_partition, unsigned char* data, int offset); - bool IsWriteProtectionSupported(); + bool IsBLv87(); + int ReadMSL(); private: RMIDevice & m_device; @@ -238,6 +239,10 @@ private: bool m_hasGlobalParameters; /* BL_V7 end */ + /* BL v8.7 */ + unsigned short m_MSL; + /* BL v8.7 end */ + /* for BL V10 */ bool m_hasFLD; /* BL_V7 end */ diff --git a/rmi4update/updateutil.h b/rmi4update/updateutil.h index 8667086..e59d690 100644 --- a/rmi4update/updateutil.h +++ b/rmi4update/updateutil.h @@ -52,6 +52,7 @@ enum update_error { UPDATE_FAIL_INVALID_PARAMETER, UPDATE_FAIL_OPEN_FIRMWARE_IMAGE, UPDATE_FAIL_WRITE_PROTECTED, + UPDATE_FAIL_MSL_CHECKING, }; const char * update_err_to_string(int err); |