[RP2040] LittleFS showing file successfully uploaded but files cannot be read

Hi,

I’m trying to use LittleFS to write some data to my YD-RP2040(16MB). But even though the log seems showing success

Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: https://docs.platformio.org/page/boards/raspberrypi/vccgnd_yd_rp2040.html
PLATFORM: Raspberry Pi RP2040 (1.14.0+sha.19e3012) > YD RP2040
HARDWARE: RP2040 133MHz, 256KB RAM, 16MB Flash
DEBUG: Current (picoprobe) External (blackmagic, cmsis-dap, jlink, picoprobe, raspberrypi-swd)
PACKAGES:

  • framework-arduinopico @ 1.40201.0+sha.e25d382
  • tool-mklittlefs-rp2040-earlephilhower @ 5.100300.230216 (10.3.0)
  • tool-picotool-rp2040-earlephilhower @ 5.140200.240929 (14.2.0)
  • toolchain-rp2040-earlephilhower @ 5.140200.240929 (14.2.0)
    Flash size: 16.00MB
    Sketch size: 15.00MB
    Filesystem size: 1.00MB
    PSRAM size: 0.00MB
    Maximium Sketch size: 15724544 EEPROM start: 0x10fff000 Filesystem start: 0x10eff000 Filesystem end: 0x10fff000
    LDF: Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
    LDF Modes: Finder ~ deep, Compatibility ~ soft
    Found 73 compatible libraries
    Scanning dependencies…
    Dependency Graph
    |-- TFT_eSPI @ 2.5.34
    |-- lvgl @ 8.4.0
    |-- LittleFS @ 0.1.0
    Building in release mode
    Flash size: 16.00MB
    Sketch size: 15.00MB
    Filesystem size: 1.00MB
    PSRAM size: 0.00MB
    Maximium Sketch size: 15724544 EEPROM start: 0x10fff000 Filesystem start: 0x10eff000 Filesystem end: 0x10fff000
    Building file system image from ‘data’ directory to .pio\build\ydrp2040\littlefs.bin
    /test2.txt

But I can’t see any files on the flash. This is my platform.ini:

[env:ydrp2040]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = vccgnd_yd_rp2040
framework = arduino
board_build.core = earlephilhower
board_build.mcu = rp2040
board_build.filesystem_size = 1m
monitor_speed = 115200
upload_protocol = mbed
debug_tool = picoprobe

lib_ldf_mode = deep
lib_deps = 
    bodmer/TFT_eSPI@2.5.34
    lvgl/lvgl@8.4.0

build_flags =
    -D PICO_CYW43_SUPPORTED=0
    -D CYW43_PIN_WL_DYNAMIC=0
    -D USE_TINYUSB

And this is the code I used to print all files on LittleFS:

#include <LittleFS.h>

void listDir(const char *dirname, uint8_t levels);

void setup() {
  Serial.begin(115200);
  
  if (!LittleFS.begin()) {
    Serial.println("LittleFS Mount Failed");
    return;
  }
  Serial.println("LittleFS Mounted Successfully");
}

void loop() {
  listDir("/", 0);
}

// Function to list files and directories in LittleFS
void listDir(const char *dirname, uint8_t levels) {
  Serial.println("Listing files...");

  File root = LittleFS.open(dirname, "r");
  if (!root) {
    Serial.println("Failed to open directory");
    return;
  }

  // Read and list files
  File entry = root.openNextFile();
  while (entry) {
    if (entry.isDirectory()) {
      Serial.print("DIR : ");
      Serial.println(entry.name());
      if (levels) {
        listDir(entry.name(), levels - 1);
      }
    } else {
      Serial.print("FILE: ");
      Serial.print(entry.name());
      Serial.print("  SIZE: ");
      Serial.println(entry.size());
    }
    entry = root.openNextFile();
  }
}

Somehow it doesn’t print any files in the root directory, can someone give me guidance on how to setup and upload files to RP2040 with LittleFS?

Thank you in advance!

I don’t think a filesystem can be uploaded using the mbed / uf2 upload method… Can you remove that line?

Then use the project task “Upload Filesystem” again.

1 Like

Thank you, that is the issue.

After remove it and make sure I have the correct driver using Zadig. I can read my file :slight_smile: