diff options
-rw-r--r-- | board/cr50/board.c | 13 | ||||
-rw-r--r-- | board/cr50/board.h | 3 | ||||
-rw-r--r-- | board/host/board.h | 3 | ||||
-rw-r--r-- | common/nvmem.c | 5 |
4 files changed, 22 insertions, 2 deletions
diff --git a/board/cr50/board.c b/board/cr50/board.c index ac1e640e47..4eeb21fc23 100644 --- a/board/cr50/board.c +++ b/board/cr50/board.c @@ -1718,3 +1718,16 @@ int board_in_prod_mode(void) { return in_prod_mode; } + +int board_nvmem_legacy_check_needed(void) +{ + enum system_image_copy_t other_rw; + const struct SignedHeader *h; + + other_rw = system_get_image_copy() == SYSTEM_IMAGE_RW ? + SYSTEM_IMAGE_RW_B : SYSTEM_IMAGE_RW; + + h = (const struct SignedHeader *)get_program_memory_addr(other_rw); + + return (h->major_ <= 2) || (h->minor_ <= 18); +} diff --git a/board/cr50/board.h b/board/cr50/board.h index f85d938b29..5a8c02f453 100644 --- a/board/cr50/board.h +++ b/board/cr50/board.h @@ -358,6 +358,9 @@ int ec_is_on(void); int ec_is_rx_allowed(void); int servo_is_connected(void); +/* Moving from legacy versions might require NVMEM transition. */ +int board_nvmem_legacy_check_needed(void); + void set_ap_on(void); /* Returns True if chip is brought up in a factory test harness. */ diff --git a/board/host/board.h b/board/host/board.h index ac44f31907..ad65749c3d 100644 --- a/board/host/board.h +++ b/board/host/board.h @@ -80,4 +80,7 @@ enum { #define CONFIG_RNG void fps_event(enum gpio_signal signal); +/* Let the tests always check the other NVMEM slot. */ +static inline int board_nvmem_legacy_check_needed(void){ return 1; } + #endif /* __CROS_EC_BOARD_H */ diff --git a/common/nvmem.c b/common/nvmem.c index 4b4d8fc590..42fc0ba161 100644 --- a/common/nvmem.c +++ b/common/nvmem.c @@ -4,10 +4,10 @@ */ #include "common.h" +#include "board.h" #include "console.h" #include "dcrypto.h" #include "flash.h" -#include "nvmem.h" #include "new_nvmem.h" #include "task.h" #include "timer.h" @@ -313,7 +313,8 @@ int nvmem_init(void) * Try discovering legacy partition(s). If even one is present, need * to migrate to the new nvmem storage scheme. */ - if (nvmem_find_partition() == EC_SUCCESS) + if (board_nvmem_legacy_check_needed() && + (nvmem_find_partition() == EC_SUCCESS)) ret = new_nvmem_migrate(nvmem_act_partition); else ret = new_nvmem_init(); |