Hi Max,
Thanks for providing a detailed report of what isn't working.
The bug linked on GitHub was an issue introduced in ESP-IDF v4.1 development (regression when we added support for ESP32-S2 Beta), so it shouldn't be a bug in v3.x at all.
I just did a quick test with ESP-IDF v3.3.1 by modifying the SPIFFS example as follows:
Code: Select all
diff --git a/examples/storage/spiffs/main/spiffs_example_main.c b/examples/storage/spiffs/main/spiffs_example_main.c
index 2148139a3f..996d277ca0 100644
--- a/examples/storage/spiffs/main/spiffs_example_main.c
+++ b/examples/storage/spiffs/main/spiffs_example_main.c
@@ -12,6 +12,7 @@
#include <sys/stat.h>
#include "esp_err.h"
#include "esp_log.h"
+#include "esp_partition.h"
#include "esp_spiffs.h"
static const char *TAG = "example";
@@ -96,4 +97,13 @@ void app_main(void)
// All done, unmount partition and disable SPIFFS
esp_vfs_spiffs_unregister(NULL);
ESP_LOGI(TAG, "SPIFFS unmounted");
+
+ uint8_t hash[32] = {0};
+ const esp_partition_t *p = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_SPIFFS, NULL);
+ ESP_ERROR_CHECK( esp_partition_get_sha256(p, hash) );
+ printf("SPIFFS partition hash ");
+ for (int i = 0; i < sizeof(hash); i++) {
+ printf("%02x ", hash[i]);
+ }
+ printf("\n");
}
and it prints the hash OK:
Code: Select all
SPIFFS partition hash 56 b5 de f3 f4 c9 5d 52 ee b3 e6 0d 24 ef d6 14 8f 72 10 a5 e5 ee 30 77 93 ee a3 0f 99 37 e9 b6
Confirmed by reading back the whole partition:
Code: Select all
$ esptool.py -b 921600 read_flash 0x110000 0xf0000 spiffs_readback.bin
[...]
$ sha256sum spiffs_readback.bin
56b5def3f4c95d52eeb3e60d24efd6148f7210a5e5ee307793eea30f9937e9b6 spiffs_readback.bin
I don't immediately see any problem with the code you posted, though.
Would suggest adding some checks: check that _partition pointer is returned with a non-null value, check that _partition->address and _partition->size look correct, and finally check the result of esp_partition_get_sha256 is ESP_OK.
If it turns out this is a bug in ESP-IDF then we will do our best to fix it. v3.3.x is still supported until March 2022 so there is no need to upgrade unless you want to.