Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By tommytml
#79477 Hello,
I want to build a sd card web server on this huzzah breakout, so first I'm trying to mount the sd card to this module. The code is the arduino's example code, I only changed the CS pin from GPIO4 to GPIO15 which is the CS pin of the module.

Code: Select all/*
  Listfiles

  This example shows how print out the files in a
  directory on a SD card

  The circuit:
   SD card attached to SPI bus as follows:
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS - pin 4

  created   Nov 2010
  by David A. Mellis
  modified 9 Apr 2012
  by Tom Igoe
  modified 2 Feb 2014
  by Scott Fitzgerald

  This example code is in the public domain.

*/
#include <SPI.h>
#include <SD.h>

File root;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
     Serial.print("Initializing SD card...");
  if (!SD.begin(15)) {        //Originally it's 4
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");

  root = SD.open("/");

  printDirectory(root, 0);

  Serial.println("done!");
}

void loop() {

}

void printDirectory(File dir, int numTabs) {
  while (true) {

    File entry =  dir.openNextFile();
    if (! entry) {
      // no more files
      break;
    }
    for (uint8_t i = 0; i < numTabs; i++) {
      Serial.print('\t');
    }
    Serial.print(entry.name());
    if (entry.isDirectory()) {
      Serial.println("/");
      printDirectory(entry, numTabs + 1);
    } else {
      // files have sizes, directories do not
      Serial.print("\t\t");
      Serial.println(entry.size(), DEC);
    }
    entry.close();
  }
}


But the IDE always told me it failed to upload the code:
Code: Select allwarning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed


Then I did some research and found that GPIO15 of this module controls the boot mode and if it's high then the module will fail the uploading. I wonder how should I avoid this problem like changing the CS pin of this module?
User avatar
By QuickFix
#79499 GPIO15 only has to be LOW in flash- or run-mode; if you set it HIGH at boot, the ESP will enter SD-mode (an unsupported mode to us mortal users).
Just make sure GPIO15 is pulled LOW (using a resistor, 47k or so will do) and everything will be fine.

Also make sure GPIO0 is pulled HIGH when you want the ESP to boot in run-mode.
ESPModes.png
You do not have the required permissions to view the files attached to this post.
User avatar
By rudy
#79501
tommytml wrote:I did some research and found that GPIO15 of this module controls the boot mode and if it's high then the module will fail the uploading. I wonder how should I avoid this problem like changing the CS pin of this module?

I use GPIO15 for SPI CS all the time without problem. As stated above, make sure you have an adequate pull down on GPIO15 (should be there) and check if the CS line on the module (SD card) has a pull up resistor. If it does then remove it. Or use a stronger pull down resistor (lower resistance) to make any additional pull up resistance irrelevant.