Very important!!!
The Due's SPI is on the 6 pin ICSP header, not shared with the I/O pins as on the Uno etc. From that pinout you should be able to connect wires to the correct places on whatever shield you use, just not plugged directly. Personally I build my own shield once I noticed the Due and my SD shields were not compatible, soldered some wires to a micro SD to SD adapter and was rolling.
ALSO VERY IMPORTANT!!!
While the Arduino Due is 3.3v, the VCC pin on the ICSP is 5V!!! The Sd card is 3.3v so do not connect to that pin...
Here is a simple data logger, with some write error reporting...let us know how it goes!!!
#include <SdFat.h>
const int chipSelect = 8;
SdFat sd;
SdFile myFile;
void setup(){
Serial2.begin(115200);
pinMode(8, OUTPUT);
sd.begin(chipSelect, SPI_FULL_SPEED);
if(!myFile.open("test.txt", O_RDWR | O_CREAT | O_AT_END)) //To print an error message when boot up and it can't write to the SD file
Serial.println("AHHHHHHHHHH File open ERRORRRR!");
else{
String x = "Loggin Started";
Serial.print(x);
for(int i=0;i<x.length();i++) //Writes to text file
myFile.write(x[i]);
myFile.sync(); //Actual write command from write buffer
if(!myFile.getWriteError()){ //Check for writes error
digitalWrite(13, LOW); //Goes Low when no error
}
else if(myFile.getWriteError()){ //If write error, turn LED on and Write Error message
myFile.clearWriteError(); //clear error flag
digitalWrite(13, HIGH); //Goes high if error LED onboard
}
}
}
void loop(){
while(Serial2.available() > 0){ //The source of Data to be logged
char tempChar = Serial2.read(); //The source of Data to be logged
String inputString = "";
inputString += tempChar;
if(tempChar == 10){
for(int i=0;i<inputString.length();i++) //Writes bytes of Serial String to buffer
myFile.write(inputString[i]);
myFile.sync(); //Writes to File
if(!myFile.getWriteError()){ //Check for writes error
digitalWrite(13, LOW); //Use onboard LED for Error clear
}
else if(myFile.getWriteError()){ //If write error, turn LED
myFile.clearWriteError(); //Clear error flag
digitalWrite(13, HIGH); //Use onboard LED for Error Flag
sd.begin(chipSelect, SPI_FULL_SPEED); //Re-initiallize SD after an error
myFile.open("test.txt", O_RDWR | O_CREAT | O_AT_END); //Reopen file after a write error
}
inputString = ""; //Clear the buffer string
}
}
}