Adding sdfat library

I'm trying to use an arduino uno and an adafruit sd shield to make a LED light painting sythe.

But the link to the sdfat library results in a 404. I can't find a way to add the library and the github links I've tried aren't working correctly. Every time I try to download the zip to the arduino IDE it results in saying:

"specified folder/zip file does not contain a valid library"

Help/thoughts/suggestions??

FullSizeRender.jpg
FullSizeRender.jpg

Jwplights:
I'm trying to use an arduino uno and an adafruit sd shield to make a LED light painting sythe.

Download Software | NeoPixel Painter | Adafruit Learning System

But the link to the sdfat library results in a 404.

That's an old link. The correct download link is now:
https://github.com/greiman/SdFat/archive/master.zip

Jwplights:
Every time I try to download the zip to the arduino IDE it results in saying:

"specified folder/zip file does not contain a valid library"

The problem is the folder structure of that library doesn't allow you to do Sketch > Include Library > Add .ZIP Library...

The SdFat library repository contains installation instructions:

To use SdFat, clone the repository or unzip the ZIP file and place the SdFat folder into the libraries sub-folder in your main sketch folder.

Here's a bit more detailed installation instructions for you:

  • Download https://github.com/greiman/SdFat/archive/master.zip
  • Copy the folder SdFat-master/SdFat from the downloaded file to {sketchbook folder}/libraries. You must copy the SdFat folder, not the SdFat-master folder. You can find the location of your sketchbook folder at File > Preferences > Sketchbook location.
  • Restart the Arduino IDE if it's running.

Had same problem today "No such file in lib ..."SdFat -master
downloaded from Github
installed dozens of libs directly from .zip
unzipped and yes no .cpp nor .h file ?????SdFat...
Anyone got around this problem?
Thanks a lot

EA1940:
unzipped and yes no .cpp nor .h file ?????SdFat...

That means nothing to me. Please make a bit of an effort to clearly explain what your problem is.

EA1940:
Anyone got around this problem?

Yes, I thought I had explained the solution pretty well in my previous post:

pert:

  • Download https://github.com/greiman/SdFat/archive/master.zip
  • Copy the folder SdFat-master/SdFat from the downloaded file to {sketchbook folder}/libraries. You must copy the SdFat folder, not the SdFat-master folder. You can find the location of your sketchbook folder at File > Preferences > Sketchbook location.
  • Restart the Arduino IDE if it's running.

Did you follow those instructions?

Note that moving the SdFat-master to the Arduino Libraries folder does not work.

As the Arduino Library Install directions state "There may be more files than just the .cpp and .h files, just make sure they're all there. (The library won't work if you put the .cpp and .h files directly into the libraries folder or if they're nested in an extra folder."

The SdFat.h and SdFat.cpp files are nested down several levels, and must be in the top directory for the Arduino library manager to recognize them. Generally, the "-master" is also removed.

When going into the Sketch : Include Library : Manage Libraries dialog and searching for SdFat, it will find nothing until the .cpp and .h files are in top level of the SdFat directory.

When downloading SdFat from GitHub, these files are in SdFat/SdFat/Src directory and therefore not recognized by the library manager.

Moving all files from SdFat/SdFat/Src to SdFat resolves this issue.

HOWEVER: it will still not link!

Clearly the IDE is not recognizing files in subdirectories.

After a couple of hours trying to figure out how this could easily be fixed (and noting problems with a lack of references to the Arduino 101, I have given up and will just accept that 8.3 file names will be good enough.

Hal_cat:
Note that moving the SdFat-master to the Arduino Libraries folder does not work.

Correct, but I thought my instructions made it clear that you had to move the SdFat folder from inside of the SdFat-master folder. I'll try to update them to make it more obvious.

Hal_cat:
into the libraries folder or if they're nested in an extra folder."

The SdFat.h and SdFat.cpp files are nested down several levels, and must be in the top directory for the Arduino library manager to recognize them.

...

When going into the Sketch : Include Library : Manage Libraries dialog and searching for SdFat, it will find nothing until the .cpp and .h files are in top level of the SdFat directory.

...

Moving all files from SdFat/SdFat/Src to SdFat resolves this issue.

Which version of the Arduino IDE are you using? I'd assume since you mention Arduino 101 it's 1.6.x or later, which supports (and in fact recommends) having the library source files in the src subfolder if there is a library.properties file in the library root folder. As stated in the Arduino Library Specification:

For 1.5.x+-only libraries, the source code resides in the src folder. For example:

Servo/src/Servo.h

Servo/src/Servo.cpp

If you look at the official Arduino libraries you will see most of them have this folder structure.

Hal_cat:
HOWEVER: it will still not link!

Clearly the IDE is not recognizing files in subdirectories.

After a couple of hours trying to figure out how this could easily be fixed (and noting problems with a lack of references to the Arduino 101, I have given up and will just accept that 8.3 file names will be good enough.

Works fine for me.

I am having similar problems.
I think I tried all the suggestions, but isn't working for me.
See attached file for more information

note to forum.doc (951 KB)

pumpmck:
but isn't working for me.

The problem isn't with the installation. The problem is the library doesn't define PgmPrint(). Apparently the old one does. I can't help you more with this because I don't know what the old SdFat library you refer to is.

pumpmck:
See attached file for more information

By unnecessarily putting that information in a .doc file rather than posting it on the forum you significantly reduce the chances of getting help for absolutely no good reason.

Hi,
I have sometimes problem with init for the SD card.
When I run my code the I get sometimes the Error:
SD errorCode: 0X43,0X1

Then I run the sketch sdinfo:

SdFat version: 20160913

Assuming the SD is the only SPI device.
Edit DISABLE_CHIP_SELECT to disable another device.

Assuming the SD chip select pin is: 53
Edit SD_CHIP_SELECT to change the SD chip select pin.

type any character to start
error: cardBegin failed
SD errorCode: 0X43,0X1

type any character to start

next try:

type any character to start
error: cardBegin failed
SD errorCode: 0X43,0X5

type any character to start

then I eject the card and put it in the slot again:

init time: 813 ms

Card type: SDHC

Manufacturer ID: 0X74
OEM ID: J`
Product: USD  
Version: 1.0
Serial number: 0X508FA33B
Manufacturing date: 8/2015

cardSize: 8068.79 MB (MB = 1,000,000 bytes)
flashEraseSize: 128 blocks
eraseSingleBlock: true
OCR: 0XC0FF8000

SD Partition Table
part,boot,type,start,length
1,0X0,0XC,8192,15751168
2,0X0,0X0,0,0
3,0X0,0X0,0,0
4,0X0,0X0,0,0

Volume is FAT32
blocksPerCluster: 64
clusterCount: 245984
freeClusters: 245903
freeSpace: 8057.75 MB (MB = 1,000,000 bytes)
fatStartBlock: 12540
fatCount: 2
blocksPerFat: 1922
rootDirStart: 2
dataStartBlock: 16384

type any character to start

Then all is fine.
When I add my Sketch again, it may happen that I get the Error 0x43, 0x5 again. But not always. When the Init on SD card is ok, the I can read/write/delete files.

What can I do that the initialization always works?
Here my code:

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <stdlib.h>
#include <mcp_can.h>
#include <Timer.h>
#include <EEPROM.h>
#include <WiFi101.h>
#include "SdFat.h"

// function declaration
void clearScreen();

/**
   ===================================================
   WIFI
   ===================================================
*/
#define WINC_CS   34
#define WINC_IRQ  32
#define WINC_RST  35
#define WINC_EN   36
#define WINC_WAKE 33

const int8_t DISABLE_CHIP_SELECT_WIFI = 34;

WiFiServer server(80);
WiFiClient client;

/**
   ===================================================
   CAN
   ===================================================
*/
#define CAN_CS    31
MCP_CAN CAN(CAN_CS);
const int8_t DISABLE_CHIP_SELECT_CAN = 31;
uint8_t deviceType;
uint8_t len = 0;
unsigned char buf[8];
uint16_t canId = 0;
uint8_t deviceNodeId = 0x12;
boolean deviceStatus = false;

/**
   ===================================================
   TFT
   ===================================================
*/
#define TFT_CS        49
#define TFT_DC        48
#define TFT_RST       47
#define LITE          46
#define SCR_ROTATION  45
#define TEXT_WRAP     true
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

/**
   ===================================================
   SD-Card
   ===================================================
*/
#define SD_CS     53
SdFat sd;
File myFile;
File webFile;
char fileNameVersion[] = "version.txt";
char firmware[] = "firmware.bin";

void setup() {
  Serial.begin(9600);

  // Init section
  initTFT();
  tft.println();
  initSD();
  initWiFi();
  initCAN();
}

void loop() {
  // Do some CAN stuff
}

void initTFT() {
  // Use this initializer if you're using a 1.8" TFT
  // tft.initR(INITR_BLACKTAB);

  // Use this initializer if you're using a 1.44" TFT
  tft.initR(INITR_144GREENTAB);
  tft.setTextWrap(TEXT_WRAP);
  clearScreen();
  tft.setRotation(SCR_ROTATION);
}

void initCAN() {
  tft.setTextColor(ST7735_WHITE);
  tft.setTextSize(2);
  tft.print("CAN:");

  uint8_t count = 0;
  // Init can bus : baudrate = 500k
  // CAN_OK                  (0)
  // CAN_FAILINIT            (1)
  // CAN_FAILTX              (2)
  // CAN_MSGAVAIL            (3)
  // CAN_NOMSG               (4)
  // CAN_CTRLERROR           (5)
  // CAN_GETTXBFTIMEOUT      (6)
  // CAN_SENDMSGTIMEOUT      (7)
  // CAN_FAIL                (0xff)
  while (CAN_OK != CAN.begin(CAN_500KBPS)) {
  }
  tft.println("  OK");
}

void initSD() {
  tft.setTextColor(ST7735_WHITE);
  tft.setTextSize(2);
  tft.print("SD:");

  // Desable WIFI
  pinMode(DISABLE_CHIP_SELECT_WIFI, OUTPUT);
  digitalWrite(DISABLE_CHIP_SELECT_WIFI, HIGH);

  // Desable CAN
  pinMode(DISABLE_CHIP_SELECT_CAN, OUTPUT);
  digitalWrite(DISABLE_CHIP_SELECT_CAN, HIGH);

  // Initialize at the highest speed supported by the board that is
  // not over 50 MHz. Try a lower speed if SPI errors occur.
  if (!sd.begin(SD_CS, SD_SCK_MHZ(50))) {
    tft.println("   NOK");
    sd.initErrorHalt();
  } else {
    tft.println("   OK");
  }

  // Check if file "version.txt" exist.
  if (!sd.exists(fileNameVersion)) {
    tft.print("CF:");
    File fileHandler = sd.open(fileNameVersion, FILE_WRITE);
    if (fileHandler) {
      fileHandler.close();
      tft.println("   OK");
    } else {
      tft.println("   NOK");
    }
  }
}

void initWiFi() {
  tft.setTextColor(ST7735_WHITE);
  tft.setTextSize(2);
  tft.print("WiFi:");

  // check for the presence of the shield:
  WiFi.setPins(WINC_CS, WINC_IRQ, WINC_RST, WINC_EN);
  if (WiFi.status() == WL_NO_SHIELD) {
    tft.println(" NOK");
  } else {
    tft.println(" OK");
  }
}

/**
   ------------------------------------------
   CLEAR SCREEN
   ------------------------------------------
*/
void clearScreen() {
  tft.fillScreen(ST7735_BLACK);
}

Thanks for your help!

Is there no way to check why I get sometimes this error SD errorCode: 0X43,0X5?

Hi everyone,

I spent precious hours trying to find a solution for the SdFat issue when arduino IDE did not recognize the librery.
I tryed all the suggested possible solutions but nothing worked, and even more, checking every word wrote in the sketch. I'm using the 1.8.2 IDE

Then I noted the IDE recognized the library since the example sketches for the SdFat library were listed in the EXAMPLES menu.

Finally, all I needed to know was that I had to change #include <SdFat.h> to #include "SdFat.h". No matter the .zip file name, neither if the src sub-folder exists or not or if you want to use the .zip or the unzipped one.

I know the topic is old but I wanted to post this in case someone else is looking for answers