summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2019-04-30 10:33:47 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-05-01 11:02:59 -0700
commit15bd8639ef6df248b4474808bd21d80b0c19bac4 (patch)
tree64bb5fd2113ab11b9849b30ee676781ced33e8bf /common
parent13089909211c5289c46d22a3cb7fb9b06efcd917 (diff)
downloadchrome-ec-15bd8639ef6df248b4474808bd21d80b0c19bac4.tar.gz
nvmem: add test of recovery from interrupted saves
Add a test which introduces corrupted objects in the flash and verifies that the initialization function is able to recover. BRANCH=cr50, cr50-mp BUG=b:69907320, b:129710256 TEST='make run-nvmem' succeeds Change-Id: Ibb7d8181dfdeb097b79087cdae824564ec28921f Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1590044 Reviewed-by: Andrey Pronin <apronin@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/new_nvmem.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/common/new_nvmem.c b/common/new_nvmem.c
index 60d8704a9b..9b3b399a67 100644
--- a/common/new_nvmem.c
+++ b/common/new_nvmem.c
@@ -944,6 +944,11 @@ static enum ec_error_list save_object(const struct nn_container *cont)
size_t save_size = aligned_container_size(cont);
size_t top_room;
+#if defined(NVMEM_TEST_BUILD)
+ if (failure_mode == TEST_FAILED_HASH)
+ save_size -= sizeof(uint32_t);
+#endif
+
top_room = CONFIG_FLASH_BANK_SIZE - master_at.mt.data_offset;
if (save_size >= top_room) {