LittleFS_Mbed_RP2040
LittleFS_Mbed_RP2040 copied to clipboard
Wrapper of LittleFS for Arduino MBED RP2040 boards. This library facilitates your usage of LittleFS for the onboard flash. LittleFS supports power fail safety and high performance
LittleFS_Mbed_RP2040 Library
Table of Contents
- Important Notes
- Why do we need this LittleFS_Mbed_RP2040 library
- Features
- Currently supported Boards
- Changelog
- Prerequisites
- Installation
- Use Arduino Library Manager
- Manual Install
- VS Code & PlatformIO
- Examples
- 1. LittleFS_Counting
- 2. LittleFS_Test
- Example LittleFS_Test
- Debug Terminal Output Samples
- 1. LittleFS_Counting on RaspberryPi Pico
- 2. LittleFS_Test on RaspberryPi Pico
- Debug
- Troubleshooting
- Issues
- TO DO
- DONE
- Contributions and Thanks
- Contributing
- License
- Copyright
Important Notes
The LittleFS of the new Nano_RP2040_Connect board (see picture below), using ISSI Flash chip, is currently not working with Arduino mbed_rp2040 core 2.4.1+. Please downgrade to Arduino mbed_rp2040 core 2.3.1
Check RP2040 Connect board has faulty components in newest purchase #318 for more information of when and how the issue will be fixed.
The old board (see picture below), using Adesto Flash chip, is currently working with Arduino mbed_rp2040 core 2.4.1+.
Why do we need this LittleFS_Mbed_RP2040 library
Features
This library is just a simple LittleFS wrapper to facilitate your usage of LittleFS for the onboard flash on MBED RP2040-based boards such as Nano_RP2040_Connect, RASPBERRY_PI_PICO, using Arduino-mbed RP2040 core
The filesystem access uses normal POSIX APIs or mbed FileSystem APIs
Currently supported Boards
- RP2040-based boards such as Nano_RP2040_Connect, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, etc. using Arduino-mbed RP2040 core
Prerequisites
Arduino IDE 1.8.19+for ArduinoArduino mbed_rp2040 core 2.3.1-for RP2040-based boards usingISSIFlash chip, see New board, such as Arduino Nano RP2040 Connect, RASPBERRY_PI_PICO, etc..Arduino mbed_rp2040 core 2.4.1+for Arduino (Use Arduino Board Manager) RP2040-based boards usingAdestoFlash chip, see Old board, such as Arduino Nano RP2040 Connect, RASPBERRY_PI_PICO, etc.. Latest release is
Installation
Use Arduino Library Manager
The best and easiest way is to use Arduino Library Manager. Search for LittleFS_Mbed_RP2040, then select / install the latest version.
You can also use this link for more detailed instructions.
Manual Install
Another way to install is to:
- Navigate to LittleFS_Mbed_RP2040 page.
- Download the latest release
LittleFS_Mbed_RP2040-main.zip. - Extract the zip file to
LittleFS_Mbed_RP2040-maindirectory - Copy whole
LittleFS_Mbed_RP2040-mainfolder to Arduino libraries' directory such as~/Arduino/libraries/.
VS Code & PlatformIO
- Install VS Code
- Install PlatformIO
- Install LittleFS_Mbed_RP2040 library by using Library Manager. Search for LittleFS_Mbed_RP2040 in Platform.io Author's Libraries
- Use included platformio.ini file from examples to ensure that all dependent libraries will installed automatically. Please visit documentation for the other options and examples at Project Configuration File
Examples
- LittleFS_Counting
- LittleFS_test
Example Littlefs_Test
https://github.com/khoih-prog/LittleFS_Mbed_RP2040/blob/088cf4bbbc48a1bed4f4ac0c7f94e7f92e32d092/examples/LittleFS_Test/LittleFS_Test.ino#L11-L359
Debug Terminal Output Samples
1. LittleFS_Counting on RaspberryPi Pico
The following is the sample terminal output when running example LittleFS_Counting on MBED RaspberryPi Pico
Start LittleFS_Counting on RaspberryPi Pico
LittleFS_Mbed_RP2040 v1.1.0
[LFS] LittleFS size (KB) = 256
[LFS] LittleFS Mount OK
Deleting file: /littlefs/counts.txt => OK
Times have been run = 1
=> Open to write OK
Start LittleFS_Counting on RaspberryPi Pico
LittleFS_Mbed_RP2040 v1.1.0
[LFS] LittleFS size (KB) = 256
[LFS] LittleFS Mount OK
=> Open to read OK
Times have been run = 2
=> Open to write OK
Start LittleFS_Counting on RaspberryPi Pico
LittleFS_Mbed_RP2040 v1.1.0
[LFS] LittleFS size (KB) = 256
[LFS] LittleFS Mount OK
=> Open to read OK
Times have been run = 3
=> Open to write OK
2. LittleFS_Test on RaspberryPi Pico
The following is the sample terminal output when running example LittleFS_Test on MBED RaspberryPi Pico
Start LittleFS_Test on RaspberryPi Pico
LittleFS_Mbed_RP2040 v1.1.0
[LFS] LittleFS size (KB) = 256
[LFS] LittleFS Mount OK
====================================================
Writing file: /littlefs/hello1.txt => Open OK
* Writing OK
====================================================
Reading file: /littlefs/hello1.txt => Open OK
Hello from RaspberryPi Pico
====================================================
Appending file: /littlefs/hello1.txt => Open OK
* Appending OK
====================================================
Reading file: /littlefs/hello1.txt => Open OK
Hello from RaspberryPi Pico
Hello from RaspberryPi Pico
====================================================
Renaming file: /littlefs/hello1.txt to: /littlefs/hello2.txt => OK
====================================================
readCharsFromFile: /littlefs/hello2.txt => Open OK
Hello from RaspberryPi Pico
Hello from RaspberryPi Pico
====================================================
Deleting file: /littlefs/hello2.txt => OK
====================================================
Reading file: /littlefs/hello2.txt => Open Failed
====================================================
Testing file I/O with: /littlefs/hello1.txt => Open OK
- writing
64 Kbytes written in (ms) 847
====================================================
- reading
64 Kbytes read in (ms) 18
====================================================
Testing file I/O with: /littlefs/hello2.txt => Open OK
- writing
64 Kbytes written in (ms) 847
====================================================
- reading
64 Kbytes read in (ms) 18
====================================================
Deleting file: /littlefs/hello1.txt => OK
====================================================
Deleting file: /littlefs/hello2.txt => OK
====================================================
Test complete
Debug
Debug is enabled by default on Serial.
You can also change the debugging level (LFS_LOGLEVEL) from 0 to 4
#define LFS_DEBUG_OUTPUT Serial
// These define's must be placed at the beginning before #include "LittleFS_Mbed_RP2040.h"
// _LFS_LOGLEVEL_ from 0 to 4
#define _LFS_LOGLEVEL_ 0
Troubleshooting
If you get compilation errors, more often than not, you may need to install a newer version of the core for Arduino boards.
Sometimes, the library will only work if you update the board core to the latest version because I am using newly added functions.
Issues
Submit issues to: LittleFS_Mbed_RP2040 issues
TO DO
- Search for bug and improvement.
DONE
- Basic LittleFS wrapper for RP2040-based boards such as Nano_RP2040_Connect, RASPBERRY_PI_PICO, using Arduino-mbed RP2040 core
- Add Version String
- Add Table of Contents
- Add astyle using
allmanstyle. Restyle the library
Contributions and Thanks
Many thanks for everyone for bug reporting, new feature suggesting, testing and contributing to the development of this library.
- Thanks to Maximilian Gerhardt to create bug report RP2040_RTC_Time crashes Pico, does not work #3 and help investigate and fix the bug, leading to v1.0.3
![]() Maximilian Gerhardt |
Contributing
If you want to contribute to this project:
- Report bugs and errors
- Ask for enhancements
- Create issues and pull requests
- Tell other people about this library
License
- The library is licensed under GPLv3
Copyright
Copyright (c) 2021- Khoi Hoang

