mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
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>
This commit is contained in:
committed by
chrome-bot
parent
7be8626706
commit
82f1f4187c
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user