FATS f_getfree 0 clusters

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

fastlink30
Posts: 42
Joined: Tue Aug 12, 2014 1:25 pm

Re: FATS f_getfree 0 clusters

Post by fastlink30 »

- sdcStart is void, so no return value
- sdcConnect CH_SUCCESS
- f_mount FR_OK
- f_getfree FR_DISK_ERR
Jeroen3
Posts: 35
Joined: Wed Apr 02, 2014 10:14 am

Re: FATS f_getfree 0 clusters

Post by Jeroen3 »

Looping won't help.

Code: Select all

sdcStart(&SDCD1, NULL);
if( sdcConnect(SDCDriver *sdcp) == CH_SUCCESS ){
FRESULT res = f_mount(&SDC_FS, "0:", 1);
if(res == FR_OK ){
chprintf(chp, "mounted succesfully\n");
}else{
chprintf(chp, "mounting failed\n");
}
}else{
chprintf(chp, "sdcConnect failed\n");
}

What has USB to do with this? This is the SDIO peripheral and driver, not usb, not uart, not spi.
Maybe some pins are shared with USB, but the board.h file should have taken care of this.
Also check the DMA channel assigned to sdc and all other used stuff.
Should be defined using this: STM32_SDC_SDIO_DMA_STREAM
colin
Posts: 149
Joined: Thu Dec 22, 2011 7:44 pm

Re: FATS f_getfree 0 clusters

Post by colin »

fastlink30 wrote:at the moment i do:

FATFS *fs2;
FATFS **fsp;

.....

fs2=(FATFS *)&SDC_FS;
*fsp=fs2;
chprintf(chp, "Mount filesystem... ");
chThdSleepMilliseconds(100);
err = f_getfree("/", &clusters, fsp);

ok, brutal, but like this seems correct, inside f_getfree() is called check_fs() wich return 2 (record signature not found)=> FR_NO_FILESYSYEM
... ach!


I don't know if you are still using this code, but the assignment to 'fsp' is bad here. You dereference fsp before assigning it. Consider this:

Code: Select all

        FATFS *fs2;
        FATFS **fsp;
        fs2=(FATFS *)&SDC_FS;
        fsp=&fs2;  // NOT *fsp=fs2;


Yes, pointers-to-pointers can be confusing. But hopefully the compiler warnings and errors will catch it. Use -Wall -Wextra with gcc and heed the warnings.
Post Reply