0

I have configure my esp32 s3 project by using "idf.py menuconfig" and I have set they parameters as below :

Security features ->
                  Enable flash encryption on boot ->
                                               ```
                                               Size of generated AES-XTS key (AES-128 (256-bit key))
                                               Enable usage mode (Release)
                                               ```
Partition Table ->
                (0x10000) Offset of partition table

Then, after building my project "idf.py build", I have burn my key for encryption by using the command below :

    espsecure.py generate_flash_encryption_key my_flash_encryption_key.bin
    espefuse.py --port PORT burn_key BLOCK_KEY0 my_flash_encryption_key.bin XTS_AES_128_KEY

Finally, I have flash the project (idf.py flash) and the program work well.

But now I need to modify my project flash again. The problem is that the monitor send me the data below : "invalid header: 0xdffde09a"

So I thing that I have forget something during my process to reflash my device.

You can see below, theirs commands used:

    espsecure.py encrypt_flash_data --aes_xts --keyfile /path/to/key.bin --address 0x10000 --output my-app-ciphertext.bin build/my-app.bin
    esptool.py --chip esp32s3 --port /dev/ttyUSB0 --baud 460800 write_flash 0x10000 my-app-ciphertext.bin
Tarmo
  • 3,728
  • 1
  • 8
  • 25
Stimm4
  • 13
  • 3

1 Answers1

0

After enabling the Release Mode of Flash encryption you cannot flash this device anymore. That's the whole purpose of it.

If your firmware has a built-it OTA client with flash encryption support, feel free to use this. Otherwise this board is now un-changeable.

Tarmo
  • 3,728
  • 1
  • 8
  • 25
  • Thank you, So when a company, developt a product, using an esp32 which doesn't have antenna (no OTA available), but for the SAV, this company need to update this device, How this company could do this ? – Stimm4 Nov 24 '22 at 10:43
  • You can build your own firmware update solution without wireless protocols, e.g. through UART or SD card or however, If you look at Espressif's [OTA API documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/ota.html) it doesn't mention _how_ the image is transferred, only how it's written into Flash. You're free to implement your own channel, your own verification etc. Flash encryption disables the UART bootloader which is the "god mode" update tool, so you can replace it with your own, secure solution. – Tarmo Nov 24 '22 at 11:08
  • Thank you a lot, So could you precise me the difference between the UART/ROM Download Mode enable and Permanently switch to Secure mode (recommended)? – Stimm4 Dec 01 '22 at 17:10
  • The difference is whether the ROM bootloader is enabled or disabled, so respectively you can or cannot read/write Flash using it. – Tarmo Dec 01 '22 at 20:45