mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-30 18:41:11 +00:00
g: expose API to unlock secondary RO area
For the upcoming header restore vendor command implementation there is a need to allow rw access to the alternative RO area. A static function for this is available in upgrade_fw.c, let's make it available to other users. BRANCH=cr50 BUG=b:35580805 TEST=verified that it is still possible to update the RO. Change-Id: I879804ff180c5d00cf6860ce5669f2fe48731832 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/457501 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
bd30d3f2cd
commit
a4f6a548d8
@@ -451,6 +451,18 @@ int flash_physical_erase(int byte_offset, int num_bytes)
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* Enable write access to the backup RO section. */
|
||||
void flash_open_ro_window(uint32_t offset, size_t size_b)
|
||||
{
|
||||
GREG32(GLOBALSEC, FLASH_REGION6_BASE_ADDR) =
|
||||
offset + CONFIG_PROGRAM_MEMORY_BASE;
|
||||
GREG32(GLOBALSEC, FLASH_REGION6_SIZE) = size_b - 1;
|
||||
GWRITE_FIELD(GLOBALSEC, FLASH_REGION6_CTRL, EN, 1);
|
||||
GWRITE_FIELD(GLOBALSEC, FLASH_REGION6_CTRL, RD_EN, 1);
|
||||
GWRITE_FIELD(GLOBALSEC, FLASH_REGION6_CTRL, WR_EN, 1);
|
||||
}
|
||||
|
||||
#ifdef CR50_DEV
|
||||
|
||||
static int command_erase_flash_info(int argc, char **argv)
|
||||
|
||||
@@ -30,4 +30,6 @@ void flash_info_write_disable(void);
|
||||
int flash_info_physical_write(int byte_offset, int num_bytes, const char *data);
|
||||
int flash_physical_info_read_word(int byte_offset, uint32_t *dst);
|
||||
|
||||
void flash_open_ro_window(uint32_t offset, size_t size_b);
|
||||
|
||||
#endif /* ! __EC_CHIP_G_FLASH_INFO_H */
|
||||
|
||||
@@ -3,21 +3,23 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "byteorder.h"
|
||||
#include "compile_time_macros.h"
|
||||
#include "console.h"
|
||||
#include "cryptoc/sha.h"
|
||||
#include "dcrypto/dcrypto.h"
|
||||
#include "extension.h"
|
||||
#include "flash.h"
|
||||
#include "flash_info.h"
|
||||
#include "hooks.h"
|
||||
#include "registers.h"
|
||||
#include "signed_header.h"
|
||||
#include "system.h"
|
||||
#include "system_chip.h"
|
||||
#include "registers.h"
|
||||
#include "uart.h"
|
||||
|
||||
#include "signed_header.h"
|
||||
#include "upgrade_fw.h"
|
||||
#include "cryptoc/sha.h"
|
||||
|
||||
#define CPRINTF(format, args...) cprintf(CC_EXTENSION, format, ## args)
|
||||
|
||||
@@ -66,17 +68,6 @@ static void set_valid_sections(void)
|
||||
CONFIG_RW_SIZE;
|
||||
}
|
||||
|
||||
/* Enable write access to the backup RO section. */
|
||||
static void open_ro_window(uint32_t offset, size_t size_b)
|
||||
{
|
||||
GREG32(GLOBALSEC, FLASH_REGION6_BASE_ADDR) =
|
||||
offset + CONFIG_PROGRAM_MEMORY_BASE;
|
||||
GREG32(GLOBALSEC, FLASH_REGION6_SIZE) = size_b - 1;
|
||||
GWRITE_FIELD(GLOBALSEC, FLASH_REGION6_CTRL, EN, 1);
|
||||
GWRITE_FIELD(GLOBALSEC, FLASH_REGION6_CTRL, RD_EN, 1);
|
||||
GWRITE_FIELD(GLOBALSEC, FLASH_REGION6_CTRL, WR_EN, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify that the passed in block fits into the valid area. If it does, and
|
||||
* is destined to the base address of the area - erase the area contents.
|
||||
@@ -128,7 +119,7 @@ static uint8_t check_update_chunk(uint32_t block_offset, size_t body_size)
|
||||
size = valid_sections.ro_top_offset -
|
||||
valid_sections.ro_base_offset;
|
||||
/* backup RO area write access needs to be enabled. */
|
||||
open_ro_window(base, size);
|
||||
flash_open_ro_window(base, size);
|
||||
if (flash_physical_erase(base, size) != EC_SUCCESS) {
|
||||
CPRINTF("%s:%d erase failure of 0x%x..+0x%x\n",
|
||||
__func__, __LINE__, base, size);
|
||||
|
||||
Reference in New Issue
Block a user