Secure boot and flash encrytion in developmentmode using host generated key and ota issue

jerryc
Posts: 2
Joined: Fri Apr 11, 2025 3:53 am

Secure boot and flash encrytion in developmentmode using host generated key and ota issue

Postby jerryc » Fri Apr 11, 2025 6:51 am

esp 32e wroom
idf 5.4.0
Windows
VS Code

the flash steps :
------------------------------------------------------

Code: Select all

`espsecure.py generate_flash_encryption_key key.bin

Enable flash encryption on boot (READ DOCS FIRST)

Enable usage mode - development

Enable hardware Secure Boot in bootloader
boot version
Select secure boot version - 1
Secure bootloader mode - refreshable

Offset of partition table - 0xd000

Partition Table - custom partition table csv

Name ,Type,SubType,Offset,Size,Flags
nvs, data, nvs, 0xE000, 0x4000,
otadata, data, ota, 0x12000, 0x2000,
phy_int, data, phy, 0x14000, 0x1000,
ota_0, app, ota_0, 0x20000, 0x1A0000,
ota_1, app, ota_1, 0x1C0000,0x1A0000

disable NVS encryption

espsecure.py generate_signing_key secure_boot_signing_key.pem --version 1 --scheme ecdsa256

build

espsecure.py encrypt_flash_data --keyfile key.bin --address 0x1000 -o key_bootloader.bin build/bootloader/bootloader.bin
espsecure.py encrypt_flash_data --keyfile key.bin --address 0xd000 -o key_partition-table.bin build/partition_table/partition-table.bin
espsecure.py encrypt_flash_data --keyfile key.bin --address 0x20000 -o key_myapp.bin build/myapp.bin

espefuse.py --port COM10 burn_key flash_encryption key.bin

espefuse.py --port COM10 burn_efuse FLASH_CRYPT_CONFIG 0xF FLASH_CRYPT_CNT 1

esptool.py -b 460800 --before default_reset --after no_reset --chip esp32 write_flash --flash_mode dio --flash_size detect --flash_freq 40m 0x1000 key_bootloader.bin 0xd000 key_partition-table.bin 0x20000 key_myapp.bin`
------------------------------------------------------

aftet doing these, it works on esp32.

But when i try to use the code in simple_ota_example to ota the key_myapp.bin, error shows ’Mismatch chip id, expected 0, found 16916‘. (ota works when i didn't enable flash encryption and boot security)

I try to use 'espsecure.py encrypt_flash_data --keyfile key.bin --address 0x1C0000 -o key_myapp.bin build/myapp.bin', also fails.

So can i ota an encrypted bin using host generated key? How can i do? Thanks for your help!

Who is online

Users browsing this forum: No registered users and 1 guest