Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF5 MSC Example with QSPI + SD Card

Dear all,

I am trying to run the MSC example in order to learn how to develop an application with MSC capabilities in the future. I have already run the example in its default configuration and I have also created the SD Card supplementary functions with FatFs (Initialize / Mount / Create File etc.) by consulting the FatFs example. It seems both configurations work if I activate one at a time. But I cannot make them work simultaneously and copy files or even display them both in my PC as mass storages.

My problem is how to initialize them correctly and mount them with FatFs.

What am I missing? Are there any similar examples available?

Thank you in advance for your assistance,

Aris.

Parents
  • Hi Aris

    If you mean you want to be able to access the card from the PC over USB and locally from the nRF device at the same time, then this is not possible unfortunately. 

    The MSC class does not support multiple users accessing the flash device at the same time, this is a limitation in the specification. 

    In a similar way, if you connect a phone, camera or other accessory to your PC over MSC to access the memory card the card will no longer be available from the phone until you disconnect the PC.

    Best regards
    Torbjørn 

  • Hello,

    Thank you for your reply. Actually, I do not mean that. I want to use both QSPI Flash and an external SD Card as mass storages. 

    The correct way is to initialize the SD Card is like the one implemented for the initialzation of QSPI? What modifications should I do ?

    For example I have created the following SD Card Init Function:

    static bool fatfs_initSD(void)
    {
      FRESULT ff_result;
      DSTATUS disk_state = STA_NOINIT;

       //
       // Initialize FATFS disk I/O interface by providing the block device.              //    <--------------- Is the Initialization of the     //                                                                                                                     //                           FatFs correct ?
       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));

      NRF_LOG_INFO("Initializing disk 1 (SD)...");
      for (uint32_t retries = 3; retries && disk_state; --retries)
      {
        disk_state = disk_initialize(0);
      }

      if (disk_state)
      {
        NRF_LOG_ERROR("SD Card Disk initialization failed.");
        return false;
      }

      NRF_LOG_INFO("Mounting SD volume...");
      ff_result = f_mount(&m_filesystem_SD, "1:", 1);       // <------------------------------ Is this Correct, if the default disk is                                                                                            //                                       assigned to the QSPI Flash volume?
      if (ff_result != FR_OK)
      {
         if (ff_result == FR_NO_FILESYSTEM)
         {
           NRF_LOG_ERROR("Mount failed. SD Filesystem not found. Please format device.");
         }
         else
         {
           NRF_LOG_ERROR("SD Mount failed: %u", ff_result);
         }
         return false;

       }

        return true;
    } // End Of fatfs_initSD()

  • Hi 

    So if I understand you correctly you want to use the fatFS module in parallel both for the SD card and the external memory card?

    Unfortunately this is not possible, as the fat library used in the SDK doesn't have a concept of multiple users where you can initialize it several times for different users/contexts. 

    Basically you would have to uninitialize the current disk and initialize the other one each time you want to change from accessing one or the other. 

    Best regards
    Torbjørn

  • Hello,

     Thank you very much for your response. I understand now.

    Best Regards,

    Aris.

  • Hi Aris

    I am happy to help, I only wish I had better news for you ;)

    I wish you the best of luck with your project Slight smile

    Best regards
    Torbjørn

Reply Children
No Data
Related