aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Chiu <dchiu@synaptics.com>2022-04-25 16:33:47 +0800
committerDavid Chiu <dchiu@synaptics.com>2022-04-25 16:33:47 +0800
commitb081422856340e9a95880edf8621a172797410b8 (patch)
treed829854e7637b9a0180440638435b89b3bfd525d
parent1adbac08fc71a502fbeda84c39d7513baf68d991 (diff)
downloadrmi4utils-b081422856340e9a95880edf8621a172797410b8.tar.gz
Support write protection
-rwxr-xr-xrmi4update/rmi4update.cpp27
-rwxr-xr-xrmi4update/rmi4update.h2
-rw-r--r--rmi4update/updateutil.cpp1
-rw-r--r--rmi4update/updateutil.h1
4 files changed, 30 insertions, 1 deletions
diff --git a/rmi4update/rmi4update.cpp b/rmi4update/rmi4update.cpp
index 5e1d924..6a21c38 100755
--- a/rmi4update/rmi4update.cpp
+++ b/rmi4update/rmi4update.cpp
@@ -1119,6 +1119,10 @@ int RMI4Update::WriteFlashConfigV7()
do {
Sleep(20);
rmi4update_poll();
+ if (CheckWriteProtectionActivated()) {
+ 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 (CheckWriteProtectionActivated()) {
+ 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 (CheckWriteProtectionActivated()) {
+ 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 (CheckWriteProtectionActivated()) {
+ 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::CheckWriteProtectionActivated()
+{
+ 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..80923dd 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 CheckWriteProtectionActivated();
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);