Yes ExFat is supported. Running 64gb exfat usb stick for my tests.
Have to remember windows and sdfat both will format 32gb and above as ExFat. And in the case of windows ntfs or ExFat. Sdfat formatted even has a warning about that
Initializing USB MSC drive...initialization failed!
Initializing USB MSC drive...initialization done.
System Volume Information/
WPSettings.dat 12 13:01 September 28, 2021
IndexerVolumeGuid 76 13:16 September 28, 2021
AData64GB_ExFat.txt 44 13:27 September 28, 2021
done!
Ran DataloggerUSB and timed how long it took from the time I asked for a file list to when it started printing. Well, it took almost 31 seconds before space used got calculated - the directory started printing right after that no delays. So image a larger USB how long it will take. ExFat is a different story so doesn't seem to suffer the same faith.
.
KurtE said:Is there a problem only 30+ seconds?.... Sorry maybe too much rambling here... hope some of this makes sense
if (fatType() == 16 || fatType() == 32) {
sector = m_fatStartSector;
while (todo) {
cache_t* pc = cacheFetchFat(sector++, FsCache::CACHE_FOR_READ);
if (!pc) {
DBG_FAIL_MACRO;
goto fail;
}
n = fatType() == 16 ? m_bytesPerSector/2 : m_bytesPerSector/4;
if (todo < n) {
n = todo;
}
if (fatType() == 16) {
for (uint16_t i = 0; i < n; i++) {
if (pc->fat16[i] == 0) {
free++;
}
}
} else {
for (uint16_t i = 0; i < n; i++) {
if (pc->fat32[i] == 0) {
free++;
}
}
}
todo -= n;
}
} else {
// invalid FAT type
DBG_FAIL_MACRO;
goto fail;
}
setFreeClusterCount(free);
n = fatType() == 16 ? m_bytesPerSector/2 : m_bytesPerSector/4
Last time I checked these functions were all private, so could not call them from external things like our callback.SDFat does have a few functions after it gets the sector count but does not write back to the SD card which guess makes sense - as you said not necessarily maintaind in FSINFO.
1. setfreeclustercount
2. updateFreeClusterCount
and somthing interesting that I just spotted
3. cacheFetchFat
this is all in FatPartition.h.
[B][COLOR="#FF0000"]9/30/21 : p#135[/COLOR][/B] - status update >> [URL="https://forum.pjrc.com/threads/68139-Teensyduino-File-System-Integration-including-MTP-and-MSC?p=289869&viewfull=1#post289869'"][B]Teensyduino-File-System-Integration-including-MTP-and-MSC[/B][/URL]
Did a quick post #1 update adding:
Code:[B][COLOR="#FF0000"]9/30/21 : p#135[/COLOR][/B] - status update >> [URL="https://forum.pjrc.com/threads/68139-Teensyduino-File-System-Integration-including-MTP-and-MSC?p=289869&viewfull=1#post289869'"][B]Teensyduino-File-System-Integration-including-MTP-and-MSC[/B][/URL]
Committed changes to remove all Time library dependency.
https://github.com/KurtE/MTP_Teensy/commit/118577eb4810c254c1bc7bf8c5ef2c441e411a64
100f 20 1 345: 20001 0
MTPD::formatStore called post:0
Writing FAT ................................
Format Done
2001 20 3 345: 20001 0
1005 16 1 346: 20001
131073 1 name:SD_Card
131073 1 name:SD_Card
Would a 1.56-beta2 installer help?
I was imagining doing it several hours ago, but then got into the USB serial issue again, and now I'm having a lot of second thoughts about FS mediaPresent(). Was hoping to get both format() and mediaPresent() into SD.h before an installer, so hopefully all changes can be only needed in MTP and MSC.
Seems to be almost working now - I was using MTP_Test and would not format, kept getting error message not supported. Switched to the simple.ino test sketch and it does say its formating but files remain which Kurt is trying to track down. So not don't think at this point a beta2 installer would help - think we got everything synced from the core at this point.
Interesting think is it does seem to work with a exFat formated SD Card (512GB).
At this point Kurt and I are pulling out our hair.
// List files, format, list files
#include <SD.h>
// change this to match your SD shield or module;
// Teensy 2.0: pin 0
// Teensy++ 2.0: pin 20
// Wiz820+SD board: pin 4
// Teensy audio board: pin 10
// Teensy 3.5 & 3.6 & 4.1 on-board: BUILTIN_SDCARD
const int chipSelect = BUILTIN_SDCARD;
void setup()
{
//Uncomment these lines for Teensy 3.x Audio Shield (Rev C)
//SPI.setMOSI(7); // Audio shield has MOSI on pin 7
//SPI.setSCK(14); // Audio shield has SCK on pin 14
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect.
}
Serial.print("Initializing SD card...");
if (!SD.begin(chipSelect)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
File root = SD.open("/");
printDirectory(root, 0);
Serial.println("Press any key to reformat disk");
while (Serial.read() == -1);
while (Serial.read() != -1) ;
SD.format(0,"*", Serial);
Serial.println("\nNow try listing files again");
while (Serial.read() == -1);
while (Serial.read() != -1) ;
printDirectory(root, 0);
Serial.println("done!");
}
void loop()
{
// nothing happens after setup finishes.
}
void printDirectory(File dir, int numSpaces) {
while (true) {
File entry = dir.openNextFile();
if (! entry) {
//Serial.println("** no more files **");
break;
}
printSpaces(numSpaces);
Serial.print(entry.name());
if (entry.isDirectory()) {
Serial.println("/");
printDirectory(entry, numSpaces + 2);
} else {
// files have sizes, directories do not
unsigned int n = log10(entry.size());
if (n > 10) n = 10;
printSpaces(50 - numSpaces - strlen(entry.name()) - n);
Serial.print(" ");
Serial.print(entry.size(), DEC);
DateTimeFields datetime;
if (entry.getModifyTime(datetime)) {
printSpaces(4);
printTime(datetime);
}
Serial.println();
}
entry.close();
}
}
void printSpaces(int num) {
for (int i = 0; i < num; i++) {
Serial.print(" ");
}
}
void printTime(const DateTimeFields tm) {
const char *months[12] = {
"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
};
if (tm.hour < 10) Serial.print('0');
Serial.print(tm.hour);
Serial.print(':');
if (tm.min < 10) Serial.print('0');
Serial.print(tm.min);
Serial.print(" ");
Serial.print(months[tm.mon]);
Serial.print(" ");
Serial.print(tm.mday);
Serial.print(", ");
Serial.print(tm.year + 1900);
}
Initializing SD card...initialization done.
System Volume Information/
WPSettings.dat 12 10:12 October 5, 2021
IndexerVolumeGuid 76 10:12 October 5, 2021
DSC03359.JPG 2947914 08:17 March 22, 2010
IMG_0105.JPG 2750357 11:25 October 27, 2013
L1020581.psd 2580738 18:00 April 27, 2016
DSC03356.JPG 3355221 08:11 March 22, 2010
DSC03357.JPG 3343737 08:11 March 22, 2010
DSC03361.JPG 3223767 08:44 April 18, 2010
DSC03360.JPG 3161263 08:43 April 18, 2010
IMG_0107.JPG 2969229 11:32 October 27, 2013
Press any key to reformat disk
Writing FAT ................................
Format Done
Now try listing files again
done!
SDClass sdx[nsd];
storage.addFilesystem(SD, sd_str[ii]);
131073 1 name:SD_Card
131073 1 name:SD_Card
19528 RESP:2001(RSP:OK)l: 16 T:20 : 20001
[COLOR="#FF0000"]28006 CMD: 100f(FORMAT_STORE)l: 20 T:21 : 20001 0
MTPD::formatStore called post:0
Writing FAT ................................
Format Done[/COLOR]
MTPStorage::ResetIndex() called
After index test
MTPStorage::CloseIndex called
Index is closed
28328 RESP:2001(RSP:OK)l: 20 T:21 : 20001 0
28332 CMD: 1005(GET_STORAGE_INFO)l: 16 T:22 : 20001
131073 1 name:SD_Card
131073 1 name:SD_Card
28332 RESP:2001(RSP:OK)l: 16 T:22 : 20001
[COLOR="#FF0000"][COLOR="#FF0000"]28878 CMD: 1007(GET_OBJECT_HANDLES)l: 24 T:23 : 10001 0 ffffffff
*** MTPStorage::GenerateIndex called ***
remove called: 0 /mtpindex.dat
MTPStorage::OpenIndex
Index is opened
0: 0 1 0 -1 0 0 /
MTPStorage::OpenIndex
1: 1 1 0 -1 0 0 /[COLOR="#FF0000"][/COLOR]
2: 2 1 0 -1 0 0 /[/COLOR][/COLOR]
** ScanDir called 0 0
>> 3: 0 0 0 0 0 0 mtpindex.dat
** ScanDir called 0 0
** ScanDir called 0 0
28892 RESP:2001(RSP:OK)l: 24 T:23 : 10001 0 ffffffff
28892 CMD: 9803(GET_OBJECT_PROP_VALUE)l: 20 T:24 : 3 dc02 (FORMAT)
28892 RESP:2001(RSP:OK)l: 20 T:24 : 3 dc02
28893 CMD: 9803(GET_OBJECT_PROP_VALUE)l: 20 T:25 : 3 dc41 (PERSISTENT_UID)
28893 RESP:2001(RSP:OK)l: 20 T:25 : 3 dc41
28894 CMD: 1007(GET_OBJECT_HANDLES)l: 24 T:26 : 20001 0 ffffffff
** ScanDir called 1 1
[COLOR="#FF0000"] >> 4: 1 0 0 1 0 8732 FS.h[/COLOR]
** ScanDir called 1 1
** ScanDir called 1 1
28905 RESP:2001(RSP:OK)l: 24 T:26 : 20001 0 ffffffff
28905 CMD: 9803(GET_OBJECT_PROP_VALUE)l: 20 T:27 : 4 dc02 (FORMAT)
28905 RESP:2001(RSP:OK)l: 20 T:27 : 4 dc02
28906 CMD: 9803(GET_OBJECT_PROP_VALUE)l: 20 T:28 : 4 dc41 (PERSISTENT_UID)
28906 RESP:2001(RSP:OK)l: 20 T:28 : 4 dc41
28908 CMD: 9803(GET_OBJECT_PROP_VALUE)l: 20 T:29 : 4 dc03 (PROTECTION)
28908 RESP:2001(RSP:OK)l: 20 T:29 : 4 dc03
28909 CMD: 9803(GET_OBJECT_PROP_VALUE)l: 20 T:2a : 4 dc04 (SIZE)
28911 RESP:2001(RSP:OK)l: 20 T:2a : 4 dc04
28912 CMD: 1008(GET_OBJECT_INFO)l: 16 T:2b : 4
28913 RESP:2001(RSP:OK)l: 16 T:2b : 4
28914 CMD: 9803(GET_OBJECT_PROP_VALUE)l: 20 T:2c : 4 dc01 (STORAGE_ID)
28915 RESP:2001(RSP:OK)l: 20 T:2c : 4 dc01
28916 CMD: 9803(GET_OBJECT_PROP_VALUE)l: 20 T:2d : 4 dc07 (OBJECT NAME)
28918 RESP:2001(RSP:OK)l: 20 T:2d : 4 dc07
28918 CMD: 9803(GET_OBJECT_PROP_VALUE)l: 20 T:2e : 4 dc08 (CREATED)
Create (615c49ae)Date/time:20211005T124846
Create (615c49ae)Date/time:20211005T124846
28922 RESP:2001(RSP:OK)l: 20 T:2e : 4 dc08
28923 CMD: 9803(GET_OBJECT_PROP_VALUE)l: 20 T:2f : 4 dc09 (MODIFIED)
Modify (6159df44)Date/time:20211003T165012
Modify (6159df44)Date/time:20211003T165012
28927 RESP:2001(RSP:OK)l: 20 T:2f : 4 dc09
28928 CMD: 9803(GET_OBJECT_PROP_VALUE)l: 20 T:30 : 4 dc44 (NAME)
28929 RESP:2001(RSP:OK)l: 20 T:30 : 4 dc44
// List files, format, list files
#include <SD.h>
// change this to match your SD shield or module;
// Teensy 2.0: pin 0
// Teensy++ 2.0: pin 20
// Wiz820+SD board: pin 4
// Teensy audio board: pin 10
// Teensy 3.5 & 3.6 & 4.1 on-board: BUILTIN_SDCARD
const int chipSelect = BUILTIN_SDCARD;
void setup()
{
//Uncomment these lines for Teensy 3.x Audio Shield (Rev C)
//SPI.setMOSI(7); // Audio shield has MOSI on pin 7
//SPI.setSCK(14); // Audio shield has SCK on pin 14
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect.
}
Serial.print("Initializing SD card...");
if (!SD.begin(chipSelect)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
File root = SD.open("/");
printDirectory(root, 0);
root.close();
Serial.println("Press any key to reformat disk");
while (Serial.read() == -1);
while (Serial.read() != -1) ;
SD.format(0,'*', Serial);
Serial.println("\nNow try listing files again");
// while (Serial.read() == -1);
// while (Serial.read() != -1) ;
root = SD.open("/");
printDirectory(root, 0);
Serial.println("done!");
}
void loop()
{
// nothing happens after setup finishes.
}
void printDirectory(File dir, int numSpaces) {
while (true) {
File entry = dir.openNextFile();
if (! entry) {
//Serial.println("** no more files **");
break;
}
printSpaces(numSpaces);
Serial.print(entry.name());
if (entry.isDirectory()) {
Serial.println("/");
printDirectory(entry, numSpaces + 2);
} else {
// files have sizes, directories do not
unsigned int n = log10(entry.size());
if (n > 10) n = 10;
printSpaces(50 - numSpaces - strlen(entry.name()) - n);
Serial.print(" ");
Serial.print(entry.size(), DEC);
DateTimeFields datetime;
if (entry.getModifyTime(datetime)) {
printSpaces(4);
printTime(datetime);
}
Serial.println();
}
entry.close();
}
}
void printSpaces(int num) {
for (int i = 0; i < num; i++) {
Serial.print(" ");
}
}
void printTime(const DateTimeFields tm) {
const char *months[12] = {
"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
};
if (tm.hour < 10) Serial.print('0');
Serial.print(tm.hour);
Serial.print(':');
if (tm.min < 10) Serial.print('0');
Serial.print(tm.min);
Serial.print(" ");
Serial.print(months[tm.mon]);
Serial.print(" ");
Serial.print(tm.mday);
Serial.print(", ");
Serial.print(tm.year + 1900);
}
Initializing SD card...initialization done.
System Volume Information/
WPSettings.dat 12 13:47 October 5, 2021
IndexerVolumeGuid 76 13:47 October 5, 2021
FS.h 8732 16:50 October 3, 2021
Press any key to reformat disk
Writing FAT ................................
Format Done
Now try listing files again
System Volume Information/
WPSettings.dat 12 13:47 October 5, 2021
IndexerVolumeGuid 76 13:47 October 5, 2021
done!