Page 1 of 1

Using partition label instead of using NULL for .partition_table in esp_vfs_spiffs_conf_t

Posted: Sat Aug 08, 2020 6:20 am
by Zeni241
I am trying SPIFFS example with “partition label” instead of using NULL for .partition_table in esp_vfs_spiffs_conf_t
My spiffs partion is as below in my partition table:
storage, data, spiffs, , 0x6000,

This is my code:

Code: Select all

const char *part_label="storage";
void files(void)
{
    ESP_LOGI(TAG, "Initializing SPIFFS");
    
    esp_vfs_spiffs_conf_t conf = {
      .base_path = "/spiffs",
      .partition_label =part_label,
      .max_files = 5,
      .format_if_mount_failed = true
    };
    
ret = esp_spiffs_info(NULL, &total, &used);
    if (ret != ESP_OK) {
        ESP_LOGE(TAG, "Failed to get SPIFFS partition information (%s)", esp_err_to_name(ret));
    } else {
        ESP_LOGI(TAG, "Partition Label= %s Partition size: total: %d, used: %d", part_label, total, used);
    }
Though spiffs works OK but I get following:
E (581) example: Failed to get SPIFFS partition information (ESP_ERR_INVALID_STATE)
I (581) example: Opening file
I (601) example: File written
I (601) example: Renaming file
I (611) example: Reading file
I (611) example: Read from file: 'Hello World!'
I (611) example: SPIFFS unmounted


Wonder what I am doing wrong.

Re: Using partition label instead of using NULL for .partition_table in esp_vfs_spiffs_conf_t

Posted: Sat Aug 08, 2020 10:40 am
by chegewara
https://docs.espressif.com/projects/esp ... _tP6size_t
ESP_ERR_INVALID_STATE if not mounted