This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SDCard / FatFS Example Problem (and partial solution)

I'm starting to work on SDCard reading, and was having issues.

My problem was that in diskio_blkdev.c, this code:

if (err_code == NRF_SUCCESS)
{
    while (m_drives[drv].busy)
    {
        m_drives[drv].config.wait_func();
    }
    
    // right here...
}

Where I've got the "right here", m_drives[drv].last_result would always be NRF_BLOCK_DEV_RESULT_IO_ERROR (1), which matched a lot of the other questions.

I went through all the other SDCard/FatFS example problems in devzone:

  • I set my NRFX_SPIM_MISO_PULL_CFG to NRF_GPIO_PIN_PULLUP (it had previously been pulldown)
  • I verified all my wires (about 8in-long 0.1in hobby connectors) were in solidly
  • I double-checked that all my wires were in the right GPIO pins
  • I double-checked that the actual pins used for the APP_SDCARD_CONFIG macro in main.c matched the pins that the example docs expected
  • I used Windows and quick-formatted my 32gb sandisk SD Card to Fat32 / 4096-byte block size (it was previously Fat32 / unknown)
  • I lowered my APP_SDCARD_FREQ_INIT and APP_SDCARD_FREQ_DATA to 33554432 (thus setting the SPI frequency to 125khz)

But after all that, it was still failing.  Stay tuned for the solution.

Related