[Resolved] Random Error Codes

The SparkFun microSD shields uses pin 8 for SD chip select. Sometimes it will almost work with the wrong chip select pin. This happens if pin 8 floats low.

Try changing this line

const uint8_t chipSelect = SS;

to this

const uint8_t chipSelect = 8;