Get SD card free space not updating?

User avatar
gunar.kroeger
Posts: 143
Joined: Fri Jul 27, 2018 6:48 pm

Get SD card free space not updating?

Postby gunar.kroeger » Fri Mar 29, 2019 7:43 pm

I am able to read SD card free space by using this function:

Code: Untitled.c Select all


bool SD_getFreeSpace(uint32_t *tot, uint32_t *free)
{
FATFS *fs;
DWORD fre_clust, fre_sect, tot_sect;

/* Get volume information and free clusters of drive 0 */
if(f_getfree("0:", &fre_clust, &fs) == FR_OK)
{
/* Get total sectors and free sectors */
tot_sect = (fs->n_fatent - 2) * fs->csize;
fre_sect = fre_clust * fs->csize;

*tot = tot_sect / 2;
*free = fre_sect / 2;

/* Print the free space (assuming 512 bytes/sector) */
ESP_LOGD(TAG, "%10lu KiB total drive space. %10lu KiB available.", *tot, *free);

return true;
}
return false;
}
But even if I remove the SD card after I mounted the card I still get the same values as before removing the card. Is there a way to get free and total space without unmounting and remounting the SD card? I wish to check at least if the SD card has been removed.
Currently I am opening and closing an empty file to do this.
"Running was invented in 1612 by Thomas Running when he tried to walk twice at the same time."

pilidfast-mail
Posts: 1
Joined: Sat Apr 06, 2019 7:54 am

Re: Get SD card free space not updating?

Postby pilidfast-mail » Sat Apr 06, 2019 8:09 am

That's the software bug, nothing to do with hardware. Report the issue, next update might (will) solve it.

User avatar
gunar.kroeger
Posts: 143
Joined: Fri Jul 27, 2018 6:48 pm

Re: Get SD card free space not updating?

Postby gunar.kroeger » Mon Apr 08, 2019 3:20 pm

That's the software bug, nothing to do with hardware. Report the issue, next update might (will) solve it.
https://github.com/espressif/esp-idf/issues/3278
"Running was invented in 1612 by Thomas Running when he tried to walk twice at the same time."

Who is online

Users browsing this forum: Amazon [Bot], Semrush [Bot] and 0 guests