vsCode IDFexstesion error compile littlefs exsample

corso_shiba
Posts: 2
Joined: Thu Jan 18, 2024 11:43 am

vsCode IDFexstesion error compile littlefs exsample

Postby corso_shiba » Thu Jan 18, 2024 12:00 pm

Hi everyone, I'm having trouble compiling the LittleFS example taken from this link
https://github.com/wreyford/demo_esp_littlefs/tree/main
I followed all the guides and precautions

IDF-extension 1.6.5
vcCode 1.85.1
ESP32 module kit
Espressif IDF 5.2

partitions Table:

# Name, Type, SubType, Offset, Size, Flags
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, 0x10000, 1M,
littlefs, data, spiffs, , 0xF0000,
  • [105/106] Generating binary image from built executable
    esptool.py v4.7.0
    Creating esp32 image...
    Merged 2 ELF sections
    Successfully created esp32 image.
    Generated C:/Users/User/Desktop/Proiect_gen/Project_VSCode/demo_esp_littlefs/build/bootloader/bootloader.bin
    [106/106] cmd.exe /C "cd /D C:\Users\User\Desktop\Proiect_gen\Project_VSCode\demo_esp_littlefs\build\bootloader\esp-idf\esptool_py && C:\Espressif\python_env\idf5.2_py3.11_env\Scripts\python.exe C:/Espressif/frameworks/esp-idf-v5.2/components/partition_table/check_sizes.py --offset 0x8000 bootloader 0x1000 C:/Users/User/Desktop/Proiect_gen/Project_VSCode/demo_esp_littlefs/build/bootloader/bootloader.bin"
    Bootloader binary size 0x6850 bytes. 0x7b0 bytes (7%) free.
    [911/926] Building C object esp-idf/esp_littlefs/CMakeFiles/__idf_esp_littlefs.dir/src/littlefs/lfs.c.obj
    ninja: build stopped: subcommand failed.

    * Il processo del terminale "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command ninja " è stato terminato. Codice di uscita: 1.
  1. #include <stdio.h>
  2. #include "sdkconfig.h"
  3. #include "freertos/FreeRTOS.h"
  4. #include "freertos/task.h"
  5. #include "esp_system.h"
  6. #include "esp_spi_flash.h"
  7. #include "esp_err.h"
  8. #include "esp_log.h"
  9.  
  10. #include "esp_littlefs.h"
  11.  
  12. static const char *TAG = "demo_esp_littlefs";
  13.  
  14. void app_main(void)
  15. {
  16.         printf("Demo LittleFs implementation by esp_littlefs!\n");
  17.         printf("   https://github.com/joltwallet/esp_littlefs\n");
  18.  
  19.         /* Print chip information */
  20.         esp_chip_info_t chip_info;
  21.         esp_chip_info(&chip_info);
  22.         printf("This is %s chip with %d CPU cores, WiFi%s%s, ",
  23.                CONFIG_IDF_TARGET,
  24.                chip_info.cores,
  25.                (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
  26.                (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "");
  27.  
  28.         printf("silicon revision %d, ", chip_info.revision);
  29.  
  30.         printf("%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024),
  31.                (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");
  32.  
  33.         printf("Free heap: %d\n", esp_get_free_heap_size());
  34.  
  35.         printf("Now we are starting the LittleFs Demo ...\n");
  36.  
  37.         ESP_LOGI(TAG, "Initializing LittelFS");
  38.  
  39.         esp_vfs_littlefs_conf_t conf = {
  40.             .base_path = "/littlefs",
  41.             .partition_label = "littlefs",
  42.             .format_if_mount_failed = true,
  43.             .dont_mount = false,
  44.         };
  45.  
  46.         // Use settings defined above to initialize and mount LittleFS filesystem.
  47.         // Note: esp_vfs_littlefs_register is an all-in-one convenience function.
  48.         esp_err_t ret = esp_vfs_littlefs_register(&conf);
  49.  
  50.         if (ret != ESP_OK)
  51.         {
  52.                 if (ret == ESP_FAIL)
  53.                 {
  54.                         ESP_LOGE(TAG, "Failed to mount or format filesystem");
  55.                 }
  56.                 else if (ret == ESP_ERR_NOT_FOUND)
  57.                 {
  58.                         ESP_LOGE(TAG, "Failed to find LittleFS partition");
  59.                 }
  60.                 else
  61.                 {
  62.                         ESP_LOGE(TAG, "Failed to initialize LittleFS (%s)", esp_err_to_name(ret));
  63.                 }
  64.                 return;
  65.         }
  66.  
  67.         size_t total = 0, used = 0;
  68.         ret = esp_littlefs_info(conf.partition_label, &total, &used);
  69.         if (ret != ESP_OK)
  70.         {
  71.                 ESP_LOGE(TAG, "Failed to get LittleFS partition information (%s)", esp_err_to_name(ret));
  72.         }
  73.         else
  74.         {
  75.                 ESP_LOGI(TAG, "Partition size: total: %d, used: %d", total, used);
  76.         }
  77.  
  78.         // Use POSIX and C standard library functions to work with files.
  79.         // First create a file.
  80.         ESP_LOGI(TAG, "Opening file");
  81.         FILE *f = fopen("/littlefs/hello.txt", "w");
  82.         if (f == NULL)
  83.         {
  84.                 ESP_LOGE(TAG, "Failed to open file for writing");
  85.                 return;
  86.         }
  87.         fprintf(f, "LittleFS Rocks!\n");
  88.         fclose(f);
  89.         ESP_LOGI(TAG, "File written");
  90.  
  91.         // Check if destination file exists before renaming
  92.         struct stat st;
  93.         if (stat("/littlefs/foo.txt", &st) == 0)
  94.         {
  95.                 // Delete it if it exists
  96.                 unlink("/littlefs/foo.txt");
  97.         }
  98.  
  99.         // Rename original file
  100.         ESP_LOGI(TAG, "Renaming file");
  101.         if (rename("/littlefs/hello.txt", "/littlefs/foo.txt") != 0)
  102.         {
  103.                 ESP_LOGE(TAG, "Rename failed");
  104.                 return;
  105.         }
  106.  
  107.         // Open renamed file for reading
  108.         ESP_LOGI(TAG, "Reading file");
  109.         f = fopen("/littlefs/foo.txt", "r");
  110.         if (f == NULL)
  111.         {
  112.                 ESP_LOGE(TAG, "Failed to open file for reading");
  113.                 return;
  114.         }
  115.         char line[64];
  116.         fgets(line, sizeof(line), f);
  117.         fclose(f);
  118.         // strip newline
  119.         char *pos = strchr(line, '\n');
  120.         if (pos)
  121.         {
  122.                 *pos = '\0';
  123.         }
  124.         ESP_LOGI(TAG, "Read from file: '%s'", line);
  125.  
  126.         // All done, unmount partition and disable LittleFS
  127.         esp_vfs_littlefs_unregister(conf.partition_label);
  128.         ESP_LOGI(TAG, "LittleFS unmounted");
  129. }

corso_shiba
Posts: 2
Joined: Thu Jan 18, 2024 11:43 am

Re: vsCode IDFexstesion error compile littlefs exsample

Postby corso_shiba » Sun Jan 21, 2024 9:58 pm

I have currently solved my problem using the Restful server example.
what I wanted to do was use LittleFS without arduino components. I'm still not sure if that's possible.
what I wanted to do was have html js and css files upload to esp32. I used SPIFFS and now I have what I wanted.
unfortunately SPIFFS is not fast. and it is deprecated. Now I can move forward with the project.

pacucha42
Posts: 31
Joined: Fri Mar 29, 2019 12:56 pm

Re: vsCode IDFexstesion error compile littlefs exsample

Postby pacucha42 » Tue Jan 23, 2024 4:51 pm

Hi @corso_shiba,
for pure LittleFS usage, please check https://github.com/espressif/esp-idf/tr ... e/littlefs (though I understand this is not exactly what you are looking for).
Generally, the best option for file-system choice would be probably FatFS.
Hope this helps.

Who is online

Users browsing this forum: Baidu [Spider] and 120 guests