Skip to content

SD card with SPIFFS #1723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
CosmicBoris opened this issue Mar 5, 2016 · 5 comments
Closed

SD card with SPIFFS #1723

CosmicBoris opened this issue Mar 5, 2016 · 5 comments

Comments

@CosmicBoris
Copy link

Hardware: ESP-07
Core Version: 2.1.0-rc2

Description

Can I use both SD card lib and SPIFFS?

Settings in IDE

Module: Generic ESP8266 Module
Flash Size: 1MB/512kb
CPU Frequency: 160Mhz
Flash Mode: DIO
Flash Frequency: 40Mhz
Upload Using: SERIAL
Reset Method: ck

include <FS.h>

include <SPI.h>

include <SD.h>

File hFile;

In file included from ESP_FileServer.ino:7:0:
C:\Users\boris\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.1.0\libraries\SD\src/SD.h:26:7: error: redefinition of 'class fs::File'
class File : public Stream {
^
In file included from ESP_FileServer.ino:5:0:
C:\Users\boris\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.1.0\cores\esp8266/FS.h:48:7: error: previous definition of 'class fs::File'
class File : public Stream
^
Multiple libraries were found for "SD.h"
Used: C:\Users\boris\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.1.0\libraries\SD
Not used: C:\Program Files (x86)\Arduino\libraries\SD

@gmag11
Copy link
Contributor

gmag11 commented Mar 6, 2016

I'm not an expert in C++, but SPIFFS library (FS.h) defines a namespace called "fs". It should be possible to differenciate class definitions using it.

@CosmicBoris
Copy link
Author

I found this useful [https://github.com/me-no-dev/Arduino/commit/72c2c3f4e2a0c4de29ce5f946417aed6130748d5]
But now I have to specify what namespace am using:

void readFromSD(String path){
    using sd::File;
    File hFile = SD.open(path);
    ...
}
void readFromFS(String path){
    using fs::File;
    File hFile =  SPIFFS.open(path, "r");
    ...
}

@igrr
Copy link
Member

igrr commented Mar 9, 2016

Currently this isn't possible, because both SD and SPIFFS provide a class called File.
There is, however, a suggestion to put SD library into its own namespace (#1524).

@WheresWally
Copy link

WheresWally commented Jul 3, 2017

Any progress on being able to use SD and SPIFFS at the same time?

maybe this is a work around.
#1524

@probonopd
Copy link
Contributor

probonopd commented Jul 22, 2017

Solution is explained here: #1524 (comment)
Seems to work for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants