Flash encryption - flashing pre-encrypted app.bin
Posted: Mon Aug 26, 2019 1:49 pm
Hi,
I think the whole flash encryption topic is describe very detailly in the docs, but there are so much steps to follow to do it right, that it gets quite confusing... After studying the docs for days, I anyway bricked a chip yesterday
Maybe you guys could review my procedure first, before trying it with the next chip?
1. Enabled Flash encryption
(For beginning: No secure boot. I want to enable this in a later step. First get flash-encryption running.)
2. Erase entire flash
3. Clean and build with new config
4. Generate key on local machine
5. Fuse key to device
6. Pre-encryt app.bin with previously generated key.
Please note, that I use a custom partition-table with no factory app and 2 OTA partitions: ota1 @ 0x10000 and ota2 @ 0x110000
7. Flash pre-encrypted app
At that stage, I have my key on device and have ota1 flashed with my pre-encrypted binary.
Is this right?
Is the device now ready to run or is something missing?
Big thanks!
I think the whole flash encryption topic is describe very detailly in the docs, but there are so much steps to follow to do it right, that it gets quite confusing... After studying the docs for days, I anyway bricked a chip yesterday
Maybe you guys could review my procedure first, before trying it with the next chip?
1. Enabled Flash encryption
(For beginning: No secure boot. I want to enable this in a later step. First get flash-encryption running.)
Code: Select all
make menuconfig
Code: Select all
make erase_flash
Code: Select all
make clean + make all
Code: Select all
espsecure.py generate_flash_encryption_key MY_KEY.bin
Code: Select all
espefuse.py --port *COMport" burn_key flash_encryption MY_KEY.bin
Please note, that I use a custom partition-table with no factory app and 2 OTA partitions: ota1 @ 0x10000 and ota2 @ 0x110000
Code: Select all
espsecure.py encrypt_flash_data --keyfile MY_KEY.bin --address 0x10000 -o MY_APP_encrypted.bin *path*/build/MY_APP.bin
Code: Select all
esptool.py --chip esp32 --port *COMport* --baud *baud* --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x10000 MY_APP_encrypted.bin
Is this right?
Is the device now ready to run or is something missing?
Big thanks!