How to use virtual file system.?

jgfrmesp
Posts: 6
Joined: Mon May 15, 2017 11:06 pm

Re: How to use virtual file system.?

Postby jgfrmesp » Tue May 16, 2017 7:51 am

@perryc:
Can you somehow share your code? I can not send you a pm (it seems that this is blocked for new users; why?)

Jaap

Fugazi
Posts: 42
Joined: Wed Apr 26, 2017 9:05 pm

Re: How to use virtual file system.?

Postby Fugazi » Tue May 16, 2017 4:26 pm

I have it working now, works very well, reading and writing a file to flash.

I am using it with ardunio and had to increase the task stack to run the espidf vfs_fat example.

Should be able to compile the wear leveling code example and add the custom file partition for the filesystem and it will work.

Phil.

jgfrmesp
Posts: 6
Joined: Mon May 15, 2017 11:06 pm

Re: How to use virtual file system.?

Postby jgfrmesp » Wed May 17, 2017 11:14 am

Interesting.
How was it done?

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

Re: How to use virtual file system.?

Postby loboris » Wed May 17, 2017 4:44 pm

jgfrmesp wrote:Yes, that precisely the case. Spiffs raw (so without vfs) works fine.
As soon as I use the vfs part (I used the code at https://github.com/nkolban/esp32-snippe ... vfs/spiffs)m I can not read the file back (I can not see if it is written in the first place).

Best,

Jaap
Take a look at: viewtopic.php?f=18&t=1901

Laila_
Posts: 1
Joined: Thu May 18, 2017 4:59 pm

Re: How to use virtual file system.?

Postby Laila_ » Thu May 18, 2017 5:22 pm

Hello, I'm new on ESP32 ( have only little experience in programming) and currently working on a simple webserver. ESP starts in AP-mode.
I hope to find a solution for the following issue and kindly ask for help: :)

I would like to load a file that contains my html-code.
I tried to simply use the FS.h library and the code that was used on ESP8266 since I could not find a reference guide for the ESP32 libraries that i undestood.

I compiled in Arduino IDE and also PlatformIO.
In Arduino I used the library from espressif github https://github.com/espressif/arduino-esp32
Error is: " 'SPIFFS' was not declared in this scope "

Heres the important part of my code:

Code: Select all

#include <FS.h>
#include <WiFi.h>

#define DEBUGMODE 1

/*Wifi Access data*/
const char* ssid_ap = "AccessPoint";
const char* password_ap = "12345678"; 

const char * ssid_sta     = "<SSID>";
const char * password_sta = "<Password>";

/* set global variables */
byte WiFiMode = 0;  // WIFI_STA = 1 = Workstation  WIFI_AP = 2  = Accesspoint
int request_counter;
String sHTML;
String sHTMLRequest;

/* Create instance of server on Port 80 */
WiFiServer server(80);
WiFiClient client;

void setup() {
  
/*start serial communication */
  Serial.begin(115200);
  SPIFFS.format();
  Serial.println("Spiffs formatted");

/* start WiFi as workstation (STA), if not possible 
   start as Acess Point initialize server */ 
  WiFi_Start_STA();
  if (WiFiMode == 0) WiFi_Start_AP();
}


void loop() {
  
  /* Check if a client has connected */
  client = server.available();
  if (!client) 
  {
    return;
  }
  
 /*Wait for the client to send data */
  Serial.println("neuer Client verbunden");
  /*Count Aufruf der Seite: */
  request_counter ++; 
  unsigned long clTimeout = millis()+250;
  while(!client.available() && (millis()<clTimeout) )
  {
    delay(1);
  }
  if(millis()>clTimeout) 
  { 
    Serial.println("time-out bei Client-Verbindung!");
    return; 
  }

/****** open html files  *******/
  SPIFFS.begin();
  File f = SPIFFS.open("/home.txt", "r");
  if (!f) {
  Serial.println("file open failed");
  }
    f.close();
  
  }

perryc
Posts: 25
Joined: Fri Feb 17, 2017 1:29 am

Re: How to use virtual file system.?

Postby perryc » Thu May 18, 2017 10:59 pm

Sorry for slow reply jgfrmesp - I'd not seen this thread was still active. Is there any reason we'd not want to move on to using the wear leveling driver that's now in the esp-idf? So far it's been working well in my tests other than I've not solved how to flash a prebuilt filesystem.

Perry

Who is online

Users browsing this forum: No registered users and 357 guests