summaryrefslogtreecommitdiff
path: root/test/nvmem.c
diff options
context:
space:
mode:
authorScott <scollyer@chromium.org>2016-08-30 17:21:49 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-09-02 21:16:35 -0700
commit1d46c3770842d6c1f06ea3798aa36c5eeb2b392f (patch)
treebf513b92a52722ae85a3723268b663d7aeb25511 /test/nvmem.c
parentb2a751cfd8b5f543e7b40f32c81a7a6f876c42c7 (diff)
downloadchrome-ec-1d46c3770842d6c1f06ea3798aa36c5eeb2b392f.tar.gz
Cr50: NvMem: Allow for partitions to not be contiguous
TPM2.0 needs more NvMem space and currently the whole block is contiguous in memory with 2 partitions. This CL removes the requirement that the partitions are in contiguous which allows for 1 partition to placed at top of RW_A and the other at RW_B. This CL does not change the size of each partition as that will be done in a subsequent CL. BRANCH=none BUG=chrome-os-partner:56798 TEST=manual Tested with the unit test 'make runtests TEST_LIST_HOST=nvmem' and verified that all tests pass. Tested on Kevin, erased the existing NvMem area and verified that TPM was still manufactured and executed the command: trunks_client --own Erased parition 0 and 1 in the new locations and repeated the tests. Change-Id: I295441f94dccdf5a152c32603c2638ffac23f471 Signed-off-by: Scott <scollyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/378675 Commit-Ready: Bill Richardson <wfrichar@chromium.org> Tested-by: Bill Richardson <wfrichar@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Tested-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'test/nvmem.c')
-rw-r--r--test/nvmem.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/test/nvmem.c b/test/nvmem.c
index bbd580589d..9f007f0191 100644
--- a/test/nvmem.c
+++ b/test/nvmem.c
@@ -139,8 +139,10 @@ static int test_fully_erased_nvmem(void)
*/
/* Erase full NvMem area */
- flash_physical_erase(CONFIG_FLASH_NVMEM_OFFSET,
- CONFIG_FLASH_NVMEM_SIZE);
+ flash_physical_erase(CONFIG_FLASH_NVMEM_OFFSET_A,
+ NVMEM_PARTITION_SIZE);
+ flash_physical_erase(CONFIG_FLASH_NVMEM_OFFSET_B,
+ NVMEM_PARTITION_SIZE);
/* Call NvMem initialization function */
return nvmem_init();
}
@@ -160,8 +162,6 @@ static int test_configured_nvmem(void)
static int test_corrupt_nvmem(void)
{
- uint32_t offset;
- int n;
int ret;
struct nvmem_tag *p_part;
uint8_t *p_data;
@@ -175,12 +175,12 @@ static int test_corrupt_nvmem(void)
/* Overwrite each partition will all 0s */
memset(write_buffer, 0, NVMEM_PARTITION_SIZE);
- for (n = 0; n < NVMEM_NUM_PARTITIONS; n++) {
- offset = NVMEM_PARTITION_SIZE * n;
- flash_physical_write(CONFIG_FLASH_NVMEM_OFFSET + offset,
+ flash_physical_write(CONFIG_FLASH_NVMEM_OFFSET_A,
+ NVMEM_PARTITION_SIZE,
+ (const char *)write_buffer);
+ flash_physical_write(CONFIG_FLASH_NVMEM_OFFSET_B,
NVMEM_PARTITION_SIZE,
(const char *)write_buffer);
- }
/*
* The initialization function will look for a valid partition and if
* none is found, then will call nvmem_setup() which will erase the
@@ -197,7 +197,7 @@ static int test_corrupt_nvmem(void)
* partition 0 has a version number of 1 and that all of the user buffer
* data has been erased.
*/
- p_part = (struct nvmem_tag *)CONFIG_FLASH_NVMEM_BASE;
+ p_part = (struct nvmem_tag *)CONFIG_FLASH_NVMEM_BASE_A;
TEST_ASSERT(p_part->version == 1);
p_data = (uint8_t *)p_part + sizeof(struct nvmem_tag);
/* Verify that partition 0 is fully erased */
@@ -205,8 +205,7 @@ static int test_corrupt_nvmem(void)
sizeof(struct nvmem_tag));
/* Run the same test for partition 1 which should have version 0 */
- p_part = (struct nvmem_tag *)(CONFIG_FLASH_NVMEM_BASE +
- NVMEM_PARTITION_SIZE);
+ p_part = (struct nvmem_tag *)CONFIG_FLASH_NVMEM_BASE_B;
TEST_ASSERT(p_part->version == 0);
p_data = (uint8_t *)p_part + sizeof(struct nvmem_tag);
ccprintf("Partition Version = %d\n", p_part->version);