SdFat, SparkFun microSD Transflash Breakout & Boron

Hi All,

I realise there are multiple posts around this topic, but did not find any specifically that relates to this issue with a boron and the SparkFun microSD Transflash Breakout.

My Boron is wired as follows:
A2 - CS
A3 - SCK
A4 - DO
A5 - DI
3V3 - VCC

The correct wiring as @ScruffR suggested for this app is (SD - BORON):
DI - D12 (MO)
DO - D11 (MI)
SCK - D13 (SCK)
CS - A2 (A2 as it’s set in app, Scruff mentioned A5 is default)
3v3 - VCC

The Serial is printing out the following:

Can't access SD card. Do not reformat.
No card, wrong chip select pin, or SPI problem?
SD errorCode: 0X20,0XFF

Apologies if I should have posted this in an existing thread. Have I made any obvious mistakes?

The Micro SD seems to be formatted as FAT32 and I am testing with the following particle code:

// This #include statement was automatically added by the Particle IDE.
#include <SdFat.h>

// Pick an SPI configuration.
// See SPI configuration section below (comments are for photon).
// Setup SPI configuration.
// Primary SPI with DMA
// SCK => A3, MISO => A4, MOSI => A5, SS => A2 (default)
SdFat sd;
const uint8_t chipSelect = A2;

// Secondary SPI with DMA
// SCK => D4, MISO => D3, MOSI => D2, SS => D1
//SdFat sd(1);
//const uint8_t chipSelect = D1;

// // Primary SPI with Arduino SPI library style byte I/O.
// // SCK => A3, MISO => A4, MOSI => A5, SS => A2 (default)
// // SdFatLibSpi sd;
// const uint8_t chipSelect = SS;

// // Software SPI.  Use any digital pins.
// // MISO => A4, MOSI => A5, SCK => A3, SS => A2
// // SdFatSoftSpi<A4, A5, A3> sd;
// const uint8_t chipSelect = A2;



File myFile;

void setup() {

  // Wait for USB Serial 
  while (!Serial) {
 // Serial.println("Type any character to start");
  //while ( <= 0) {
   // SysCall::yield();

  // Initialize SdFat or print a detailed error message and halt
  // Use half speed like the native library.
  // Change to SPI_FULL_SPEED for more performance.
  if (!sd.begin(chipSelect, SPI_FULL_SPEED)) {

  // open the file for write at end like the "Native SD library"
  if (!"test.txt", O_RDWR | O_CREAT | O_AT_END)) {
    sd.errorHalt("opening test.txt for write failed");
  // if the file opened okay, write to it:
  Serial.print("Writing to test.txt...");
  myFile.println("testing 1, 2, 3.");
  myFile.printf("fileSize: %d\n", myFile.fileSize());
  // close the file:

  // re-open the file for reading:
  if (!"test.txt", O_READ)) {
    sd.errorHalt("opening test.txt for read failed");
  Serial.println("test.txt content:");

  // read from the file until there's nothing else in it:
  int data;
  while ((data = >= 0) {
  // close the file:

void loop() {
  // nothing happens after setup

On the Boron the SPI pins are as shown here

On the board they are labled SCK, MO, MI and A5 for the default SS but you can use any (including A2).

The DO (Data Out) pin on the microSD wants to be connected to MI (Master In) and DI (Data In) to MO (Master Out).

1 Like

Thanks for your help, all sorted now.

1 Like