How to debug failure of SD.open()

I migrated to an Arduino Due several months ago to get a lot bigger program space because SD card writing was failing and hours of fiddling seemed to indicate very vaguely the same “memory problem”.

Right now I am assembling an CO2 mapper that is basically a DUE breadboard with an Adafruit SD card and real time clock, a Adafruit barometer, an Adafruit GPS and a CO2meter.com CO2 meter sending out serial data.

Each of the breakout boards are already working with separate programs. I have done the classic task of getting each subsystem running and observed to work correctly. Now I am assembling the system by copying the key parts of each subsystem to make the desired assembly.

The idea of the mapper is to write strings of time, date and data out to the SD card.

The last component program I merged was the code for the Adafruit SD card and real time clock. After adding in the SD card code, I immediately get a failure “Error opening the dataFile”.

The working subsystem program has a compiler program size of 47,020 bytes (8% of program storage space).
The mapper program that is failing has a compiler program size of 42,008 bytes.

What is catching my attention is the process of opening a filehandle seems to be failing.
The first part of making a filehandle for writing is this invocation in setup()
File dataFile;

Later the program gets a file handle as follows:
dataFile = SD.open(“test”, FILE_WRITE);

So far, this thing called dataFile always seems to come back as a zero 0.
As in "Serial.print(dataFile); # Always is a 0

What drives me nuts is I fought with this elusive SD card failure problem months ago when working with a Mega 1280.

Is there a bug that is avoided by changing the order of loading of libraries? Which two libraries and which must load last?

Is the use of a near generic term “File” the basis for a search process failing?

Both of my programs have 2^^15 byte size. Is there a problem with an int pointer that is actually only 15 usable bits long?

I ask in advance: Don’t post obscure code fragments to these questions. Also, Paul S. please do not post regarding this comment.

Is there a bug that is avoided by changing the order of loading of libraries?

No. The linker decides the order that functions in the .o files that the compiler produced will be loaded (basically, in the order that they are called).

Is the use of a near generic term "File" the basis for a search process failing?

What search process?

Both of my programs have 2^^15 byte size.

What does this mean? A byte is always 8 bits, on all Arduinos.

This appears to be a new problem, so I have split the post.

... very vaguely the same "memory problem".

That's just guesswork.

Please post your code, like the other poster did.

How to use this forum

You may possibly not be opening the SD library, or not opening it properly, your SPI might be too fast. This is all guesswork when you cherry-pick lines of code to show us,

http://snippets-r-us.com/

Thank you Nick and thank you Paul.
Your suggestion was correct, I had commented out or deleted the SD.begin(chipSelect); library call.
If one does not make that library call... writing to the SD card does not work.

Thanks to your suggestions Nick I have got "first light" on my home science atmospheric carbon dioxide concentration mapper.

Here are a few lines of data:

# seconds unixtime CO2 ppm GPGGA , utc , longitude , NorS , latitude , WorE , fixquality , satellites , horizdilutprec , altitude , meters , heighthofgeoid  , meters  , zeroasterisk
0 1413155190  527 ppm GPGGA , 060701.000 , 3730.5509 , N , 12228.3721 , W , fixquality2 , 13 , 0.78 , 36.6 , M , -25.9 , M , 0000 , 0000*
4 1413155205  524 ppm GPGGA , 060716.000 , 3730.5507 , N , 12228.3712 , W , fixquality2 , 12 , 0.86 , 36.5 , M , -25.9 , M , 0000 , 0000*
19 1413155220  520 ppm GPGGA , 060731.000 , 3730.5507 , N , 12228.3712 , W , fixquality2 , 11 , 0.86 , 36.5 , M , -25.9 , M , 0000 , 0000*
34 1413155235  517 ppm GPGGA , 060746.000 , 3730.5508 , N , 12228.3712 , W , fixquality2 , 10 , 0.91 , 36.5 , M , -25.9 , M , 0000 , 0000*

As soon as I arrange a battery, I am going to take this puppy out and start gathering data. Thank you very much.