Figure it out. The SD library forced SPI speed to SPI_HALF_SPEED which, for some reason, isn't working. If I change it to the value '2' instead, the above sketch works fine. From SD.cpp:
boolean SDClass::begin(uint8_t csPin) {
/*
Performs the initialisation required by the sdfatlib library.
Return true if initialization succeeds, false otherwise.
*/
return card.init(SPI_HALF_SPEED, csPin) &&
volume.init(card) &&
root.openRoot(volume);
}
If I change that single line to:
return card.init(2, csPin) &&
... everything works.
So the question now is, why won't SPI_HALF_SPEED work? Is it because of the hardware being used? I'm passing signals through a logic level converter and then to the breakout.
And if it IS the hardware, what are my options? A different breakout? I don't want to have to be editing the library files every time I need to install/upgrade the Arduino IDE. Seems stupid.
SD.h is just a wrapper for an old version of my SdFfat library so that is what you are using in both cases.
card.init(2, csPin) runs the card at 1/4 speed. You have an SPI problem, maybe your wiring is not clean enough to run at high speed.
SD errorCode: 0X10
SD errorData: 0X1
This is a read error for one of the SD card's info registers. This is almost always due to problems with the SPI bus.
The standard SD.h wrapper does not allow you to set the SPI bus speed, it always runs at 1/2 speed. New versions of SdFat allow the bus speed to be set with the second argument of sd.begin(csPin, speed).
You will be "corrupting your cards" unless you fix the SPI problem or run the SPI bus at very slow speeds.
fat16lib:
card.init(2, csPin) runs the card at 1/4 speed. You have an SPI problem, maybe your wiring is not clean enough to run at high speed.
I'm assuming it's because I'm passing the signals through a level converter to go from 5V to 3V3 and back. I'm waiting for a different card breakout that has a hex converter on it, see if that makes any difference.
Ok, that was the problem. I replaced the lvel converter for a TXB0108 (bidirectional voltage-level translator) and SdInfo now works both as SPI_HALF_SPEED as well as at SPI_FULL_SPEED. Thanks folks!