Skip to content

fix: Verify Secure Boot signature before marking OTA successful#294

Open
ambaragrawal33 wants to merge 1 commit intoBlockstream:masterfrom
ambaragrawal33:master
Open

fix: Verify Secure Boot signature before marking OTA successful#294
ambaragrawal33 wants to merge 1 commit intoBlockstream:masterfrom
ambaragrawal33:master

Conversation

@ambaragrawal33
Copy link
Copy Markdown

Description

This PR fixes a UX issue where the OTA update process reports "Upgrade successful!" when a user attempts to flash an unsigned firmware binary (e.g., a beta or DIY build) onto production hardware, only for the bootloader to silently reject it and roll back upon reboot.

The Problem

Currently, ota_user_validate and esp_ota_end verify the file hash and basic structure, but they do not explicitly check the Secure Boot signature block during the USB OTA process. If an unsigned .bin is uploaded to a unit with CONFIG_SECURE_BOOT=y, the UI claims success, but the hardware's bootloader rejects the missing signature on the next boot, causing a silent fallback to the previous slot. This leads to user confusion.

The Solution

In main/process/ota_util.c, this PR introduces a call to esp_image_verify() within ota_finalize (just before esp_ota_set_boot_partition() is called).

If CONFIG_SECURE_BOOT is enabled, this ensures the written partition is fully validated—including the presence of a valid Secure Boot signature—before the UI reports success. If the signature is missing, it immediately throws an "Invalid Firmware" error to the user, preventing the silent rollback loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant