- Notifications
You must be signed in to change notification settings - Fork 7.7k
Closed
Labels
Status: StaleIssue is stale stage (outdated/stuck)Issue is stale stage (outdated/stuck)
Description
I use an ESP32 in Arduino environment (more precise: UECIDE). I use both the internal Flash (about 1.4MB) with FFat and an external SD card (32GB) with SD.
When I first mount the Flash with FFat, and then the SD with SD, all calls to totalBytes and freeBytes, usedBytes, resp., show only the values valid for FFat.
When I reverse the order of mounting, so doing SD first, then all comes out correct.
(Note: FFat can't do usedBytes, SD can't do freeBytes.)
#include "FS.h" #include "FFat.h" #include "SD.h" void setup(){ Serial.begin(115200); uint64_t totalB; // total Bytes uint64_t freeB; // free Bytes uint64_t usedB; // used Bytes = total Bytes - free Bytes uint64_t cardSize; // only for SD: size of card //************ First ****************************************** Serial.println("\nMounting FFat Flash"); if (!FFat.begin(false)) { Serial.println("An Error has occurred while mounting FFAT"); return; } // end first ************************************************** //************ Second ***************************************** Serial.println("\nMounting SD card"); if(!SD.begin()){ Serial.println("Card Mount Failed"); return; } //end second*************************************************** Serial.println(); totalB = SD .totalBytes(); usedB = SD .usedBytes(); freeB = totalB - usedB; // no freeBytes in SD cardSize = SD.cardSize() / (1024 * 1024); Serial.printf("SD: total: %llu, free: %llu, used: %llu, card size: %llu \n", totalB, freeB, usedB, cardSize); totalB = FFat.totalBytes(); freeB = FFat.freeBytes(); usedB = totalB - freeB; // no usedBytes in FFat Serial.printf("FFat: total: %llu, free: %llu, used: %llu \n", totalB, freeB, usedB); totalB = SD .totalBytes(); usedB = SD .usedBytes(); freeB = totalB - usedB; // no freeBytes in SD cardSize = SD.cardSize() / (1024 * 1024); Serial.printf("SD: total: %llu, free: %llu, used: %llu, card size: %llu \n", totalB, freeB, usedB, cardSize); totalB = FFat.totalBytes(); freeB = FFat.freeBytes(); usedB = totalB - freeB; // no usedBytes in FFat Serial.printf("FFat: total: %llu, free: %llu, used: %llu \n", totalB, freeB, usedB); } void loop(){}
When the code is run as shown, the outcome is:
Mounting FFat Flash Mounting SD card SD: total: 1454080, free: 4096, used: 1449984, card size: 30735 FFat: total: 1454080, free: 4096, used: 1449984 SD: total: 1454080, free: 4096, used: 1449984, card size: 30735 FFat: total: 1454080, free: 4096, used: 1449984
Irrespective of whether SD or FFat is selected, only the FFat data are shown.
When the sections in the code marked 'First' and 'Second' are switched, then the outcome is this:
Mounting SD card Mounting FFat Flash SD: total: 32211189760, free: 31970983936, used: 240205824, card size: 30735 FFat: total: 1454080, free: 4096, used: 1449984 SD: total: 32211189760, free: 31970983936, used: 240205824, card size: 30735 FFat: total: 1454080, free: 4096, used: 1449984
This is the correct result!
Metadata
Metadata
Assignees
Labels
Status: StaleIssue is stale stage (outdated/stuck)Issue is stale stage (outdated/stuck)