diff --git a/board/cr50/tpm2/NVMem.c b/board/cr50/tpm2/NVMem.c index 7dad3d5d3d..695debe26c 100644 --- a/board/cr50/tpm2/NVMem.c +++ b/board/cr50/tpm2/NVMem.c @@ -65,14 +65,10 @@ int _plat__NVEnable(void *platParameter) */ s_NV_recoverable = nvmem_get_error_state() != 0; s_NV_unrecoverable = s_NV_recoverable; - if (s_NV_unrecoverable) - return -1; - return s_NV_recoverable; -#else - if (s_NV_unrecoverable) - return -1; - return s_NV_recoverable; #endif + if (s_NV_unrecoverable) + return -1; + return s_NV_recoverable; } void _plat__NVDisable(void) @@ -217,3 +213,12 @@ void _plat__ClearNvAvail(void) s_NvIsAvailable = FALSE; return; } + +void wipe_nvram(void) +{ +#ifdef CONFIG_FLASH_NVMEM + nvmem_setup(0); +#else + memset(s_NV, 0xff, sizeof(s_NV)); +#endif +} diff --git a/board/cr50/tpm2/memory.h b/board/cr50/tpm2/memory.h index de9729313d..fc79db2778 100644 --- a/board/cr50/tpm2/memory.h +++ b/board/cr50/tpm2/memory.h @@ -6,6 +6,7 @@ #ifndef __EC_BOARD_CR50_TPM2_MEMORY_H #define __EC_BOARD_CR50_TPM2_MEMORY_H -/* An empty file to meet expectations of the tpm2 library. */ +/* A function to reinitialize the TPM NVram. */ +void wipe_nvram(void); #endif /* __EC_BOARD_CR50_TPM2_MEMORY_H */ diff --git a/common/nvmem.c b/common/nvmem.c index 63ea1581f5..c4a373291a 100644 --- a/common/nvmem.c +++ b/common/nvmem.c @@ -12,6 +12,7 @@ #include "util.h" #define CPRINTF(format, args...) cprintf(CC_COMMAND, format, ## args) +#define CPRINTS(format, args...) cprints(CC_COMMAND, format, ## args) #define NVMEM_ACQUIRE_CACHE_SLEEP_MS 25 #define NVMEM_ACQUIRE_CACHE_MAX_ATTEMPTS (250 / NVMEM_ACQUIRE_CACHE_SLEEP_MS) @@ -273,7 +274,7 @@ int nvmem_setup(uint8_t starting_version) int part; int ret; - CPRINTF("Configuring NVMEM FLash Partition\n"); + CPRINTS("Configuring NVMEM FLash Partition"); /* * Initialize NVmem partition. This function will only be called * if during nvmem_init() fails which implies that NvMem is not fully @@ -334,6 +335,7 @@ int nvmem_init(void) return ret; } + CPRINTS("Active NVram partition set to %d", nvmem_act_partition); return EC_SUCCESS; }