summaryrefslogtreecommitdiff
path: root/common/update_fw.c
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2022-09-21 14:10:01 -0700
committerTom Hughes <tomhughes@chromium.org>2022-09-22 12:49:33 -0700
commit2bcf863b492fe7ed8105c853814dba6ed32ba719 (patch)
treefcf6ce5810f9ff9e3c8cce434812dd75492269ed /common/update_fw.c
parente5fb0b9ba488614b5684e640530f00821ab7b943 (diff)
parent28712dae9d7ed1e694f7622cc083afa71090d4d5 (diff)
downloadchrome-ec-2bcf863b492fe7ed8105c853814dba6ed32ba719.tar.gz
Merge remote-tracking branch cros/main into firmware-fpmcu-bloonchipper-releasefirmware-fpmcu-bloonchipper-release
Generated by: ./util/update_release_branch.py --board bloonchipper --relevant_paths_file ./util/fingerprint-relevant-paths.txt firmware- fpmcu-bloonchipper-release Relevant changes: git log --oneline e5fb0b9ba4..28712dae9d -- board/hatch_fp board/bloonchipper common/fpsensor docs/fingerprint driver/fingerprint util/getversion.sh ded9307b79 util/getversion.sh: Fix version when not in a git repo 956055e692 board: change Google USB vendor info 71b2ef709d Update license boilerplate text in source code files 33e11afda0 Revert "fpsensor: Build fpsensor source file with C++" c8d0360723 fpsensor: Build fpsensor source file with C++ bc113abd53 fpsensor: Fix g++ compiler error 150a58a0dc fpsensor: Fix fp_set_sensor_mode return type b33b5ce85b fpsensor: Remove nested designators for C++ compatibility 2e864b2539 tree-wide: const-ify argv for console commands 56d8b360f9 test: Add test for get ikm failure when seed not set 3a3d6c3690 test: Add test for fpsensor trivial key failure 233e6bbd08 fpsensor_crypto: Abstract calls to hmac_SHA256 0a041b285b docs/fingerprint: Typo correction c03fab67e2 docs/fingerprint: Fix the path of fputils.py 0b5d4baf5a util/getversion.sh: Fix empty file list handling 6e128fe760 FPMCU dev board environment with Satlab 3eb29b6aa5 builtin: Move ssize_t to sys/types.h 345d62ebd1 docs/fingerprint: Update power numbers for latest dartmonkey release c25ffdb316 common: Conditionally support printf %l and %i modifiers 9a3c514b45 test: Add a test to check if the debugger is connected 54e603413f Move standard library tests to their own file 43fa6b4bf8 docs/fingerprint: Update power numbers for latest bloonchipper release 25536f9a84 driver/fingerprint/fpc/bep/fpc_sensor_spi.c: Format with clang-format 4face99efd driver/fingerprint/fpc/libfp/fpc_sensor_pal.h: Format with clang-format 738de2b575 trng: Rename rand to trng_rand 14b8270edd docs/fingerprint: Update dragonclaw power numbers 0b268f93d1 driver/fingerprint/fpc/libfp/fpc_private.c: Format with clang-format f80da163f2 driver/fingerprint/fpc/libfp/fpc_private.h: Format with clang-format 5e9c85c9b1 driver/fingerprint/fpc/libfp/fpc_sensor_pal.c: Format with clang-format c1f9dd3cf8 driver/fingerprint/fpc/libfp/fpc_bio_algorithm.h: Format with clang-format eb1e1bed8d driver/fingerprint/fpc/libfp/fpc1145_private.h: Format with clang-format 6e7b611821 driver/fingerprint/fpc/bep/fpc_bio_algorithm.h: Format with clang-format e0589cd5e2 driver/fingerprint/fpc/bep/fpc1035_private.h: Format with clang-format 7905e556a0 common/fpsensor/fpsensor_crypto.c: Format with clang-format 21289d170c driver/fingerprint/fpc/bep/fpc1025_private.h: Format with clang-format 98a20f937e common/fpsensor/fpsensor_state.c: Format with clang-format a2d255d8af common/fpsensor/fpsensor.c: Format with clang-format 73055eeb3f driver/fingerprint/fpc/bep/fpc_private.c: Format with clang-format 0f7b5cb509 common/fpsensor/fpsensor_private.h: Format with clang-format 1ceade6e65 driver/fingerprint/fpc/bep/fpc_private.h: Format with clang-format dc3e9008b8 board/hatch_fp/board.h: Format with clang-format dca9d74321 Revert "trng: Rename rand to trng_rand" a6b0b3554f trng: Rename rand to trng_rand 28d0b75b70 third_party/boringssl: Remove unused header BRANCH=None BUG=b:246424843 b:234181908 b:244781166 b:234181908 b:244387210 BUG=b:242720240 chromium:1098010 b:180945056 b:236025198 b:234181908 BUG=b:234181908 b:237344361 b:131913998 b:236386294 b:234143158 BUG=b:234781655 b:215613183 b:242720910 TEST=`make -j buildall` TEST=./test/run_device_tests.py --board bloonchipper Test "aes": PASSED Test "cec": PASSED Test "cortexm_fpu": PASSED Test "crc": PASSED Test "flash_physical": PASSED Test "flash_write_protect": PASSED Test "fpsensor_hw": PASSED Test "fpsensor_spi_ro": PASSED Test "fpsensor_spi_rw": PASSED Test "fpsensor_uart_ro": PASSED Test "fpsensor_uart_rw": PASSED Test "mpu_ro": PASSED Test "mpu_rw": PASSED Test "mutex": PASSED Test "pingpong": PASSED Test "printf": PASSED Test "queue": PASSED Test "rollback_region0": PASSED Test "rollback_region1": PASSED Test "rollback_entropy": PASSED Test "rtc": PASSED Test "sha256": PASSED Test "sha256_unrolled": PASSED Test "static_if": PASSED Test "stdlib": PASSED Test "system_is_locked_wp_on": PASSED Test "system_is_locked_wp_off": PASSED Test "timer_dos": PASSED Test "utils": PASSED Test "utils_str": PASSED Test "stm32f_rtc": PASSED Test "panic_data_bloonchipper_v2.0.4277": PASSED Test "panic_data_bloonchipper_v2.0.5938": PASSED Force-Relevant-Builds: all Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I264ad0ffe7afcd507a1e483c6e934a9c4fea47c3
Diffstat (limited to 'common/update_fw.c')
-rw-r--r--common/update_fw.c67
1 files changed, 30 insertions, 37 deletions
diff --git a/common/update_fw.c b/common/update_fw.c
index 068758e7b0..85b805191c 100644
--- a/common/update_fw.c
+++ b/common/update_fw.c
@@ -1,4 +1,4 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -25,13 +25,13 @@
#include "touchpad_fw_hash.h"
BUILD_ASSERT(sizeof(touchpad_fw_hashes) ==
- (CONFIG_TOUCHPAD_FW_CHUNKS * SHA256_DIGEST_SIZE));
+ (CONFIG_TOUCHPAD_FW_CHUNKS * SHA256_DIGEST_SIZE));
BUILD_ASSERT(sizeof(touchpad_fw_hashes[0]) == SHA256_DIGEST_SIZE);
BUILD_ASSERT(sizeof(touchpad_fw_full_hash) == SHA256_DIGEST_SIZE);
#endif
-#define CPRINTF(format, args...) cprintf(CC_USB, format, ## args)
+#define CPRINTF(format, args...) cprintf(CC_USB, format, ##args)
/* Section to be updated (i.e. not the current section). */
struct {
@@ -47,9 +47,8 @@ struct {
static int is_touchpad_block(uint32_t block_offset, size_t body_size)
{
return (block_offset >= CONFIG_TOUCHPAD_VIRTUAL_OFF) &&
- (block_offset + body_size) <=
- (CONFIG_TOUCHPAD_VIRTUAL_OFF +
- CONFIG_TOUCHPAD_VIRTUAL_SIZE);
+ (block_offset + body_size) <= (CONFIG_TOUCHPAD_VIRTUAL_OFF +
+ CONFIG_TOUCHPAD_VIRTUAL_SIZE);
}
#endif
@@ -71,17 +70,15 @@ static uint8_t check_update_chunk(uint32_t block_offset, size_t body_size)
if (update_section.base_offset != update_section.top_offset &&
(block_offset >= update_section.base_offset) &&
((block_offset + body_size) <= update_section.top_offset)) {
-
base = update_section.base_offset;
- size = update_section.top_offset -
- update_section.base_offset;
+ size = update_section.top_offset - update_section.base_offset;
/*
* If this is the first chunk for this section, it needs to
* be erased.
*/
if (block_offset == base) {
if (crec_flash_physical_erase(base, size) !=
- EC_SUCCESS) {
+ EC_SUCCESS) {
CPRINTF("%s:%d erase failure of 0x%x..+0x%x\n",
__func__, __LINE__, base, size);
return UPDATE_ERASE_FAILURE;
@@ -96,14 +93,11 @@ static uint8_t check_update_chunk(uint32_t block_offset, size_t body_size)
return UPDATE_SUCCESS;
#endif
- CPRINTF("%s:%d %x, %d section base %x top %x\n",
- __func__, __LINE__,
- block_offset, body_size,
- update_section.base_offset,
+ CPRINTF("%s:%d %x, %d section base %x top %x\n", __func__, __LINE__,
+ block_offset, body_size, update_section.base_offset,
update_section.top_offset);
return UPDATE_BAD_ADDR;
-
}
int update_pdu_valid(struct update_command *cmd_body, size_t cmd_size)
@@ -120,8 +114,8 @@ static void new_chunk_written(uint32_t block_offset)
{
}
-static int contents_allowed(uint32_t block_offset,
- size_t body_size, void *update_data)
+static int contents_allowed(uint32_t block_offset, size_t body_size,
+ void *update_data)
{
#if defined(CONFIG_TOUCHPAD_VIRTUAL_OFF) && defined(CONFIG_TOUCHPAD_HASH_FW)
if (is_touchpad_block(block_offset, body_size)) {
@@ -132,9 +126,9 @@ static int contents_allowed(uint32_t block_offset,
int good = 0;
if (chunk >= CONFIG_TOUCHPAD_FW_CHUNKS ||
- (fw_offset % CONFIG_UPDATE_PDU_SIZE) != 0) {
- CPRINTF("%s: TP invalid offset %08x\n",
- __func__, fw_offset);
+ (fw_offset % CONFIG_UPDATE_PDU_SIZE) != 0) {
+ CPRINTF("%s: TP invalid offset %08x\n", __func__,
+ fw_offset);
return 0;
}
@@ -143,10 +137,10 @@ static int contents_allowed(uint32_t block_offset,
tmp = SHA256_final(&ctx);
good = !memcmp(tmp, touchpad_fw_hashes[chunk],
- SHA256_DIGEST_SIZE);
+ SHA256_DIGEST_SIZE);
- CPRINTF("%s: TP %08x %02x..%02x (%s)\n", __func__,
- fw_offset, tmp[0], tmp[31], good ? "GOOD" : "BAD");
+ CPRINTF("%s: TP %08x %02x..%02x (%s)\n", __func__, fw_offset,
+ tmp[0], tmp[31], good ? "GOOD" : "BAD");
return good;
}
@@ -194,7 +188,7 @@ void fw_update_start(struct first_response_pdu *rpdu)
rpdu->common.offset = htobe32(update_section.base_offset);
if (version)
memcpy(rpdu->common.version, version,
- sizeof(rpdu->common.version));
+ sizeof(rpdu->common.version));
#ifdef CONFIG_ROLLBACK
rpdu->common.min_rollback = htobe32(rollback_get_minimum_version());
@@ -216,13 +210,12 @@ void fw_update_start(struct first_response_pdu *rpdu)
#endif
}
-void fw_update_command_handler(void *body,
- size_t cmd_size,
+void fw_update_command_handler(void *body, size_t cmd_size,
size_t *response_size)
{
struct update_command *cmd_body = body;
void *update_data;
- uint8_t *error_code = body; /* Cache the address for code clarity. */
+ uint8_t *error_code = body; /* Cache the address for code clarity. */
size_t body_size;
uint32_t block_offset;
@@ -285,11 +278,11 @@ void fw_update_command_handler(void *body,
#ifdef CONFIG_TOUCHPAD_VIRTUAL_OFF
if (is_touchpad_block(block_offset, body_size)) {
if (touchpad_update_write(
- block_offset - CONFIG_TOUCHPAD_VIRTUAL_OFF,
- body_size, update_data) != EC_SUCCESS) {
+ block_offset - CONFIG_TOUCHPAD_VIRTUAL_OFF,
+ body_size, update_data) != EC_SUCCESS) {
*error_code = UPDATE_WRITE_FAILURE;
- CPRINTF("%s:%d update write error\n",
- __func__, __LINE__);
+ CPRINTF("%s:%d update write error\n", __func__,
+ __LINE__);
return;
}
@@ -301,8 +294,8 @@ void fw_update_command_handler(void *body,
#endif
CPRINTF("update: 0x%x\n", block_offset + CONFIG_PROGRAM_MEMORY_BASE);
- if (crec_flash_physical_write(block_offset, body_size, update_data)
- != EC_SUCCESS) {
+ if (crec_flash_physical_write(block_offset, body_size, update_data) !=
+ EC_SUCCESS) {
*error_code = UPDATE_WRITE_FAILURE;
CPRINTF("%s:%d update write error\n", __func__, __LINE__);
return;
@@ -311,12 +304,12 @@ void fw_update_command_handler(void *body,
new_chunk_written(block_offset);
/* Verify that data was written properly. */
- if (memcmp(update_data, (void *)
- (block_offset + CONFIG_PROGRAM_MEMORY_BASE),
+ if (memcmp(update_data,
+ (void *)(block_offset + CONFIG_PROGRAM_MEMORY_BASE),
body_size)) {
*error_code = UPDATE_VERIFY_ERROR;
- CPRINTF("%s:%d update verification error\n",
- __func__, __LINE__);
+ CPRINTF("%s:%d update verification error\n", __func__,
+ __LINE__);
return;
}