mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-11 18:35:28 +00:00
g: clear reset_counter after update
If the firmware was just updated clear the reset counter before rebooting. This will ensure that the update can complete even if the TPM isn't being used. BUG=chrome-os-partner:56864 BRANCH=none TEST=Set the reset counter to 7 by running 'rw 0x40000128 1' and 'rw 0x4000012c 7'. Then make sure cr50 can still be updated Change-Id: Ic304fc7a20a4f2af7792f80e970d28e0eb10967e Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/380235 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "signed_header.h"
|
||||
#include "system.h"
|
||||
#include "task.h"
|
||||
#include "upgrade_fw.h"
|
||||
#include "version.h"
|
||||
|
||||
static void check_reset_cause(void)
|
||||
@@ -86,6 +87,14 @@ 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)
|
||||
{
|
||||
@@ -96,6 +105,15 @@ 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 {
|
||||
@@ -333,9 +351,7 @@ int system_process_retry_counter(void)
|
||||
struct SignedHeader *me, *other;
|
||||
|
||||
retry_counter = GREG32(PMU, LONG_LIFE_SCRATCH0);
|
||||
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);
|
||||
clear_retry_counter();
|
||||
|
||||
ccprintf("%s:retry counter %d\n", __func__, retry_counter);
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ 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)
|
||||
{
|
||||
@@ -263,3 +265,13 @@ void fw_upgrade_command_handler(void *body,
|
||||
|
||||
*error_code = UPGRADE_SUCCESS;
|
||||
}
|
||||
|
||||
void fw_upgrade_complete(void)
|
||||
{
|
||||
upgrade_done = 1;
|
||||
}
|
||||
|
||||
int fw_upgraded(void)
|
||||
{
|
||||
return upgrade_done;
|
||||
}
|
||||
|
||||
@@ -115,6 +115,11 @@ 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);
|
||||
|
||||
/* Various upgrade command return values. */
|
||||
enum return_value {
|
||||
|
||||
@@ -206,6 +206,7 @@ static void upgrade_out_handler(struct consumer const *consumer, size_t count)
|
||||
if (command == UPGRADE_DONE) {
|
||||
CPRINTS("FW update: done");
|
||||
|
||||
fw_upgrade_complete();
|
||||
resp_value = 0;
|
||||
QUEUE_ADD_UNITS(&upgrade_to_usb,
|
||||
&resp_value, 1);
|
||||
|
||||
Reference in New Issue
Block a user