Binaries with "fs" SD card support NEEDED!!!

Posted on
of 2
/ 2
  • Please take a picture of your wiring and do a table like this:­920/

    Display     NodeMCU     ESP-12   Colour
    LED         3V3         3V3       N/A
    SCLCK       D5          GPIO14    Green
    DN<MOSI>    D7          GPIO13    Yellow
    D/C         D2          GPIO04    Orange
    RST         D1          GPIO05    Brown
    SCE         D8          GPIO15    Red
    GND         GND         GND       Grey
    VCC         3V3         3V3       Blue
    BackLight   GND         GND       Purple

    As you can see here NodeMCU.D7 is gpio13

    I don't think your init it matching how you have wired up.

  • If you don't want to use NodeMCU.Dx just use Dx instead.

    I guess it's possible that the SD card code took a while to execute and that caused a watchdog timer to reset the board? It shouldn't really take that long to initialise though...

  • I found, that when i change my CS pin to NodeMCU.D5 instead of the (accually) used D4, i get a 'Connection lost' error. When i use D4 i get 'SD card not found!'

    I use MOSI GPIO13, MISO GPIO12 and SCK GPIO14. Anyone knows the NodeMCU.Dx replacement for GPIO12? I guess it is D6 but not sure...

  • try this and you will see

  • Ah, that worked great!

    Seems i got my pin assignments correct.

      "port": "D",
      "num": 12,
      "functions": {  }
      "port": "D",
      "num": 14,
      "functions": {  }
      "port": "D",
      "num": 13,
      "functions": {  }
      "port": "D",
      "num": 4,
      "functions": {  }
  • Are you still trying to do this in an oninit() function, or are you trying the simple case?

    You should be able to paste the setup stuff directly into the left side of the ide

  • I tried both. But in the first place i always try to copy-paste-enter it line by line in the left terminal frame.

    >var s = new SPI();
    ={  }
    ERROR: Unable to mount SD card : NOT_READY
  • I had same problem, after switching from D2 to GPIO15(hardware and software) NOT_READY went away, but then ESP8266 crashed during reading boot sector.

  • I tried the software SPI again and removed the "NodeMCU." before the pin. Like this:

    var s = new SPI();
    s.setup({mosi:D7, miso:D6, sck:D5});
    E.connectSDCard(s, D2);

    And then i get this output. Maybe this says something to anyone?

     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
     1v86.113 Copyright 2016 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    Flash map 1MB:512/512, manuf 0xe0 chip 0x4014
    ERROR: Cannot change pins used for flash chip
    ERROR: Cannot change pins used for flash chip
    ERROR: Unable to mount SD card : NOT_READY

    Also with the Hardware SPI example, SPI1 is used. int the documentation it says that there should be options for SPI1,SPI2 and SPI3.

    Can it be that i should use the SPI2, because of the flash memory beeing attached to SPI1?
    Is SPI2 dissabled in the firmware from the earlier post, or is it a matter of the ESP8266 not beeing able to find the SPI2?

  • Please take a picture and document your wiring, otherwise this is just guess work.

  • See the attached schematic.

    1 Attachment

    • espSD_schematic.png
  • I know my wiring is correct because i allready had it working with code from the Arduino IDE.

    I can't show you the wiring because it is on a pcb. There are no wires. (Look ma! No wires :) )

  • @ManoBiletsky

    So looks like it is wired:

    DO  NodeMCU.D6  GPIO12
    SCK NodeMCU.D5 GPIO14
    DI  NodeMCU.D7 GPIO13
    CS  NodeMCU.D2 GPIO4
    var s = new SPI();

    It looks like it should work ok.

    The SD card has been formatted with the correct File system?

  • Indeed! it was formatted as FAT16 before and later formatted as FAT32.

  • After 6 weeks of occasional tries I got my sdcard working, yeah!

    I confirm the "Fatal exception 9" of @JumJum in check_fs-function of libs/filesystem/fat_sd/ff.c in this line:

    if ((LD_DWORD(&fs->win[BS_FilSysType]) & 0xFFFFFF) == 0x544146)         /* Check "FAT" string */

    Espruino uses the FatFs lib of ChaN in version R0.10a. ChaN has a later version (­) which seem to be compatible and includes some bug fixes. One of them ist mentioned in the Changelog: "Fixed a potential problem of FAT access that can appear on disk error."

    The crashes were gone with the later version R0.10c. I have not testet it thoroughly yet, but it looks promising. Here is my small test code which was crashing the esp8266, and now it is printing the directory content as expected:

    var fs = require('fs');
    SPI1.setup({sck:D14, miso:D12, mosi:D13});
    E.connectSDCard(SPI1, D15);
    var e = require("ESP8266");

    For this is my first post here, I want to thank @Gordon and all community members for the great work! I'm convinced that Espruino is the best platform for learning how to program microcontrollers these days, as long as you don't use a not officially supported device and experiment with sophisticated features which are not compiled in by default. ;-)

  • @hartmut

    So you had to update the espruino source with the updated fs library?

    Is this on github, it would be great to do a pull request so this can be brought back into the project!

  • It's not yet on github. I give it a try...
    I attached my firmware for those who have the patience of myself...

    1 Attachment

  • @Wilberforce Sorry for the delay! Finally I've prepared the suggested pull request for you, but sadly my lib upgrade doesn't repair the esp8266 build by itself like I thought it would.

    By simply overwriting all files with the updated library, the esp8266 build worked. For the pull request I tried to carefully to adopt all changes from the espruino configuration to the new library, which results in a crash in fs.readdir() on esp8266.

    The real reason for the crashes on esp8266 lies in libs/filesystem/fat_sd/ffconf.h. For esp8266, the #define _WORD_ACCESS must be set to zero, maybe because of alignment restrictions on the LX106. Maybe someone more experienced than me is able to wrap the define _WORD_ACCESS 0 with an ifdef ESP8266_BOARD?

  • Thanks. I saw the pull request on github.

    Some of the esp memory reads need to be on four byte boundaries, so perhaps this is what is going on?

    Did you try on a later version of the library, it looks like it is up to version 13, rather than 10c?

  • No. I had two objectives, getting my sdcard in esp8266 to work and keeping the changes as small as possible to ease the integration in Espruino. The API of versions >10 was changed or rather expanded (f_findfirst(), f_findnext(), f_findclose(), f_expand(), changed behavior of f_readdir(), f_rename() and f_lseek(), added codepages, added exFAT). On the other side, the problematic option _WORD_ACCESS was removed in Version 12. ;-)

    I would try to integrate the latest version in Expruino, but I'm not very skilled in C/Makefiles/filesystems. Do you have the time to check my results? Did anyone request the extra features of later versions so far? Is there enough space left in the official devices?

  • Thanks - it looks like a Gordon has merged the changes on github.

    I'm currently working with @jumjum porting espruino to the esp32, which has much more resources. I'm looking at integrating the i2c and spi libs at present, so this work you have done with sd cards will be useful. There is a native virtual file system with the esp-idf, however the espruino implemention should sit on top of the spi code and just work.

  • Thats good news, @Wilberforce! Do you know when your spi code will be mature enough for testing with my esp32?

  • No, it's a work in progress. And given that I don't have a carrier for an sdk card and only a breadboard I would heave to cobble the hardware together, making another possible failer point !

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Binaries with "fs" SD card support NEEDED!!!

Posted by Avatar for ManoBiletsky @ManoBiletsky