diff options
author | Vincent Huang <vincenthsw@gmail.com> | 2022-04-29 15:51:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-29 15:51:36 +0800 |
commit | 53b3c8437af10831aefea3498549e012f3ff5425 (patch) | |
tree | 6b5adae4094e008cec589891f8d838129f40357f | |
parent | 9bb07fb6893e8debba61573cc0584924f110a44f (diff) | |
parent | 833d55ac8895265d756ccde3f5255320e213dad9 (diff) | |
download | rmi4utils-53b3c8437af10831aefea3498549e012f3ff5425.tar.gz |
Merge pull request #35 from blueue/writeprotect
Writeprotect
-rwxr-xr-x | rmi4update/rmi4update.cpp | 27 | ||||
-rwxr-xr-x | rmi4update/rmi4update.h | 2 | ||||
-rw-r--r-- | rmi4update/updateutil.cpp | 1 | ||||
-rw-r--r-- | rmi4update/updateutil.h | 1 |
4 files changed, 30 insertions, 1 deletions
diff --git a/rmi4update/rmi4update.cpp b/rmi4update/rmi4update.cpp index 5e1d924..5338234 100755 --- a/rmi4update/rmi4update.cpp +++ b/rmi4update/rmi4update.cpp @@ -1119,6 +1119,10 @@ int RMI4Update::WriteFlashConfigV7() do { Sleep(20); rmi4update_poll(); + if (IsWriteProtectionSupported()) { + if (m_flashStatus == WRITE_PROTECTION) + return UPDATE_FAIL_WRITE_PROTECTED; + } if (m_flashStatus == SUCCESS){ break; } @@ -1252,6 +1256,10 @@ int RMI4Update::WriteFLDV7() do { Sleep(20); rmi4update_poll(); + if (IsWriteProtectionSupported()) { + if (m_flashStatus == WRITE_PROTECTION) + return UPDATE_FAIL_WRITE_PROTECTED; + } if (m_flashStatus == SUCCESS){ break; @@ -1442,6 +1450,10 @@ int RMI4Update::EraseFlashConfigV10() do { Sleep(20); rmi4update_poll(); + if (IsWriteProtectionSupported()) { + if (m_flashStatus == WRITE_PROTECTION) + return UPDATE_FAIL_WRITE_PROTECTED; + } if (m_flashStatus == SUCCESS){ break; } @@ -1569,6 +1581,10 @@ int RMI4Update::EraseFirmwareV7() do { Sleep(20); rmi4update_poll(); + if (IsWriteProtectionSupported()) { + if (m_flashStatus == WRITE_PROTECTION) + return UPDATE_FAIL_WRITE_PROTECTED; + } if (m_flashStatus == SUCCESS){ break; } @@ -1681,7 +1697,7 @@ int RMI4Update::EnterFlashProgrammingV7() rmi4update_poll(); if (!m_inBLmode) return UPDATE_FAIL_DEVICE_NOT_IN_BOOTLOADER; - + } else fprintf(stdout, "Already in BL mode, skip...\n"); @@ -1972,3 +1988,12 @@ int RMI4Update::WaitForIdle(int timeout_ms, bool readF34OnSucess) return UPDATE_SUCCESS; } + +bool RMI4Update::IsWriteProtectionSupported() +{ + if ((m_bootloaderID[1] >= 10) || + ((m_bootloaderID[1] == 8) && (m_bootloaderID[0] >= 7))){ + return true; + } else + return false; +} diff --git a/rmi4update/rmi4update.h b/rmi4update/rmi4update.h index 928e07b..cfc5d21 100755 --- a/rmi4update/rmi4update.h +++ b/rmi4update/rmi4update.h @@ -35,6 +35,7 @@ enum v7_status { FLASH_PROGRAMMING_KEY_INCORRECT, BAD_PARTITION_TABLE, CHECKSUM_FAILED, + WRITE_PROTECTION = 0x0E, FLASH_HARDWARE_FAILURE = 0x1f, }; @@ -194,6 +195,7 @@ 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(); private: RMIDevice & m_device; diff --git a/rmi4update/updateutil.cpp b/rmi4update/updateutil.cpp index 52245d3..cc607d2 100644 --- a/rmi4update/updateutil.cpp +++ b/rmi4update/updateutil.cpp @@ -52,6 +52,7 @@ const char *update_error_str[] = { "the firmware image is older then the firmware on the device", // UPDATE_FAIL_FIRMWARE_IMAGE_IS_OLDER "invalid parameter", // UPDATE_FAIL_INVALID_PARAMETER "failed to open firmware image file", // UPDATE_FAIL_OPEN_FIRMWARE_IMAGE + "write protection is activated", // UPDATE_FAIL_WRITE_PROTECTED }; const char * update_err_to_string(int err) diff --git a/rmi4update/updateutil.h b/rmi4update/updateutil.h index c65c53a..8667086 100644 --- a/rmi4update/updateutil.h +++ b/rmi4update/updateutil.h @@ -51,6 +51,7 @@ enum update_error { UPDATE_FAIL_FIRMWARE_IMAGE_IS_OLDER, UPDATE_FAIL_INVALID_PARAMETER, UPDATE_FAIL_OPEN_FIRMWARE_IMAGE, + UPDATE_FAIL_WRITE_PROTECTED, }; const char * update_err_to_string(int err); |