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:
  1. bool SD_getFreeSpace(uint32_t *tot, uint32_t *free)
  2. {
  3.     FATFS *fs;
  4.     DWORD fre_clust, fre_sect, tot_sect;
  5.  
  6.     /* Get volume information and free clusters of drive 0 */
  7.     if(f_getfree("0:", &fre_clust, &fs) == FR_OK)
  8.     {
  9.         /* Get total sectors and free sectors */
  10.         tot_sect = (fs->n_fatent - 2) * fs->csize;
  11.         fre_sect = fre_clust * fs->csize;
  12.  
  13.         *tot = tot_sect / 2;
  14.         *free = fre_sect / 2;
  15.  
  16.         /* Print the free space (assuming 512 bytes/sector) */
  17.         ESP_LOGD(TAG, "%10lu KiB total drive space. %10lu KiB available.", *tot, *free);
  18.  
  19.         return true;
  20.     }
  21.     return false;
  22. }
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

pilidfast-mail wrote:
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.
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: No registered users and 95 guests