[solved] LittleFS errors when running from VC Code

Hi,

I am using all this time arduino ide to write code.
Yesterday I decided to test VS CODE (PlatformIO).
I imported my arduino code, i had to re install the libraries to PlatformIO etc.

I have esp32-devkitc v4 but on PlatformIO theres only the v1(DOIT ESP32 DEVKIT V1) and thats what i choosed..

When i try to build my project(already builds successfully in arduino ide) I get errors about LittleFS:

.pio\libdeps\esp32doit-devkit-v1\LittleFS_esp32\src\esp_littlefs.c: In function 'esp_vfs_littlefs_register':
.pio\libdeps\esp32doit-devkit-v1\LittleFS_esp32\src\esp_littlefs.c:208:9: error: unknown field 'utime_p' specified in initializer
         .utime_p     = &vfs_littlefs_utime,
         ^
.pio\libdeps\esp32doit-devkit-v1\LittleFS_esp32\src\esp_littlefs.c:208:24: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
         .utime_p     = &vfs_littlefs_utime,
                        ^
.pio\libdeps\esp32doit-devkit-v1\LittleFS_esp32\src\esp_littlefs.c:208:24: note: (near initialization for 'vfs.<anonymous>.access_p')
.pio\libdeps\esp32doit-devkit-v1\LittleFS_esp32\src\esp_littlefs.c:179:27: warning: missing braces around initializer [-Wmissing-braces]
     const esp_vfs_t vfs = {
                           ^
.pio\libdeps\esp32doit-devkit-v1\LittleFS_esp32\src\esp_littlefs.c:179:27: note: (near initialization for 'vfs')
*** [.pio\build\esp32doit-devkit-v1\lib7e8\LittleFS_esp32\esp_littlefs.c.o] Error 1

================================================================================================== [FAILED] Took 6.11 seconds ==================================================================================================
The terminal process "C:\Users\CT\.platformio\penv\Scripts\pio.exe 'run', '--environment', 'esp32doit-devkit-v1'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

An other error also (not during compiling):

Please post your code. Without it providing help, especially compiling it on PlatformIO is difficult

UKHeliBob:
Please post your code. Without it providing help, especially compiling it on PlatformIO is difficult

hi thanks for your reply. I tried a clean project without anything, just the library but it cannot compile library at all

Edit:
Empty project with only littleFS installed on the project(not even included littlefs.. just added it on the project from libraries menu of PlatformIO) and it wont compile:

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32doit-devkit-v1.html
PLATFORM: Espressif 32 (2.1.0) > DOIT ESP32 DEVKIT V1
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 3.10004.201016 (1.0.4)
 - tool-esptoolpy 1.30000.201119 (3.0.0)
 - toolchain-xtensa32 2.50200.80 (5.2.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 27 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <LittleFS_esp32> 1.0.5
Building in release mode
Compiling .pio\build\esp32doit-devkit-v1\src\main.cpp.o
Generating partitions .pio\build\esp32doit-devkit-v1\partitions.bin
Compiling .pio\build\esp32doit-devkit-v1\libc6f\LittleFS_esp32\LITTLEFS.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\libc6f\LittleFS_esp32\esp_littlefs.c.o
.pio\libdeps\esp32doit-devkit-v1\LittleFS_esp32\src\LITTLEFS.cpp:17:21: fatal error: vfs_api.h: No such file or directory

*****************************************************************
* Looking for vfs_api.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:vfs_api.h"
* Web  > https://platformio.org/lib/search?query=header:vfs_api.h
*
*****************************************************************

compilation terminated.
.pio\libdeps\esp32doit-devkit-v1\LittleFS_esp32\src\esp_littlefs.c: In function 'esp_vfs_littlefs_register':
.pio\libdeps\esp32doit-devkit-v1\LittleFS_esp32\src\esp_littlefs.c:208:9: error: unknown field 'utime_p' specified in initializer
         .utime_p     = &vfs_littlefs_utime,
         ^
.pio\libdeps\esp32doit-devkit-v1\LittleFS_esp32\src\esp_littlefs.c:208:24: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
         .utime_p     = &vfs_littlefs_utime,
                        ^
.pio\libdeps\esp32doit-devkit-v1\LittleFS_esp32\src\esp_littlefs.c:208:24: note: (near initialization for 'vfs.<anonymous>.access_p')
.pio\libdeps\esp32doit-devkit-v1\LittleFS_esp32\src\esp_littlefs.c:179:27: warning: missing braces around initializer [-Wmissing-braces]
     const esp_vfs_t vfs = {
                           ^
.pio\libdeps\esp32doit-devkit-v1\LittleFS_esp32\src\esp_littlefs.c:179:27: note: (near initialization for 'vfs')
Compiling .pio\build\esp32doit-devkit-v1\libc6f\LittleFS_esp32\lfs.c.o
*** [.pio\build\esp32doit-devkit-v1\libc6f\LittleFS_esp32\esp_littlefs.c.o] Error 1
*** [.pio\build\esp32doit-devkit-v1\libc6f\LittleFS_esp32\LITTLEFS.cpp.o] Error 1
================================================================================================== [FAILED] Took 5.41 seconds ==================================================================================================
The terminal process "C:\Users\CT\.platformio\penv\Scripts\pio.exe 'run', '--environment', 'esp32doit-devkit-v1'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

main problem i think:

SIGH !

Post your code so that it can be copied, examined and compiled
A small but complete example is good enough

No code = no help as far as I am concerned

I would suspect that with the ESP32 LittleFS being kinda new that your other development IDE may not have been upgraded yet? Of course, this is an Arduino site. Why not try the site for the other IDE and see what's the not there?

If you insist on the code here it is (im not being sarcastic, as i said its nothing inside..it will just not compile) as long as littlefs is added on the project as library:

#include <Arduino.h>
#include "FS.h"
#include "LITTLEFS.h"

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
}

And this is how the "wizard" in platformio adds the library on the project:

lib_deps = lorol/LittleFS_esp32@^1.0.5

The above line is added automatically on platformio.ini when installing the library

Idahowalker:
I would suspect that with the ESP32 LittleFS being kinda new that your other development IDE may not have been upgraded yet? Of course, this is an Arduino site. Why not try the site for the other IDE and see what's the not there?

Sure, but this is also arduino code and libraries and everything, just different environment :slight_smile: Some people might write code for arduino on a notepad (i do edit sometimes files on a notepad.. that does not mean its not arduino or arduino related) :slight_smile:

Error seems to be on this file esp_littlefs.c

line 207-209:

#if CONFIG_LITTLEFS_USE_MTIME
        .utime_p     = &vfs_littlefs_utime,
#else

.pio\libdeps\az-delivery-devkit-v4\LittleFS_esp32\src\esp_littlefs.c:208:9: error: unknown field 'utime_p' specified in initializer

(dodgy) Solution:
file: esp_littlefs.c
comment out line 208 .utime_p = &vfs_littlefs_utime,
comment out line 210 .utime_p = NULL,

I read some files and it seems to work fine. havent tested to create,append etc.

Removing the lines that cause the errors (I get the same errors by the way), is one way of solving the problem but it would, of course, be better to have the problem fixed properly

By the way, it compiles OK if the board is set to be an ESP8266

thanks, it seems to work by taking out those lines on ESP32, i hope someone might find this post helpful

A little experimentation has shown that if you copy the LittleFS library files from the Arduino IDE LittleFS library folder into the PlatformIO src folder where the main.cpp is located then sketches using LittleFS appear to compile and work, at least as far as I have tested it. I have not tested with the files in the lib folder where they belong

So the fault appears to be with the version of the LittleFS library installed by PlatformIO

UKHeliBob:
A little experimentation has shown that if you copy the LittleFS library files from the Arduino IDE LittleFS library folder into the PlatformIO src folder where the main.cpp is located then sketches using LittleFS appear to compile and work, at least as far as I have tested it. I have not tested with the files in the lib folder where they belong

So the fault appears to be with the version of the LittleFS library installed by PlatformIO

I was able to get a successful compile by replacing the libdeps....\LittleFS_esp32\src\ files with those in the zip file from LittleFS_esp32 - Arduino Libraries. Seems like the GitHub - lorol/LITTLEFS: LittleFS library for arduino-esp32 resposity is different to the zip files. I've not done a forensic comparison of the esp_littlefs.c files, and have only confirmed a successful compile.

Hope this helps others as the above post had helped point me in the right direction.