Git Product home page Git Product logo

esp32-psramfs's Introduction

ESP32-PsRamFS

Coding Horror

ESP32-PsRamFS id a pseudo RamDisk library for Arduino-ESP32, with vfs compliance.

It provides a fs::FS style filesystem using the psram of an ESP32-Wrover or any ESP32 equipped with PSRam.

Some unit tests are available in the example folder, consider setting the debug output level to DEBUG to see what's happening.

Directory support is still partial but the API is now vfs compliant.

Usage

Only use this if your situation requires a filesystem, otherwise consider dropping the filesystem and use Streams instead with the excellent arduino-BufferStream library.

#include <PSRamFS.h>


void setup()
{

  Serial.begin(115200);

  if(!PSRamFS.begin()){
    Serial.println("PSRamFS Mount Failed");
    return;
  }

}

Hardware Requirements:

  • ESP32 with PSRam

Actually PSRam is optional, but strongly recommended.

For very low memory situations that still require some abstraction to access file data,

Tested on:

  • ESP32-Wroom
  • ESP32-Wrover
  • ESP32-S2
  • ESP32-C3

Known issues:

  • Broken support for file::position()
  • Unimplemented fs::open(dirname); (fake support)
  • Partial support for file::isDirectory();
  • No support for dir::openNextFile()

Credits:

esp32-psramfs's People

Contributors

lbernstone avatar tobozo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esp32-psramfs's Issues

Handle FS using VFS POSIX API

Is POSIX style VFS API supported? I want to use this library in conjunction with SQLite 3 database for ESP32, all running in PSRAM (allocations for SQLite and the database files itself).

By the way, awesome project 😎

readBytes problem

Hello thanks for ESP32-PsRamFS ramdisk program.
Im using this useful program.
When I used readBytes(char *,sizs_t) function ,l could not read last char of this file.
followin is test program

#include "./PSRamFS.h"
#include "./pfs.h"
void setup() {
  Serial.begin(115200);
  esp32Info();
  if (!PSRamFS.begin()) {
    log_e("PSRamFS Mount Failed");
    return;
  }
  if (PSRamFS.exists("/test.txt")) {
    PSRamFS.remove("/test.txt");;
  }
  File t = PSRamFS.open("/test.txt", FILE_WRITE);
  if (t) {
    t.print("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
    Serial.print("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
    Serial.printf("\n/test.txt size= %d \n", t.size());
    t.close();
  }
  File r = PSRamFS.open("/test.txt", FILE_READ);
  int rsize = r.size();
  if (r) {
    int c = 0;
    char rbuf[32];
    int len = 0;
    int total = 0;
    do {
      len = r.readBytes(rbuf, sizeof(rbuf));
      for (int i = 0; i < len; i++) {
        Serial.print(rbuf[i]);
      }
      Serial.printf("\nlen=%d", len);
      total += len;
    } while (len);
    t.close();
    Serial.printf("\ntotal=%d", total);
    if (total != rsize) {
      Serial.printf("\nwe can read all data except file end..Z");
    }
  }
  Serial.println("\nEND");
}

void loop() {
  // put your main code here, to run repeatedly:

}
void esp32Info(void) {
  Serial.println("---------------------------- -");
  uint64_t chipid;
  chipid = ESP.getEfuseMac(); //The chip ID is essentially its MAC address(length: 6 bytes).
  Serial.printf("ESP32 Chip ID = % 04X\r\n", (uint16_t)(chipid >> 32)); //print High 2 bytes
  Serial.printf("Chip Revision % d\r\n", ESP.getChipRevision());
  esp_chip_info_t chip_info;
  esp_chip_info(&chip_info);
  Serial.printf("Number of Core: % d\r\n", chip_info.cores);
  Serial.printf("CPU Frequency: % d MHz\r\n", ESP.getCpuFreqMHz());
  Serial.printf("Flash Chip Size = % d byte\r\n", ESP.getFlashChipSize());
  Serial.printf("Flash Frequency = % d Hz\r\n", ESP.getFlashChipSpeed());
  Serial.printf("Free Heap Size = % d\r\n", esp_get_free_heap_size());
  Serial.printf("Total PSRAM: %d\r\n", ESP.getPsramSize());
  Serial.printf("Free PSRAM: %d\r\n", ESP.getFreePsram());
  Serial.printf("ESP - IDF version = % s\r\n", esp_get_idf_version());
  Serial.println();
}

PsRamFS as LittleFS cache to accelerate a web server - viable?

Hi,

this looks like a very interesting project.

I have a performance issue with a web server using ESPAsyncWebServer serving from a small LittleFS root (maybe 1MB) - which is so slow that reading large files triggers the watchdog no matter how long I set it

so I was thinking about caching the LittleFS content in a PSRAM-based filesystem

Do you think this project is a viable base for such an effort?

what I would do is:

  • after boot, recursively copy the LittleFS contents to the PsRamFS (probably in a background task)
  • when serving a file, first check if the file is available in PsRamFS, and only fall back to LittleFS

another option would be to cook up something like a PSRAM-based LittleFS subclass which would just suck up the whole partition into PSRAM and serve from there, but I have no grasp how complex this would pan out.

Does this sound reasonable? which option would you choose?

I would be grateful for a frank opinion.

best regards
Michael

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.