Skip to content
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

How to compile a firmware for ESP32 that can handle SD Cards #1779

Closed
MaBecker opened this issue Mar 16, 2020 · 4 comments
Closed

How to compile a firmware for ESP32 that can handle SD Cards #1779

MaBecker opened this issue Mar 16, 2020 · 4 comments
Labels

Comments

@MaBecker
Copy link
Contributor

/* jshint esversion: 6 */
//File_IO_and_SD_cards.js 

if ( process.env.BOARD == "ESP32") {

    M5Stack = require("M5STACKS");
    SPI1.setup({mosi:M5Stack.MOSI, miso:M5Stack.MISO, sck:M5Stack.SCK});
    E.connectSDCard(SPI1, M5Stack.CS);

    // see what's on the device
    //console.log(require("fs").readdirSync());
}


if ( process.env.BOARD == "PICO_R1_3") {

  // Wire up up MOSI, MISO, SCK and CS pins (along with 3.3v and GND)
  SPI1.setup({mosi:B5, miso:B4, sck:B3});
  E.connectSDCard(SPI1, B6 /*CS*/);
 
  // see what's on the device
  //console.log(require("fs").readdirSync());

}

No error on Pico, but this one on ESP32.

Uncaught Error: Unimplemented on Linux
 at line 5 col 37
    E.connectSDCard(SPI1, M5Stack.CS);

Are there some modules or -DSettings for ESP32 missing?

void jswrap_E_connectSDCard(JsVar *spi, Pin csPin) {
#ifdef SD_CARD_ANYWHERE
if (!jsvIsObject(spi)) {
jsExceptionHere(JSET_ERROR, "First argument is a %t, not an SPI object\n", spi);
return;
}
if (!jshIsPinValid(csPin)) {
jsExceptionHere(JSET_ERROR, "Second argument is not a valid pin");
return;
}
jswrap_E_unmountSD();
sdSPISetup(spi, csPin);
#else
NOT_USED(spi);
NOT_USED(csPin);
jsExceptionHere(JSET_ERROR, "Unimplemented on Linux");
#endif
}

@MaBecker
Copy link
Contributor Author

Wow the solution was there in the same file just a few lines above :)

#if !defined(LINUX) && !defined(USE_FILESYSTEM_SDIO) && !defined(USE_FLASHFS)
#define SD_CARD_ANYWHERE
#endif

So the solution is to remove this line

'FLASHFS',

and build a new firmware version and it works.

@AkosLukacs
Copy link
Contributor

Just a hunch: does writing to internal flash still work?

@gfwilliams
Copy link
Member

Using Storage it would - FLASHFS is something different (FAT32 on the internal flash)

@AkosLukacs
Copy link
Contributor

That's great news, thanks for the clarification.
Btw, is there a list of boards.py or common compiler flags?

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

No branches or pull requests

3 participants