LittleFS-RK (community library)

Summary

Name Value
Name LittleFS-RK
Version 0.0.1
Installs 173
License MIT
Author Rick Kaseguma rickkas7@rickk.com
URL https://github.com/rickkas7/LittleFS-RK
Repository https://github.com/rickkas7/LittleFS-RK.git
Download .tar.gz

LittleFS port for Particle Gen 2 devices

Example Build Testing

Device OS Version:

This table is generated from an automated build. Success only indicates that the code compiled successfully.

Library Read Me

This content is provided by the library maintainer and has not been validated or approved.

LittleFS-RK

Port of LittleFS for Particle Gen 2 devices.

Warning: This only works on Gen 2 devices (Photon, P1, Electron, E Series)! The issue is that it uses the same C POSIX file API as currently used on the Gen 3 devices, so the linker will complain that it's implemented in two places, as it is.

Warning: As this point in time, it's just a proof-of-concept for testing. There are almost certainly still bugs that haven't been found yet as it has not been extensively tested yet!

Usage

You'll probably need some includes:

#include "LittleFS-RK.h"

#include <dirent.h>
#include <sys/stat.h>
#include <fcntl.h>

This code uses the SpiFlashRK library to interface to the flash chip. You typically use one of these lines depending on the brand, SPI port, and CS line:

// Pick a chip, port, and CS line
// SpiFlashISSI spiFlash(SPI, A2);
// SpiFlashWinbond spiFlash(SPI, A2);
// SpiFlashMacronix spiFlash(SPI, A2);
// SpiFlashWinbond spiFlash(SPI1, D5);
// SpiFlashMacronix spiFlash(SPI1, D5);

You then allocate a LittleFS object as a global:

LittleFS fs(&spiFlash, 0, 256);

The parameters are:

  • &spiFlash the object for your flash chip
  • 0 the start sector for the file system (0 = beginning of chip)
  • 256 replace with the number of 4096-byte sectors to use for the file system. 256 * 4096 = 1,048,576 bytes = 1 Mbyte, the size of an 8 Mbit SPI flash chip.

Note: You must only ever allocate one LittleFS object. Bad things will happen if you create more than one. You can allocate it with new but don't allocate it on the stack.

Finally, in setup(), initialize the SPI flash and mount the file system. This will format it if it has not been formatted.

spiFlash.begin();
int res = fs.mount();
Log.info("fs.mount() = %d", res);

Testing

There are two test programs:

  • FileSystemTest: A simple app
  • LargeFileTest: A test that writes larger files to test performance

Version History

0.0.1 (2020-11-10)
  • Initial testing version. It probably still has bugs!

Browse Library Files