diff options
author | Allen Webb <allenwebb@google.com> | 2018-08-21 07:44:37 -0700 |
---|---|---|
committer | Vadim Bendebury <vbendeb@chromium.org> | 2019-09-21 19:11:21 -0700 |
commit | 1e63718c6a8c60faed7082e366043ac1325bed80 (patch) | |
tree | f9f3a36b494711abc878dfe77040aa414b937d02 | |
parent | 2fe7f933f42a59b71d56427f95dd4e46784ba670 (diff) | |
download | chrome-ec-1e63718c6a8c60faed7082e366043ac1325bed80.tar.gz |
common: flash and nvmem fixes for compatibility with the host board. (take two)
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)
Signed-off-by: Allen Webb <allenwebb@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1183533
Reviewed-by: Randall Spangler <rspangler@chromium.org>
(cherry picked from commit 8961872603f6d7b66ef97d444711e83d6a55e2f4)
Change-Id: I1a34f50919a4ab394c60f37fc78c64ca0047fb3c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1644276
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
(cherry picked from commit c4d2423f3527fb2605e212935dda8d7c94ef8a49)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1705697
(cherry picked from commit e586bb72f4c7c4ef12c75ca80549e8e1edbd3d3d)
-rw-r--r-- | chip/host/flash.c | 4 | ||||
-rw-r--r-- | common/nvcounter.c | 8 | ||||
-rw-r--r-- | common/nvmem_vars.c | 2 |
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 1bc32ee9e1..4ce28fbbb9 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) |