f_getfree fails on assertion if no volume is mounted
-
- Posts: 18
- Joined: Sun Jul 03, 2022 8:35 pm
f_getfree fails on assertion if no volume is mounted
f_getfree calls mount_volume, which calls get_ldnumber, which crashes in lock_volume, if no volume is mounted. The crash is due to an assertion failure of an uninitialized Mutex in xQueueSemaphoreTake, called by ff_mutex_take. Both Mutex[0] and FatFs[0] seem to have an invalid pointer at that time.
Re: f_getfree fails on assertion if no volume is mounted
Hi @maierkomor,
I assume your code looks similar to the FatFS example on the elm-chan.org site:
FATFS *fs;
DWORD fre_clust, fre_sect, tot_sect;
/* Get volume information and free clusters of drive 1 */
res = f_getfree("1:", &fre_clust, &fs);
if (res) die(res);
/* Get total sectors and free sectors */
tot_sect = (fs->n_fatent - 2) * fs->csize;
fre_sect = fre_clust * fs->csize;
/* Print the free space (assuming 512 bytes/sector) */
printf("%10lu KiB total drive space.\n%10lu KiB available.\n", tot_sect / 2, fre_sect / 2);
We have to check the f_getfree() behaviour to confirm whether the issue comes from the IDF locks incorporation to the FatFS, or from the FatFS itself. Will keep you posted, thanks for the report!
I assume your code looks similar to the FatFS example on the elm-chan.org site:
FATFS *fs;
DWORD fre_clust, fre_sect, tot_sect;
/* Get volume information and free clusters of drive 1 */
res = f_getfree("1:", &fre_clust, &fs);
if (res) die(res);
/* Get total sectors and free sectors */
tot_sect = (fs->n_fatent - 2) * fs->csize;
fre_sect = fre_clust * fs->csize;
/* Print the free space (assuming 512 bytes/sector) */
printf("%10lu KiB total drive space.\n%10lu KiB available.\n", tot_sect / 2, fre_sect / 2);
We have to check the f_getfree() behaviour to confirm whether the issue comes from the IDF locks incorporation to the FatFS, or from the FatFS itself. Will keep you posted, thanks for the report!
-
- Posts: 18
- Joined: Sun Jul 03, 2022 8:35 pm
Re: f_getfree fails on assertion if no volume is mounted
Another hint for tracking the issue down. It might be the case that a mount attempt failed before calling the f_getfree. So it might be a case, of incomplete cleanup of the relevant data-structures after a failed mount attempt.
Who is online
Users browsing this forum: MicroController and 232 guests