summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllen Webb <allenwebb@google.com>2018-08-21 07:44:37 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-09-07 18:36:34 -0700
commit8961872603f6d7b66ef97d444711e83d6a55e2f4 (patch)
tree814d6cf13e2fc23162daf6437dcef7625d7c84bf
parent5c5555a49d89154f14efa0c68c99938ef1313b73 (diff)
downloadchrome-ec-8961872603f6d7b66ef97d444711e83d6a55e2f4.tar.gz
common: flash and nvmem fixes for compatibility with the host board.
This CL 1) Forces alignment of __host_flash so it can be used with nvcounter 2) Disables a compile time check for the host board that failes because the host board uses a variable to emulate flash memory. 3) Disables nvmem_vars console commands that are specific to a unit test for fuzzing targets. BRANCH=none BUG=chromium:876582 TEST=make -j buildfuzztests (with cr50_fuzz CL) Change-Id: Id6257132d8f2dd73ae07e796efd0da3df83b30d6 Signed-off-by: Allen Webb <allenwebb@google.com> Reviewed-on: https://chromium-review.googlesource.com/1183533 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--chip/host/flash.c4
-rw-r--r--common/nvcounter.c8
-rw-r--r--common/nvmem_vars.c2
3 files changed, 11 insertions, 3 deletions
diff --git a/chip/host/flash.c b/chip/host/flash.c
index b83d72ff5f..4961db1578 100644
--- a/chip/host/flash.c
+++ b/chip/host/flash.c
@@ -8,11 +8,13 @@
#include <stdio.h>
#include "common.h"
+#include "config_chip.h"
#include "flash.h"
#include "persistence.h"
#include "util.h"
-char __host_flash[CONFIG_FLASH_SIZE];
+/* This needs to be aligned to the erase bank size for NVCTR. */
+__aligned(CONFIG_FLASH_ERASE_SIZE) char __host_flash[CONFIG_FLASH_SIZE];
uint8_t __host_flash_protect[PHYSICAL_BANKS];
/* Override this function to make flash erase/write operation fail */
diff --git a/common/nvcounter.c b/common/nvcounter.c
index de00d8857c..6c267e3a4c 100644
--- a/common/nvcounter.c
+++ b/common/nvcounter.c
@@ -21,9 +21,15 @@
static uint32_t *FLASH_CNT_LO = (uint32_t *)CONFIG_FLASH_NVCTR_BASE_A;
static uint32_t *FLASH_CNT_HI = (uint32_t *)CONFIG_FLASH_NVCTR_BASE_B;
-/* Ensure the 2 flash counter areas are aligned on flash pages */
+
+#ifndef CHIP_HOST
+/* Ensure the 2 flash counter areas are aligned on flash pages except for the
+ * host board which simulates flash with a variable that cannot be checked
+ * at compile time.
+ */
BUILD_ASSERT(CONFIG_FLASH_NVCTR_BASE_A % CONFIG_FLASH_ERASE_SIZE == 0);
BUILD_ASSERT(CONFIG_FLASH_NVCTR_BASE_B % CONFIG_FLASH_ERASE_SIZE == 0);
+#endif
/*
* An anti-rollback, persistent flash counter. This counter requires two pages
diff --git a/common/nvmem_vars.c b/common/nvmem_vars.c
index 746c47d1d7..d90fe37f9e 100644
--- a/common/nvmem_vars.c
+++ b/common/nvmem_vars.c
@@ -344,7 +344,7 @@ int writevars(void)
}
/****************************************************************************/
-#ifdef TEST_BUILD
+#if defined(TEST_BUILD) && !defined(TEST_FUZZ)
#include "console.h"
static void print_blob(const uint8_t *blob, int blob_len)