VSCode ESP-IDF Framework esp32 SPIFFS-Fehler

Ich versuche seit Tagen und Tagen, SPIFFS auf meinem esp32-Board mit PlatformIO in VSCode nach dem folgenden Beispiel zum Laufen zu bringen: https://github.com/espressif/esp-idf/tree/master/examples/storage/spiffs aber ich kann es nicht einfach zum Laufen bringen. Wenn ich das Arduino-Framework verwende, wird die Partition ohne Probleme gemountet, aber wenn ich versuche, es mit dem ESP-IDF-Framework zu tun, wird es weder die Partition erstellen noch den Flash-Speicher neu formatieren, wenn die gesuchte Partition nicht gefunden wird.

die logs sind wie folgt:

I (28) boot: ESP-IDF 3.30300.190916 2nd stage bootloader
I (29) boot: compile time 23:32:31
I (37) boot: Enabling RNG early entropy source…
I (37) boot: SPI Speed : 40MHz
I (38) boot: SPI Mode : DIO
I (42) boot: SPI Flash Size : 4MB
I (46) boot: Partition Table:
I (50) boot: ## Label Usage Type ST Offset Length
I (57) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (64) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (72) boot: 2 factory factory app 00 00 00010000 00100000
I (79) boot: End of partition table
I (83) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x08e64 ( 36452) map
I (105) esp_image: segment 1: paddr=0x00018e8c vaddr=0x3ffbdb60 size=0x01ec4 ( 7876) load
I (108) esp_image: segment 2: paddr=0x0001ad58 vaddr=0x40080000 size=0x00400 ( 1024) load
I (113) esp_image: segment 3: paddr=0x0001b160 vaddr=0x40080400 size=0x04eb0 ( 20144) load
I (129) esp_image: segment 4: paddr=0x00020018 vaddr=0x400d0018 size=0x19444 (103492) map
I (165) esp_image: segment 5: paddr=0x00039464 vaddr=0x400852b0 size=0x033cc ( 13260) load
I (176) boot: Loaded app from partition at offset 0x10000
I (176) boot: Disabling RNG early entropy source…
I (177) cpu_start: Pro cpu up.
I (180) cpu_start: Application information:
I (185) cpu_start: Project name: vetable
I (190) cpu_start: App version: 1.0.0
I (195) cpu_start: Compile time: Nov 28 2019 23:32:36
I (201) cpu_start: ELF file SHA256: 0000000000000000…
I (207) cpu_start: ESP-IDF: 3.30300.190916
I (213) cpu_start: Starting app cpu, entry point is 0x40081e0c
I (0) cpu_start: App cpu up.
I (223) heap_init: Initializing. RAM available for dynamic allocation:
I (230) heap_init: At 3FFAE6E0 len 0000F480 (61 KiB): DRAM
I (236) heap_init: At 3FFC0A80 len 0001F580 (125 KiB): DRAM
I (242) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (249) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (255) heap_init: At 4008867C len 00017984 (94 KiB): IRAM
I (261) cpu_start: Pro cpu start user code
I (280) cpu_start: Chip Revision: 1
W (280) cpu_start: Chip revision is higher than the one configured in menuconfig. Suggest to upgrade it.
I (283) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (294) SPIFFS:

Initializing SPIFFS
E (304) SPIFFS: spiffs partition could not be found
E (304) SPIFFS: Failed to find SPIFFS partition

und mein code ist folgender:

//standar freeRTOS
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_spi_flash.h"
#include "driver/gpio.h"
#include "sdkconfig.h"
#include "freertos/queue.h"

//spiffs
#include <string.h>
#include <sys/unistd.h>
#include <sys/stat.h>
#include "esp_err.h"
#include "esp_log.h"
#include "esp_spiffs.h"
#include "spiffs_config.h"



//----------SPIFFS SETUP-----------//
void vfsSetup(){
    ESP_LOGI(TAG, "\n\nInitializing SPIFFS");

    esp_vfs_spiffs_conf_t conf = {
    .base_path = "/vetable",
    .partition_label = NULL,
    .max_files = 5,
    .format_if_mount_failed = true
    };

    // Use settings defined above to initialize and mount SPIFFS filesystem.
    // Note: esp_vfs_spiffs_register is an all-in-one convenience function.
    esp_err_t ret = esp_vfs_spiffs_register(&conf);

    if (ret != ESP_OK) {
        if (ret == ESP_FAIL) {
            ESP_LOGE(TAG, "Failed to mount or format filesystem");
        } else if (ret == ESP_ERR_NOT_FOUND) {
            ESP_LOGE(TAG, "Failed to find SPIFFS partition");
        } else {
            ESP_LOGE(TAG, "Failed to initialize SPIFFS (%s)", esp_err_to_name(ret));
        }
        return;
    }


    vTaskDelay(100/portTICK_PERIOD_MS);

    size_t total = 0, used = 0;
    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 size: total: %d, used: %d", total, used);
    }

};



//----------MAIN----------//
void app_main(void){
   vfsSetup();
   return;
}

Das Folgende ist meine platformio.ini-Datei:

;PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = espidf
monitor_speed = 115200
Um SPIFFS verwenden zu können, müssen Sie den Flash-Speicher so partitionieren, dass Speicherplatz für SPIFFS zugewiesen wird? Welche Partitionierung verwendest du? Bitte zeigen Sie die platformio.iniDatei. Siehe auch: docs.platformio.org/en/latest/platforms/…
@Codo Ich glaube, du hast völlig Recht, das war mein Hauptverdächtiger. Meine Frage wäre jetzt, in VSCode, wo in meinem Projekt müsste ich meine Partitionstabelle ablegen?
Ich denke, Sie haben Ihre Antwort inzwischen erhalten: community.platformio.org/t/…

Antworten (2)

Ich habe eine Antwort auf dieses Problem gefunden, wie im folgenden Thread angegeben: https://community.platformio.org/t/vscode-esp-idf-framework-esp32-spiffs-error/10817 .

Das Problem war im Grunde, dass ich versuchte, auf eine Partition zuzugreifen, die in meiner Partitionstabelle nie existierte. Ich habe die CSV-Datei aus dem Beispiel heruntergeladen und im Stammverzeichnis abgelegt (wo sich die Datei „platformio.ini“ befindet). Dann konnte ich auf die „spiffs“-Partition zugreifen, um Daten zu speichern

Definieren Sie die Partitionstabelle in der platform.ini wie folgt:

board_build.partitions = custom_16MB.csv

Inside-Datei ist so etwas wie:

Name, Type, SubType, Offset, Size, Flags

nvs, data, nvs, 0x9000, 0x5000,

otadata, data, ota, 0xe000, 0x2000,

app0, app, ota_0, , 0x640000,

app1, app, ota_1, , 0x640000,

spiffs, data, spiffs, , 0x370000,

Dies ist meine Partitionstabelle für 16 MB ESP32.

So definieren Sie benutzerdefinierte Partitionstabellen:

https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/partition-tables.html