How to enable SHA256 in image footer

maxvandenbussche
Posts: 2
Joined: Sun Jul 12, 2020 8:27 am

How to enable SHA256 in image footer

Postby maxvandenbussche » Tue Sep 26, 2023 8:31 am

We have used the SHA256 that was appended at the end of the binary file to verify integrity when uploading the file to the our backend for OTA to client ESP32 devices. Suddenly the ESP-IDF stopped generating these checksums and I have no idea why and how to enable them again.

For reference this is a new binary generated:

Code: Select all

max@max-linuxbox:~/Code/mtappro-app$ esptool.py image_info --version 2 ./build/MTapPro.bin
esptool.py v4.7.dev1
File size: 1794176 (bytes)
Detected image type: ESP32-C3

ESP32-C3 image header
=====================
Image version: 1
Entry point: 0x40380430
Segments: 5
Flash size: 4MB
Flash freq: 80m
Flash mode: DIO

ESP32-C3 extended image header
==============================
WP pin: 0xee (disabled)
Flash pins drive settings: clk_drv: 0x0, q_drv: 0x0, d_drv: 0x0, cs0_drv: 0x0, hd_drv: 0x0, wp_drv: 0x0
Chip ID: 5 (ESP32-C3)
Minimal chip revision: v0.3, (legacy min_rev = 3)
Maximal chip revision: v0.99

Segments information
====================
Segment  Length   Load addr   File offs  Memory types
-------  -------  ----------  ----------  ------------
      1  0x50f08  0x3c150020  0x00000018  DROM
      2  0x032c4  0x3fc96c00  0x00050f28  DRAM, BYTE_ACCESSIBLE
      3  0x0be1c  0x40380000  0x000541f4  IRAM
      4  0x14b2c8  0x42000020  0x00060018  IROM
      5  0x0ad84  0x4038be1c  0x001ab2e8  IRAM

ESP32-C3 image footer
=====================
Checksum: 0x76 (valid)

Application information
=======================
Project name: MTapPro
App version: 0.0.17-dirty
Compile time: Sep 26 2023 10:21:56
ELF file SHA256: 0ea901793494fd713023d898f4ef7d22d3d05898ce7446565f9bd77309142531
ESP-IDF: v5.1.1
Secure version: 0
And this was a previous binary already on the backend server:

Code: Select all

max@max-linuxbox:~/Code/mtappro-app$ esptool.py image_info --version 2 ~/Downloads/a4e23936-7ac3-4561-aa09-431edec14a00 
esptool.py v4.7.dev1
File size: 1794176 (bytes)
Detected image type: ESP32-C3

ESP32-C3 image header
=====================
Image version: 1
Entry point: 0x40380430
Segments: 5
Flash size: 4MB
Flash freq: 80m
Flash mode: DIO

ESP32-C3 extended image header
==============================
WP pin: 0xee (disabled)
Flash pins drive settings: clk_drv: 0x0, q_drv: 0x0, d_drv: 0x0, cs0_drv: 0x0, hd_drv: 0x0, wp_drv: 0x0
Chip ID: 5 (ESP32-C3)
Minimal chip revision: v0.3, (legacy min_rev = 3)
Maximal chip revision: v0.99

Segments information
====================
Segment   Length   Load addr   File offs  Memory types
-------  -------  ----------  ----------  ------------
      1  0x50f48  0x3c150020  0x00000018  DROM
      2  0x032c4  0x3fc96c00  0x00050f68  DRAM, BYTE_ACCESSIBLE
      3  0x0bddc  0x40380000  0x00054234  IRAM
      4  0x14b26c  0x42000020  0x00060018  IROM
      5  0x0adc4  0x4038bddc  0x001ab28c  IRAM

ESP32-C3 image footer
=====================
Checksum: 0xed (valid)
Validation hash: 3eddca940cb8401dddbab3a2413bead6ecb16751bc95ee66c65d14896d2facbb (valid)

Application information
=======================
Project name: MTapPro
App version: 0.0.13
Compile time: Aug 29 2023 15:07:03
ELF file SHA256: 4955c31c7a8ae43a16f0873c42151f833e57471d196def7c2503751a9cbd7536
ESP-IDF: v5.1.1
Secure version: 0
Does anyone have any idea how to get the ESP-IDF to generate this SHA256 validation hash again in the image footer?

Best regards,
Max

ESP_Mahavir
Posts: 190
Joined: Wed Jan 24, 2018 6:51 am

Re: How to enable SHA256 in image footer

Postby ESP_Mahavir » Wed Sep 27, 2023 6:35 am

Hello,

Any chance you have enabled `CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE` config option? If yes, then it would disable appending the SHA256 checksum to the image.

Please see the migration guide section regarding this: https://docs.espressif.com/projects/esp ... ml#esptool

HTH!

Who is online

Users browsing this forum: No registered users and 69 guests