LittleFS download created data files

I am trying to do a data logger. My simplistic view was that if I used a Pico, then I could connect it back to a Windows or Linux machine and download the contents of the LittleFS which would be the data that I logged . I saw tools that would upload data to the Pico and assumed that a similar download or extract must also be easy to do. However, now that I get to that part of the project, I don’t see such a tool.
Is there a tool for downloading the contents of a LittleFS that already exists on the microcontroller like the Pico?
If there is not such a tool, is there a recommended way to get the data out serially?
Thanks.

This is very similiar to what’s discussed in Download or view esp8266 file system for ESP8266/ESP32.

Basically, if you want to extract the LittleFS filesystem content from the Pico without there being functionality programmed in your sketch to print it out, you can use the technique of downloading the flash content (or just the part where the filesystem would be, the address is visible in the build log) into a binary file using download tools like picotool or openocd and then run the mklittlefs tool in unpack mode (--unpack) with the right parameters (such as the block and page size used in the initial LittleFS configuration).

So yeah that path is not yet implemented in an automated, “one button click” way. But I see why that would be usefull and I’ll look into adding it. What it’ll come down to in the end is just running something like

picotool save --range 0x101ff000 0x1027f000 littlefs.bin 
mklittlefs -b 4096 -p 256 --unpack "extracted_files" "littlefs.bin"

(addresses depending on the flash size and chosen filesystem size per platformio.ini of course)

Of course, this doesn’t stop you from programming a readout functionality into your firmware. Your firmware could e.g. react to a special serial command and it’ll do the whole LittleFS.open(), .read(), etc., like shown in the official examples

Thank you very much. I got it to work. For those perhaps as clueless as me, the picotool and mklittlefs are not in my path from Visual Studio Code or Platformio. Therefore, I could not call these directly from the terminal window within VS Code. Very likely it is either not supposed to be there or I have something configured wrong. I found the executable files under the .platformio\packages tree in the User folder in Windows 10. I copied these executables out to a working folder as a temporary fix. I executed them using Windows PowerShell. Under Windows 10, picotool will probably fail with a message like “Device at bus 1, address 7 appears to be a RP2040 device in BOOTSEL mode, but picotool was unable to connect” That is due to the Windows driver being used. Follow the link below to fix the driver with Zadig.

https://forums.raspberrypi.com/viewtopic.php?t=321116

After doing the above, I have downloaded a binary blob of the LittleFS and extracted the binary data file that I saved. For my application, I can just write a script to automate those two commands as the file name , the LittleFS size and location will be fixed.
Thanks again.

While the binares are not directly in the path, that’s what the pio pkg exec command is for, e.g.

pio pkg exec -p "tool-rp2040tools" --call "picotool --info"

But yeah instead of creating a shell script to call that the right way to integrate it into PlatformIO is the same as demonstrated in the linked ESP8266/32 filesystem downloader: To use the “Create a new project task” API that just gives the user a one-click button for extraction in VSCode. That’s what I’m looking into adding for platform-raspberrypi.