summaryrefslogtreecommitdiff
path: root/chip/g/upgrade_fw.c
diff options
context:
space:
mode:
Diffstat (limited to 'chip/g/upgrade_fw.c')
-rw-r--r--chip/g/upgrade_fw.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/chip/g/upgrade_fw.c b/chip/g/upgrade_fw.c
index caa5b88818..d350753fa1 100644
--- a/chip/g/upgrade_fw.c
+++ b/chip/g/upgrade_fw.c
@@ -318,6 +318,23 @@ static int contents_allowed(uint32_t block_offset,
size_t body_size, void *upgrade_data,
uint8_t *error_code)
{
+#ifndef CR50_DEV
+#ifdef CONFIG_BOARD_ID_SUPPORT
+ if (block_offset == valid_sections.rw_base_offset) {
+ /* This block is a rw header of the new image. */
+ if (body_size < sizeof(struct SignedHeader)) {
+ CPRINTF("%s: block too short\n", __func__);
+ *error_code = UPGRADE_TRUNCATED_HEADER_ERROR;
+ return 0;
+ }
+ if (board_id_mismatch(upgrade_data)) {
+ CPRINTF("%s: rejecting Board ID mismatch.\n", __func__);
+ *error_code = UPGRADE_BOARD_ID_ERROR;
+ return 0;
+ }
+ }
+#endif
+#endif
return 1;
}
#endif