Page 2 of 2

Re: FATS f_getfree 0 clusters

Posted: Sat Jan 17, 2015 2:44 pm
by fastlink30
- sdcStart is void, so no return value
- sdcConnect CH_SUCCESS
- f_mount FR_OK
- f_getfree FR_DISK_ERR

Re: FATS f_getfree 0 clusters

Posted: Mon Jan 19, 2015 7:52 am
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

Re: FATS f_getfree 0 clusters

Posted: Tue Feb 03, 2015 10:35 pm
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.