I'm using esp-idf 4.4.2, sd card is on SPI, fatfs mounted.
How to check it's free size?
I tried example_get_fatfs_usage in ext_flash_fatfs example, it don't work.
How to check free size on a sd card?
-
- Posts: 4
- Joined: Tue Nov 22, 2022 11:25 am
Re: How to check free size on a sd card?
Are you using this
https://sourcegraph.com/github.com/espr ... ple_main.c
example
try this
int file_space()
{
FATFS *fs;
DWORD fre_clust, fre_sect, tot_sect;
/* Get volume information and free clusters of drive 0 */
int res = f_getfree("0:", &fre_clust, &fs);
/* 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("%10u KiB total drive space.\r\n%10u KiB available.\r\n%10u free clust.\r\n",tot_sect / 2, fre_sect / 2,fre_clust);
return (fre_sect / 2);
}
or have you already tried this
https://sourcegraph.com/github.com/espr ... ple_main.c
example
try this
int file_space()
{
FATFS *fs;
DWORD fre_clust, fre_sect, tot_sect;
/* Get volume information and free clusters of drive 0 */
int res = f_getfree("0:", &fre_clust, &fs);
/* 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("%10u KiB total drive space.\r\n%10u KiB available.\r\n%10u free clust.\r\n",tot_sect / 2, fre_sect / 2,fre_clust);
return (fre_sect / 2);
}
or have you already tried this
Re: How to check free size on a sd card?
Yeah, I'm using that example, and already tried the f_getfree code, which don't work( got both 0 size)
I also tried to use 1: or 2: instead of 0: in f_getfree, they would make the program crash.
Any ideas?
Thanks for replying.
I also tried to use 1: or 2: instead of 0: in f_getfree, they would make the program crash.
Any ideas?
Thanks for replying.
-
- Posts: 4
- Joined: Tue Nov 22, 2022 11:25 am
Re: How to check free size on a sd card?
Re: How to check free size on a sd card?
Sounds good, I'll take a check, thank you.
Who is online
Users browsing this forum: No registered users and 56 guests