summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2019-12-03 12:59:18 -0800
committerCommit Bot <commit-bot@chromium.org>2019-12-06 23:48:34 +0000
commit5046ee81f5eb35330615b54f0486f4f052ef8a62 (patch)
tree5fe9eb108cead114c1ea1ec561e630815f69f760
parent5c88fa3af437636a626e2046b59dab94eeab021c (diff)
downloadchrome-ec-5046ee81f5eb35330615b54f0486f4f052ef8a62.tar.gz
g: update rollback info map for both RO and RW sections
Both RO and RW sections have their respective rollback spaces in INFO1, but until now Cr50 code did not honor the RO binaries' headers rollback maps and did not update the appropriate iNFO1 space. With this patch both RO and RW info maps are updated to the lowest level of the two images found in the flash when invoked during board_init() or to match the currently active RO/RW when invoked through vendor command indicating successful OS startup. BRANCH=cr50, cr50-mp BUG=b:136284186 TEST=tried the new image on a chip with freshly erased INFO1 space: first running a DBG image, which does not touch INFO1 maps: > vers ... RO_A: * 0.0.11/bc74f7dc RO_B: 0.0.11/4d655eab RW_A: * 0.4.24/DBG/cr50_v2.0.2744-d79516a9d RW_B: 0.4.24/DBG/cr50_v2.0.2744-d79516a9d .. > sysinfo ... Rollback: 0/1/1 0/128/128 ... Then running an image with debug extensions disabled: > vers ... RO_A: * 0.0.11/bc74f7dc RO_B: 0.0.11/4d655eab RW_A: 0.4.24/DBG/cr50_v2.0.2744-d79516a9d RW_B: * 0.4.24/cr50_v2.0.2744-d79516a9d ... > sysinfo ... Rollback: 1/1/1 2/128/2 ... Change-Id: I259a3f46c03199633ca85389872449d667f172fb Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1949548 Reviewed-by: Mary Ruthven <mruthven@chromium.org> (cherry picked from commit 94cfd7cee548047d8e0f5dee2995c4c03fba665d) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1954342
-rw-r--r--chip/g/system.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/chip/g/system.c b/chip/g/system.c
index 2b6d63be33..d68da094f2 100644
--- a/chip/g/system.c
+++ b/chip/g/system.c
@@ -604,15 +604,20 @@ const char *system_get_build_info(void)
* header address is passed (the other one is set to zero), only the valid
* header is considered when updating INFO1.
*/
-static void update_rollback_mask(const struct SignedHeader *header_a,
- const struct SignedHeader *header_b)
+static void update_rollback_mask(uint32_t addr_a, uint32_t addr_b,
+ uint32_t info_base_offset)
{
#ifndef CR50_DEV
+ const struct SignedHeader *header_a;
+ const struct SignedHeader *header_b;
int updated_words_count = 0;
int i;
int write_enabled = 0;
uint32_t header_mask = 0;
+ header_a = (const struct SignedHeader *)addr_a;
+ header_b = (const struct SignedHeader *)addr_b;
+
/*
* The infomap field in the image header has a matching space in the
* flash INFO1 section.
@@ -659,7 +664,7 @@ static void update_rollback_mask(const struct SignedHeader *header_a,
break;
}
- byte_offset = (INFO_MAX + i) * sizeof(uint32_t);
+ byte_offset = info_base_offset + i * sizeof(uint32_t);
if (flash_physical_info_read_word(byte_offset, &word) !=
EC_SUCCESS) {
@@ -696,17 +701,21 @@ static void update_rollback_mask(const struct SignedHeader *header_a,
void system_update_rollback_mask_with_active_img(void)
{
- update_rollback_mask((const struct SignedHeader *)
- get_program_memory_addr(system_get_image_copy()),
- 0);
+ update_rollback_mask(
+ get_program_memory_addr(system_get_ro_image_copy()), 0,
+ INFO_RO_MAP_OFFSET);
+ update_rollback_mask(get_program_memory_addr(system_get_image_copy()),
+ 0, INFO_RW_MAP_OFFSET);
}
void system_update_rollback_mask_with_both_imgs(void)
{
- update_rollback_mask((const struct SignedHeader *)
- get_program_memory_addr(SYSTEM_IMAGE_RW),
- (const struct SignedHeader *)
- get_program_memory_addr(SYSTEM_IMAGE_RW_B));
+ update_rollback_mask(get_program_memory_addr(SYSTEM_IMAGE_RO),
+ get_program_memory_addr(SYSTEM_IMAGE_RO_B),
+ INFO_RO_MAP_OFFSET);
+ update_rollback_mask(get_program_memory_addr(SYSTEM_IMAGE_RW),
+ get_program_memory_addr(SYSTEM_IMAGE_RW_B),
+ INFO_RW_MAP_OFFSET);
}
void system_get_rollback_bits(char *value, size_t value_size)