Hello, I am working on an Arduino art instillation on Arduino UNO with an educational shield that involves LEDs and speakers, but the speakers have had problems playing the song from the SD card. I tried using the CardInfo sketch, and it always says this:
Initializing SD card...Wiring is correct and a card is present.
Card type: SD2
Could not find FAT16/FAT32 partition.
Make sure you've formatted the card
I have looked at other posts similar to this and have tried checking my SD library, got a brand new 32 GB SD card, and tried using other SD Card formatters beside the one on Windows and it still says the same thing. I am new to Arduino so if anyone has any tips/recommendations please let me know
This could be just a stupid question, but did you format your SD card with FAT (16 or 32)?
I can't remember where I got this information from, but it is recommended to format SD cards using the SD Card Association's formatter, rather than any other.
You can get it from https://www.sdcard.org/downloads/formatter/
You could also try SdFat. It may work with FATex format to 32GB.
Try this test. Don't know what pin you are using for the CS. This uses D10.
#include <SdFat.h>
SdFat sd;
void setup() {
Serial.begin(9600);
if(!sd.begin(10)) {
Serial.println("SD init fail");
while(1);
}
Serial.println("SD ok");
}
void loop() {
}
Hi bojan, yes I did format the SD card to fat32 (since its 32GB). I quick formatted it and overwrote it, and still it says that it can't find the right partition.
I did use the SD Card Associations formatter along with the other ones I've tried, but still, the same thing...
So, I just downloaded the SdFat library today and used the QuickStart example code, and it still shows the same issue. 
// Quick hardware test for SPI card access.
//
#include <SPI.h>
#include "SdFat.h"
#include "sdios.h"
// SD_FAT_TYPE = 0 for SdFat/File as defined in SdFatConfig.h,
// 1 for FAT16/FAT32, 2 for exFAT, 3 for FAT16/FAT32 and exFAT.
#define SD_FAT_TYPE 3
//
// Set DISABLE_CHIP_SELECT to disable a second SPI device.
// For example, with the Ethernet shield, set DISABLE_CHIP_SELECT
// to 10 to disable the Ethernet controller.
const int8_t DISABLE_CHIP_SELECT = -1;
//
// Test with reduced SPI speed for breadboards. SD_SCK_MHZ(4) will select
// the highest speed supported by the board that is not over 4 MHz.
// Change SPI_SPEED to SD_SCK_MHZ(50) for best performance.
#define SPI_SPEED SD_SCK_MHZ(4)
//------------------------------------------------------------------------------
#if SD_FAT_TYPE == 0
SdFat sd;
File file;
#elif SD_FAT_TYPE == 1
SdFat32 sd;
File32 file;
#elif SD_FAT_TYPE == 2
SdExFat sd;
ExFile file;
#elif SD_FAT_TYPE == 3
SdFs sd;
FsFile file;
#else // SD_FAT_TYPE
#error Invalid SD_FAT_TYPE
#endif // SD_FAT_TYPE
// Serial streams
ArduinoOutStream cout(Serial);
// input buffer for line
char cinBuf[40];
ArduinoInStream cin(Serial, cinBuf, sizeof(cinBuf));
// SD card chip select
int chipSelect;
void cardOrSpeed() {
cout << F("Try another SD card or reduce the SPI bus speed.\n");
cout << F("Edit SPI_SPEED in this program to change it.\n");
}
void clearSerialInput() {
uint32_t m = micros();
do {
if (Serial.read() >= 0) {
m = micros();
}
} while (micros() - m < 10000);
}
void reformatMsg() {
cout << F("Try reformatting the card. For best results use\n");
cout << F("the SdFormatter program in SdFat/examples or download\n");
cout << F("and use SDFormatter from www.sdcard.org/downloads.\n");
}
void setup() {
Serial.begin(9600);
// Wait for USB Serial
while (!Serial) {
yield();
}
cout << F("\nSPI pins:\n");
cout << F("MISO: ") << int(MISO) << endl;
cout << F("MOSI: ") << int(MOSI) << endl;
cout << F("SCK: ") << int(SCK) << endl;
cout << F("SS: ") << int(SS) << endl;
#ifdef SDCARD_SS_PIN
cout << F("SDCARD_SS_PIN: ") << int(SDCARD_SS_PIN) << endl;
#endif // SDCARD_SS_PIN
if (DISABLE_CHIP_SELECT < 0) {
cout << F(
"\nBe sure to edit DISABLE_CHIP_SELECT if you have\n"
"a second SPI device. For example, with the Ethernet\n"
"shield, DISABLE_CHIP_SELECT should be set to 10\n"
"to disable the Ethernet controller.\n");
}
cout << F(
"\nSD chip select is the key hardware option.\n"
"Common values are:\n"
"Arduino Ethernet shield, pin 4\n"
"Sparkfun SD shield, pin 8\n"
"Adafruit SD shields and modules, pin 10\n");
}
bool firstTry = true;
void loop() {
// Read any existing Serial data.
clearSerialInput();
if (!firstTry) {
cout << F("\nRestarting\n");
}
firstTry = false;
cout << F("\nEnter the chip select pin number: ");
while (!Serial.available()) {
yield();
}
cin.readline();
if (cin >> chipSelect) {
cout << chipSelect << endl;
} else {
cout << F("\nInvalid pin number\n");
return;
}
if (DISABLE_CHIP_SELECT < 0) {
cout << F(
"\nAssuming the SD is the only SPI device.\n"
"Edit DISABLE_CHIP_SELECT to disable another device.\n");
} else {
cout << F("\nDisabling SPI device on pin ");
cout << int(DISABLE_CHIP_SELECT) << endl;
pinMode(DISABLE_CHIP_SELECT, OUTPUT);
digitalWrite(DISABLE_CHIP_SELECT, HIGH);
}
if (!sd.begin(chipSelect, SPI_SPEED)) {
if (sd.card()->errorCode()) {
cout << F(
"\nSD initialization failed.\n"
"Do not reformat the card!\n"
"Is the card correctly inserted?\n"
"Is chipSelect set to the correct value?\n"
"Does another SPI device need to be disabled?\n"
"Is there a wiring/soldering problem?\n");
cout << F("\nerrorCode: ") << hex << showbase;
cout << int(sd.card()->errorCode());
cout << F(", errorData: ") << int(sd.card()->errorData());
cout << dec << noshowbase << endl;
return;
}
cout << F("\nCard successfully initialized.\n");
if (sd.vol()->fatType() == 0) {
cout << F("Can't find a valid FAT16/FAT32/exFAT partition.\n");
reformatMsg();
return;
}
cout << F("Can't determine error type\n");
return;
}
cout << F("\nCard successfully initialized.\n");
cout << endl;
uint32_t size = sd.card()->sectorCount();
if (size == 0) {
cout << F("Can't determine the card size.\n");
cardOrSpeed();
return;
}
uint32_t sizeMB = 0.000512 * size + 0.5;
cout << F("Card size: ") << sizeMB;
cout << F(" MB (MB = 1,000,000 bytes)\n");
cout << endl;
if (sd.fatType() <= 32) {
cout << F("\nVolume is FAT") << int(sd.fatType());
} else {
cout << F("\nVolume is exFAT");
}
cout << F(", Cluster size (bytes): ") << sd.vol()->bytesPerCluster();
cout << endl << endl;
cout << F("Files found (date time size name):\n");
sd.ls(LS_R | LS_DATE | LS_SIZE);
if ((sizeMB > 1100 && sd.vol()->sectorsPerCluster() < 64) ||
(sizeMB < 2200 && sd.vol()->fatType() == 32)) {
cout << F("\nThis card should be reformatted for best performance.\n");
cout << F("Use a cluster size of 32 KB for cards larger than 1 GB.\n");
cout << F("Only cards larger than 2 GB should be formatted FAT32.\n");
reformatMsg();
return;
}
// Read any extra Serial data.
clearSerialInput();
cout << F("\nSuccess! Type any character to restart.\n");
while (!Serial.available()) {
yield();
}
}
I should also mention that I tried using different ChipSelect pins to see if any would work beside 10,4, and 8, and this is what I got from all of them:
Card successfully initialized.
Can't find a valid FAT16/FAT32/exFAT partition.
Try reformatting the card. For best results use
the SdFormatter program in SdFat/examples or download
and use SDFormatter from www.sdcard.org/downloads.
Restarting
Enter the chip select pin number:
Try using the most recent version of SD Card Formatter. At the time I used version 5.0.2
When you are going to format it, use the option: CHS format size adjustment. It will take a while, but it is very likely that your SD card will be recovered.
When I tried clicking the CHS format size adjustment option, it was greyed out. What should I do?
Since you have SdFat available, you should use the Formatter example in that library. It's better than the Association formatter.
So, when I tried using the SdFat formatter, it says this:
Warning, all data on the card will be erased.
Enter 'Y' to continue: Y
error: card init failed.
Invalid SD_CONFIG
I don't know what to suggest except that the CS line may be wrong. Is it possible we have a power problem? Which SD module are you using?