11 years, 4 months ago.

FATFileSystem problem "FR_NO_FILESYSTEM"

Hello to everybody,

I have an application where I want to read a file from the SD Card (using SDFileSystem) and write it to a USB Device (using MSCFIleSystem).

I have done a little test setting up the two interfaces and I found an error (enabling FATFIleSytem Debug). My code is like this

code example

MSCFileSystem usbFS("msc");
SDFileSystem sdFS(p5,p6,p7,p8,"sd");

FILE* current_fp;

int main () {
    if (isFlashDriveConnected() == true) {   
        current_fp = fopen("/msc/testUSB.txt","w");        
    }
    else {
        current_fp = fopen("/sd/testSD.txt","w");                
    }

    if (current_fp == NULL) {
         error("Cannot write to file");
    }

}

// determine if USB Flash Drive is able to open a file -> so, the FS exists and can be used
bool isFlashDriveConnected() {     
    FILE *fp = NULL;  
    
    fp = fopen("/msc/.exist","w");
    if (fp == NULL) {
        return false;
    }

    fclose(fp);
    fp = NULL;
    return true;
}

The result I get in the console, where I found the error, is (USB Device not connected, SD Card connected)

FATFileSystem(msc) Mounting [msc] on ffs drive [0] FATFileSystem(sd) Mounting [sd] on ffs drive [1]

open(.exist) on filesystem [msc], drv [0] disk_initialize on drv [0] In Host_Init Initializing Host Stack Host Initialized Connect a Mass Storage device ERROR: In Host_EnumDev at Line 385 - rc = -1 Could not enumerate device: -1 f_open('w') failed (3, FR_NO_PATH)

open(testSD.txt) on filesystem [sd], drv [1] f_open('w') failed (11, FR_NO_FILESYSTEM)

Cannot write to file

------------------- If I test MSCFileSystem and SDFileSystem separately, both works ok.

How can I fix the "FR_NO_FILESYSTEM" error?

Thanks!

Ezequiel Aceto

1 Answer

11 years, 4 months ago.

Found my own answer. And the problem is fixed!

ffconf.h has _VOLUMES = 1 as max number of volumes, and FATFIleSystem (The file I was looking at) allows a number of up to 4 logical units.

I fixed it by settings _VOLUMES to the same maxnumber of logical drives that FATFIleSystem can handle.

Accepted Answer