summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2016-09-08 19:29:09 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-09-09 02:58:49 -0700
commit82f1f4187cabac1f179201231afb2e628ac94cd1 (patch)
tree8c7c29918f5275590b078418fafee8f43f932c13
parent7be86267061c6ed71768c26fb7ba329274d1b761 (diff)
downloadchrome-ec-82f1f4187cabac1f179201231afb2e628ac94cd1.tar.gz
g: usb update: clear fallback counter after update finishes
There is no point in waiting for a reset to clear the fallback counter, it can be cleared as soon as USB update is finished. BRANCH=none BUG=chrome-os-partner:56864 TEST=on a kevin-tpm2 device: set the reset counter to 7 by running > rw 0x40000128 1 > rw 0x4000012c 7 on the cr50 console. Then try uploading a new RW image over Suzy-Q and verify that it is running after reset. Then verify that cr50 can still be updated Change-Id: I098a87c48b2fe864143715b1e90d4bb2409b9eae Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/383077 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
-rw-r--r--chip/g/system.c28
-rw-r--r--chip/g/upgrade_fw.c8
-rw-r--r--chip/g/upgrade_fw.h3
-rw-r--r--include/system.h8
4 files changed, 18 insertions, 29 deletions
diff --git a/chip/g/system.c b/chip/g/system.c
index 15640f46e3..b79af123ce 100644
--- a/chip/g/system.c
+++ b/chip/g/system.c
@@ -13,7 +13,6 @@
#include "signed_header.h"
#include "system.h"
#include "task.h"
-#include "upgrade_fw.h"
#include "version.h"
static void check_reset_cause(void)
@@ -87,14 +86,6 @@ void system_pre_init(void)
system_init_board_properties();
#endif
}
-#ifdef BOARD_CR50
-void clear_retry_counter(void)
-{
- GWRITE_FIELD(PMU, LONG_LIFE_SCRATCH_WR_EN, REG0, 1);
- GREG32(PMU, LONG_LIFE_SCRATCH0) = 0;
- GWRITE_FIELD(PMU, LONG_LIFE_SCRATCH_WR_EN, REG0, 0);
-}
-#endif
void system_reset(int flags)
{
@@ -105,15 +96,6 @@ void system_reset(int flags)
interrupt_disable();
if (flags & SYSTEM_RESET_HARD) {
-#if defined(BOARD_CR50) && !defined(SECTION_IS_RO)
- /*
- * If the system was updated during this boot clear the retry
- * counter.
- */
- if (fw_upgraded())
- clear_retry_counter();
-#endif
-
/* Reset the full microcontroller */
GR_PMU_GLOBAL_RESET = GC_PMU_GLOBAL_RESET_KEY;
} else {
@@ -281,6 +263,14 @@ const char *system_get_version(enum system_image_copy_t copy)
}
#ifdef BOARD_CR50
+
+void system_clear_retry_counter(void)
+{
+ GWRITE_FIELD(PMU, LONG_LIFE_SCRATCH_WR_EN, REG0, 1);
+ GREG32(PMU, LONG_LIFE_SCRATCH0) = 0;
+ GWRITE_FIELD(PMU, LONG_LIFE_SCRATCH_WR_EN, REG0, 0);
+}
+
/*
* Check wich of the two cr50 RW images is newer, return true if the first
* image is no older than the second one.
@@ -351,7 +341,7 @@ int system_process_retry_counter(void)
struct SignedHeader *me, *other;
retry_counter = GREG32(PMU, LONG_LIFE_SCRATCH0);
- clear_retry_counter();
+ system_clear_retry_counter();
ccprintf("%s:retry counter %d\n", __func__, retry_counter);
diff --git a/chip/g/upgrade_fw.c b/chip/g/upgrade_fw.c
index b1da99d7a7..8cc79eaafa 100644
--- a/chip/g/upgrade_fw.c
+++ b/chip/g/upgrade_fw.c
@@ -32,8 +32,6 @@ struct {
uint32_t rw_top_offset;
} valid_sections;
-static int upgrade_done;
-
/* Pick sections where updates can go to based on current code addresses. */
static void set_valid_sections(void)
{
@@ -268,10 +266,6 @@ void fw_upgrade_command_handler(void *body,
void fw_upgrade_complete(void)
{
- upgrade_done = 1;
+ system_clear_retry_counter();
}
-int fw_upgraded(void)
-{
- return upgrade_done;
-}
diff --git a/chip/g/upgrade_fw.h b/chip/g/upgrade_fw.h
index cbddd5bdb8..239384668f 100644
--- a/chip/g/upgrade_fw.h
+++ b/chip/g/upgrade_fw.h
@@ -115,9 +115,6 @@ void fw_upgrade_command_handler(void *body,
size_t cmd_size,
size_t *response_size);
-/* Returns 1 if an upgrade was done during this run 0 if there was no upgrade */
-int fw_upgraded(void);
-
/* Used to tell fw upgrade the update ran successfully and is finished */
void fw_upgrade_complete(void);
diff --git a/include/system.h b/include/system.h
index d6d2c063b7..5bca2c6321 100644
--- a/include/system.h
+++ b/include/system.h
@@ -462,6 +462,14 @@ int system_is_reboot_warm(void);
*/
int system_process_retry_counter(void);
+/**
+ * On systems with protection from a failing RW update: reset retry
+ * counter, this is used after a new image upload is finished, to make
+ * sure that the new image has a chance to run.
+ */
+void system_clear_retry_counter(void);
+
+
/* Board properties options */
#define BOARD_SLAVE_CONFIG_SPI (1 << 0) /* Slave SPI interface */
#define BOARD_SLAVE_CONFIG_I2C (1 << 1) /* Slave I2C interface */