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

Using ExFAT micro SD card

I am using the nRF52832 chip with an SDI connected microSD device.  I am able to communicate with the microSD card formatted as FAT32, store data, read data all with the FATFS software in the DSK15.3.0 SDK without error.  I want to be able to use a larger microSD card but when I format the card as ExFAT, I get a "mount failed" error.  Does the FATFS library auto identify the formatting of the card or am I supposed to set a flag somewhere letting it know the disk is ExFAT formatted?  Here is the code I am using to open the device:

static bool fatfs_init() {

  static diskio_blkdev_t drives[] =
      {DISKIO_BLOCKDEV_CONFIG(NRF_BLOCKDEV_BASE_ADDR(m_block_dev_sdc, block_dev), NULL)};
  diskio_blockdev_register(drives, ARRAY_SIZE(drives));

  send_output_debug("Initializing disk 0 (SDC)...\n");
  for (uint32_t retries = 3; retries && disk_state; --retries) {
    disk_state = disk_initialize(0);
  }
  if (disk_state) {
    send_output_debug("Disk initialization failed.\n");
    return (false);
  }

  uint32_t blocks_per_mb = (1024uL * 1024uL) / m_block_dev_sdc.block_dev.p_ops->geometry(&m_block_dev_sdc.block_dev)->blk_size;
  uint32_t capacity = m_block_dev_sdc.block_dev.p_ops->geometry(&m_block_dev_sdc.block_dev)->blk_count / blocks_per_mb;
  char str[30];
  snprintf(str, 30, "Capacity(MB): %'d", capacity);
  send_output_debug(str);
  send_output_debug("\n");

  send_output_debug("Mounting volume...\n");
  ff_result = f_mount(&fs, "", 1);
  if (ff_result) {
    send_output_debug("Mount failed.");
    return (false);
  }
  return (true);
}
Related