How to get the offset address of a file created in SPIFFS partition

saicharan67
Posts: 3
Joined: Wed Nov 08, 2023 12:16 pm

How to get the offset address of a file created in SPIFFS partition

Postby saicharan67 » Wed Nov 08, 2023 12:24 pm

Hi all,

I am trying to find the sha256 of a binary file situated at

Code: Select all

/spiffs/temp.bin
using

Code: Select all

bootloader_sha256_flash_contents
but it requires the address of the file offset. Is there any way I can get the address of the file?

Thanks in advance

ESP_adokitkat
Posts: 50
Joined: Thu Jun 22, 2023 12:50 pm

Re: How to get the offset address of a file created in SPIFFS partition

Postby ESP_adokitkat » Wed Nov 08, 2023 9:31 pm

Hello.

The `bootloader_sha256_flash_contents` function is to be used with flash memory and partitions on certain offsets, not with files. There is "mbedtls" component available in esp-idf in which there are functions you can call to get sha256 from a file, i.e. in "mbedtls/sha256.h".

Here is a code example: https://stackoverflow.com/a/63691861

Docs:
https://mbed-tls.readthedocs.io/project ... sha256_8h/
https://docs.espressif.com/projects/esp ... edtls.html

saicharan67
Posts: 3
Joined: Wed Nov 08, 2023 12:16 pm

Re: How to get the offset address of a file created in SPIFFS partition

Postby saicharan67 » Thu Nov 09, 2023 12:27 pm

Hi thanks for the information, i have tried using the mbedtls apis for calculating the hash, but the hash generated for the file using mbedtls apis and hash generated from passing the same file to esp secure script with no signature appending and no padding are different.

Any insights what might be the case here?

Who is online

Users browsing this forum: No registered users and 88 guests