summaryrefslogtreecommitdiff
path: root/test/flash_write_protect.c
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2021-07-27 18:33:46 -0700
committerCommit Bot <commit-bot@chromium.org>2021-07-30 21:13:22 +0000
commit3d67df923a05a5108ef1f00586880e35acf89d82 (patch)
tree0abb3d5b7c89ac4ee4b42d20f8c1e6c603aecfa7 /test/flash_write_protect.c
parentd92c21a2ae6544aac372ec9b98a97cab1db6d302 (diff)
downloadchrome-ec-3d67df923a05a5108ef1f00586880e35acf89d82.tar.gz
flash: Set CBI EEPROM WP immediately if SW WP set
With `CONFIG_EEPROM_CBI_WP`, the EC will set the the CBI EEPROM WP according to `system_is_locked`. The system lock status is also cached. In order to prevent requiring an EC reboot after setting the software write protect status, this commit will set the CBI EEPROM WP status when the SW WP is asserted along with the HW WP. This is the same criteria that `system_is_locked` would use when deciding if the system is locked. BUG=b:181769483 BRANCH=None TEST=Build and flash a reworked lalala, enable HW WP, enable SW WP via `flashrom -p ec --wp-enable` and verify that EC_CBI_WP is asserted immediately without requiring an EC reboot. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I987a5b7652134be11c82855aab9ed4eb1442b57c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3058077 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'test/flash_write_protect.c')
-rw-r--r--test/flash_write_protect.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/flash_write_protect.c b/test/flash_write_protect.c
index 2bf801c9b0..df20ede3fd 100644
--- a/test/flash_write_protect.c
+++ b/test/flash_write_protect.c
@@ -79,16 +79,55 @@ test_static void run_test_step2(void)
if (test_get_error_count())
test_reboot_to_next_step(TEST_STATE_FAILED);
+ else if (IS_ENABLED(CONFIG_EEPROM_CBI_WP))
+ test_reboot_to_next_step(TEST_STATE_STEP_3);
else
test_reboot_to_next_step(TEST_STATE_PASSED);
}
+#ifdef CONFIG_EEPROM_CBI_WP
+test_static int test_cbi_wb_asserted_immediately(void)
+{
+ int rv;
+
+ TEST_EQ(check_image_and_hardware_write_protect(), EC_SUCCESS, "%d");
+
+ /* Ensure that EC_CBI_WP is not asserted. */
+ TEST_EQ(gpio_get_level(GPIO_EC_CBI_WP), 0, "%d");
+
+ /* Equivalent of ectool --name=cros_fp flashprotect disable */
+ rv = crec_flash_set_protect(EC_FLASH_PROTECT_RO_NOW, 0);
+ TEST_EQ(rv, EC_SUCCESS, "%d");
+
+ /* Now make sure EC_CBI_WP is asserted immediately. */
+ TEST_EQ(gpio_get_level(GPIO_EC_CBI_WP), 1, "%d");
+
+
+ return EC_SUCCESS;
+}
+
+test_static void run_test_step3(void)
+{
+ ccprintf("Step 3: Flash write protect test\n");
+ RUN_TEST(test_cbi_wb_asserted_immediately);
+
+ if (test_get_error_count())
+ test_reboot_to_next_step(TEST_STATE_FAILED);
+ else
+ test_reboot_to_next_step(TEST_STATE_PASSED);
+}
+#endif /* CONFIG_EEPROM_CBI_WP */
+
void test_run_step(uint32_t state)
{
if (state & TEST_STATE_MASK(TEST_STATE_STEP_1))
run_test_step1();
else if (state & TEST_STATE_MASK(TEST_STATE_STEP_2))
run_test_step2();
+#ifdef CONFIG_EEPROM_CBI_WP
+ else if (state & TEST_STATE_MASK(TEST_STATE_STEP_3))
+ run_test_step3();
+#endif /* CONFIG_EEPROM_CBI_WP */
}
int task_test(void *unused)