-
Notifications
You must be signed in to change notification settings - Fork 852
Open
Labels
area: espressifAffects the Espressif portAffects the Espressif port
Description
I was following this documentation. After a few hours, I have now just given up making this work.
I have added this fragment to my build config:
CONFIG_SECURE_BOOT=1
CONFIG_SECURE_BOOT_V2_ENABLED=1
CONFIG_SECURE_SIGNED_ON_BOOT=1
CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME=1
CONFIG_SECURE_BOOT_SUPPORTS_RSA=1
I then generated a signing key with the espsecure tool:
espsecure generate_signing_key --version 2 bootloader_key.pemI use this to sign the resulting binary:
espsecure sign_data --version 2 --keyfile bootloader_key.pem -a -o mcuboot.signed.bin build/mcuboot_esp32c3.binFrom here I flash the system:
esptool flash_erase
esptool --chip auto --baud 921600 --before default-reset --after hard-reset write-flash -u --flash-mode dio --flash-freq 80m --flash-size 4MB 0x0 mcuboot.signed.binThis results in the following output:
[esp32c3] [INF] *** Booting MCUboot build v2.3.0-rc1-1-gd319cbc6 ***
[esp32c3] [INF] [boot] chip revision: v0.4
[esp32c3] [INF] [boot.esp32c3] SPI Speed : 80MHz
[esp32c3] [INF] [boot.esp32c3] SPI Mode : DIO
[esp32c3] [INF] [boot.esp32c3] SPI Flash Size : 4MB
[esp32c3] [INF] [boot] Enabling RNG early entropy source...
[esp32c3] [INF] enabling secure boot v2...
[esp32c3] [INF] [efuse] Batch mode of writing fields is enabled
[esp32c3] [INF] [esp_image] segment 0: paddr=00000020 vaddr=3fcdac00 size=03410h ( 13328)
[esp32c3] [INF] [esp_image] segment 1: paddr=00003438 vaddr=403c7000 size=05b84h ( 23428)
[esp32c3] [INF] [esp_image] segment 2: paddr=00008fc4 vaddr=403d0000 size=0446ch ( 17516)
[esp32c3] [INF] [esp_image] Verifying image signature...
[esp32c3] [INF] [secure_boot_v2] Secure boot V2 is not enabled yet and eFuse digest keys are not set
[esp32c3] [INF] [secure_boot_v2] Verifying with RSA-PSS...
Sig block 0 invalid: Image digest does not match
[esp32c3] [ERR] [secure_boot_v2] Secure Boot V2 verification failed.
[esp32c3] [ERR] [esp_image] Secure boot signature verification failed
[esp32c3] [INF] [esp_image] Calculating simple hash to check for corruption...
[esp32c3] [WRN] [esp_image] image valid, signature bad
[esp32c3] [ERR] [secure_boot_v2] bootloader image appears invalid! error 8194
[esp32c3] [INF] [efuse] Batch mode of writing fields is cancelled
Dumping the image via esptool to a binary file and the using espsecure works though:
$> espsecure verify-signature -k bootloader_key.pem -v 2 flash_dump.bin
espsecure v5.1.0
Signature block 0 is valid (RSA).
Signature block 0 verification successful using the supplied key (RSA).
Signature block 1 invalid. Skipping.
Signature block 2 invalid. Skipping.
I checked the actual code, and I feel it should work, the only guess I have left is that there is some virtual size-limitation that I am unaware of, and actually the signature is not fully loaded? I am aware of the 64K limit.
$> du -h mcuboot.signed.bin
56K mcuboot.signed.binPointers would be much appreciated, maybe my next step would be trying to find deeper information from espressif.
Metadata
Metadata
Assignees
Labels
area: espressifAffects the Espressif portAffects the Espressif port