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

nRF52840 SDK16 - USB MSC example - How to check if FAT volume exists

Hi everyone,

I am working on the USB MSC example. I am able to create files and perform read and write operations. 

Now what I want is to check if there is a FAT volume when the system restarts. Is there any function for checking this? Because I do not want to accidentally format the disk (call to f_mkfs())

So, how could I ensure during start up that the disk has a FAT volume?

Thanks in advance

Nick

Parents Reply
  • Nikosant03 said:
    Everytime the system reset/restart I have to call the f_mount() function?

    Yes, if you want to perform any file/directory operations. From the description of the function: "Prior to perform any file/directory operations, a filesystem object needs to be registered with f_mount function for the logical drive."

    Nikosant03 said:
    what if the disk is already be mounted and I call f_mount() again? Is it safe? Re-mount the default drive will reinitialize the filesystem.. Could this lead to data loss?

    That should be fine, it will just re-init the filesystem object (FATFS* fs). However, note the following line from the description: "If there is any open object of file or directory on the logical drive, the object will be invalidated by this function."

Children
Related