Are you using the latest version of SdFs? If so, you really proved "it depends on the uSD".
Yes, I downloaded is again for this test.
I agree, good selection of uSD is key.
Are you using the latest version of SdFs? If so, you really proved "it depends on the uSD".
Yes, I downloaded is again for this test.
I agree, good selection of uSD is key.
Type any character to start
init time: 7 ms
Card type: SDXC
Manufacturer ID: 0X1B
OEM ID: SM
Product: 00000
Version: 1.0
Serial number: 0X2A5DED9C
Manufacturing date: 7/2010
cardSize: 64021.86 MB (MB = 1,000,000 bytes)
flashEraseSize: 128 blocks
eraseSingleBlock: true
OCR: 0XC0FF8000
SD Partition Table
part,boot,bgnCHS[3],type,endCHS[3],start,length
1,0X0,0XA,0X9,0X2,0X7,0XFE,0XFF,0XFF,32768,125009920
2,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0,0
3,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0,0
4,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0,0
Scanning FAT, please wait.
Volume is exFAT
sectorsPerCluster: 256
clusterCount: 488192
freeClusterCount: 421892
fatStartSector: 49152
dataStartSector: 65536
10c10
< Serial number: 0X365DDB9C
---
> Serial number: 0X2A5DED9C
31c31
< freeClusterCount: 480120
---
> freeClusterCount: 421892
2c2
< init time: 7 ms
---
> init time: 9 ms
10c10
< Serial number: 0X365DDB9C
---
> Serial number: 0X7853CE88
13c13
< cardSize: 64021.86 MB (MB = 1,000,000 bytes)
---
> cardSize: 64087.92 MB (MB = 1,000,000 bytes)
21c21
< 1,0X0,0XA,0X9,0X2,0X7,0XFE,0XFF,0XFF,32768,125009920
---
> 1,0X0,0XA,0X9,0X2,0X7,0XFE,0XFF,0XFF,32768,125138944
30,31c30,31
< clusterCount: 488192
< freeClusterCount: 480120
---
> clusterCount: 488696
> freeClusterCount: 488375
What card are you using?
Assuming an SDIO interface.
type any character to start
init time: 155 ms
Card type: SDHC
Manufacturer ID: 0X3
OEM ID: SD
Product: SU32G
Version: 8.0
Serial number: 0X75BE5A20
Manufacturing date: 7/2013
cardSize: 31914.98 MB (MB = 1,000,000 bytes)
flashEraseSize: 128 blocks
eraseSingleBlock: true
OCR: 0XC0FF8000
SD Partition Table
part,boot,bgnCHS[3],type,endCHS[3],start,length
1,0X0,0X82,0X3,0X0,0X7,0XFE,0XFF,0XFF,8192,62325760
2,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0,0
3,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0,0
4,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0,0
Scanning FAT, please wait.
Volume is exFAT
sectorsPerCluster: 64
clusterCount: 973680
freeClusterCount: 973625
fatStartSector: 10240
dataStartSector: 18432
type any character to start
type any character to start
init time: 111 ms
Card type: SDHC
Manufacturer ID: 0X3
OEM ID: SD
Product: SU32G
Version: 8.0
Serial number: 0X45773607
Manufacturing date: 5/2013
cardSize: 31914.98 MB (MB = 1,000,000 bytes)
flashEraseSize: 128 blocks
eraseSingleBlock: true
OCR: 0XC0FF8000
SD Partition Table
part,boot,bgnCHS[3],type,endCHS[3],start,length
1,0X0,0X82,0X3,0X0,0XC,0XFE,0XFF,0XFF,8192,62325760
2,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0,0
3,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0,0
4,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0,0
Scanning FAT, please wait.
Volume is FAT32
sectorsPerCluster: 64
clusterCount: 973584
freeClusterCount: 973517
fatStartSector: 9362
dataStartSector: 24576
Bill,
how to truncate file when closing?
I note that final file-size is also pre-allocated size.
bool ExFatFile::truncate ( )
Truncate a file at the current file position.
Returns
The value true is returned for success and the value false is returned for failure.
bool ExFatFile::truncate ( uint64_t length )
inline
Truncate a file to a specified length. The current file position will be set to end of file.
Parameters
[in] length The desired length for the file.
Returns
The value true is returned for success and the value false is returned for failure.
ValidDataLength determines how much actual data written to the file. Implementation shall update this field as data has been written. The data beyond the valid data length is undefined and implementation shall return zeros.
You can use exFAT on smaller cards.I'm confused (so what else is new?) - does exFAT only work on >32GB SD cards? I tried Teensy36FifoLogger.ino on my Sandisk Extreme 32GB, no joy, and SDFormatter insists on formatting it with FAT32.
I note that FsFile does not have preAllocate.
any workaround for FS agnostic programs?
bool FatFile:: preAllocate ( uint32_t length )
Allocate clusters to an empty file.
The file will contain uninitialized data.
Parameters
[in] length size of the file in bytes.
Returns
true for success else false.
Assuming an SDIO interface.
type any character to start
init time: 18 ms
Card type: SDHC
Manufacturer ID: 0X3
OEM ID: SD
Product: SP32G
Version: 8.0
Serial number: 0X912A13DA
Manufacturing date: 6/2011
cardSize: 31914.98 MB (MB = 1,000,000 bytes)
flashEraseSize: 128 blocks
eraseSingleBlock: true
OCR: 0XC0FF8000
SD Partition Table
part,boot,bgnCHS[3],type,endCHS[3],start,length
1,0X0,0X1,0X1,0X0,0X7,0XFE,0XFF,0XFF,16384,62317568
2,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0,0
3,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0,0
4,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0,0
Scanning FAT, please wait.
Volume is exFAT
sectorsPerCluster: 256
clusterCount: 243364
freeClusterCount: 243361
fatStartSector: 24576
dataStartSector: 32768
type any character to start
Type any character to begin
FIFO_DIM = 6
FreeStack: 59587
Type any character to stop
6 maxFifoCount
8913420288 bytes
870.45 seconds
10.24 MB/sec
1326687109 yieldCalls
Type any character to run test again
manufactured in 2011? sounds old...
Windows will set valid length to data length. Or at least show the files size to be data_length. I need to dump the a directory after having Windows repair a exFAT volume.
I have not decided how to handle features like preAllocate where the FAT16/FAT32 version is totally different than the exFAT version.
Here is the FAT version:
It's not too useful since there is no valid length and the FAT will be accessed since there is no contiguous file attribute. If you write a partial sector it must be a rewrite which kills performance.
It would be easy to add preAllocate(). Any Thoughts?
I would suggest a FS agnostic API. Implementation may depend on FS (with/without real allocation).
BRW, I always thought that for FAT32 pre-allocation is more important for, say FAT32, than for exFAT, but I may be wrong.
Bill,
another issue:
with ExFile I seem to be unable to get file time stamp working
I added the FsDateTime callback.
Should it work? if yes, then I have a bug in my callback implementation (I try to use RTC_TSR and convert the seconds to struct_tm before calling your FS_DATE/TIME functions)
Type any character to begin
DateTime::now 2017-08-30 12:41:44
2017-08-30 12:41 35 RtcTest.txt
Done
Size 35 bytes
Date created 8/30/2017 12:41 PM
Date modified 8/30/2017 12:41 PM
bool FsFile::preAllocate ( uint64_t length )
inline
Allocate contiguous clusters to an empty file.
The file must be empty with no clusters allocated.
The file will contain uninitialized data for FAT16/FAT32 files. exFAT files will have zero validLength and dataLength will equal the requested length.
Parameters
[in] length size of the file in bytes.
Returns
true for success else false.
I added FsFile::preAllocate().
I also corrected a few errors in the documentation and defined symbols for file system types.
SdFs sd;
FsFile file;
write speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
692.00,17120,720,733
693.53,11536,720,731
read speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
666.80,2012,756,761
666.71,2012,756,761
write speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
697.74,1644,720,728
697.64,1640,720,728
read speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
667.11,1000,756,761
667.29,1216,756,761
Starting write of 10 MiB.
minMicros: 716
maxMicros: 736
15.07 Seconds
695.67 KB/sec
Starting write of 100 MiB.
minMicros: 157
maxMicros: 160
32.72 Seconds
3204.40 KB/sec
3 maxFifoCount
1633484800 bytes
159.52 seconds
10.24 MB/sec
392708121 yieldCalls
FILE_SIZE_MB = 5
BUF_SIZE = 64 bytes
write speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
449.28,17130,1,142
438.83,17465,1,145
FILE_SIZE_MB = 5
BUF_SIZE = 64 bytes
write speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
12690.36,71,1,4
12658.23,73,1,4
Log time: 17.73 Seconds
File size: 4058 bytes
totalOverrun: 0
maxFifoCount: 1
maxLogMicros: 16
maxWriteMicros: 160
Log interval: 10000 micros
maxDelta: 0 micros
I tried the example "ExFatLogger" with these results
Code:Log time: 17.73 Seconds File size: 4058 bytes totalOverrun: 0 maxFifoCount: 1 maxLogMicros: 16 maxWriteMicros: 160 Log interval: 10000 micros maxDelta: 0 micros
The "maxWriteMicros = 160" is the time it takes to write the values in the sd card and "maxLogMicros = 16" is the time it takes to write the values in the adc array correctly??
void logRecord(data_t* data, uint16_t overrun) {
if (overrun) {
// Add one since this record has no adc data. Could add overrun field.
overrun++;
data->adc[0] = 0X8000 | overrun;
} else {
for (size_t i = 0; i < ADC_COUNT; i++) {
data->adc[i] = analogRead(i);
}
}
}
uint32_t m = micros();
logRecord(fifoData + fifoHead, overrun);
m = micros() - m;
if (m > maxLogMicros) {
maxLogMicros = m;
}
uint32_t usec = micros();
if (nb != binFile.write(&fifoData[fifoTail], nb)) {
error("write binFile failed");
}
usec = micros() - usec;
if (usec > maxWriteMicros) {
maxWriteMicros = usec;
}
Thanks for the detailed explanation,so to my own project i will have furthermore a "time burden" of 160us+16us = ~180us if i want to add a datalogger(amazing)?
The time "maxLogMicros" maybe reduced depending with on the type of sd card(Speed Class)?