CAUTION - THIS IS EXPERIMENTAL PRE-ALPHA SOFTWARE!! IT MIGHT BREAK THINGS, YOU HAVE BEEN WARNED!!
This library supports both nRF5x on-chip flash (including custom areas not just the 28kb UserData area!) and external SPI flash memory chips, providing a unified filesystem interface for embedded applications.
Add to your platformio.ini:
lib_deps =
https://github.com/oltaco/CustomLFS.gitProbably requires the Adafruit nRF52 Arduino framework?
#include "CustomLFS.h"
CustomLFS myfs;
void setup() {
if (!myfs.begin()) {
Serial.println("nRF5x flash init failed");
return;
}
// Use filesystem
File file = myfs.open("/config.txt", FILE_WRITE);
file.println("Hello nRF5x!");
file.close();
}Might not require any other dependencies? I haven't checked.
#include "CustomLFS_SPIFlash.h"
const int chipSelect = 25;
void setup() {
// Option 1: Use global instance
if (!FlashFS.begin(chipSelect, SPI)) {
Serial.println("SPI flash init failed");
return;
}
Serial.print("Detected: ");
Serial.println(FlashFS.getChipName());
// Option 2: Create custom instance
CustomLFS_SPIFlash myFlash(chipSelect, SPI);
if (!myFlash.begin()) {
Serial.println("Custom instance init failed");
return;
}
}#include "CustomLFS.h"
CustomLFS myfs;
void setup() {
// Configure custom flash region (address, size, block_size)
// This example would use 100kb at the of the application flash area.
if (!myfs.setFlashRegion(0xD4000, 0x19000, 128)) {
Serial.println("Invalid flash region");
return;
}
if (!myfs.begin()) {
Serial.println("Custom region init failed");
return;
}
}This library is released under the MIT License. See LICENSE file for details.
- Based on Paul Stoffregen's LittleFS implementation