teensy 3.1 SD.open file modified time always Jan 1, 2000

Status
Not open for further replies.
Can't find where to set the file created or file modified time, and the modified seems to be defaulting to Jan 1, 2000

I've been using a crystal and 3v battery to just make the name of my files DDHHMMSS.csv but it would be really great if the modified time of the files was actually used so i could sort by last modified when i plug in the micro sd card into a computer.

i should mention i am using FILE_WRITE mode and everything else seems to be working ok
 
Last edited:
Perhaps the SD lib simply doesn't use RTC at all... Just a guess.
I don't use SD on SPI, I use SD cards in a card reader on USB, or just a cheap thumb drive on USB.
They tend to work faster in my own experience. What kind of speeds do you get anyway?
 
i guess i'll just keep using the time stamped filenames, wish there was more then 8 chars allowed :(

no idea what kind of speeds i'm getting, i'm logging a row of data 30 or 40 times a second which is governed by parsing serial input from a sensor, so i don't need crazy throughput, just low delay
 
Perhaps the SD lib simply doesn't use RTC at all... Just a guess.
I don't use SD on SPI, I use SD cards in a card reader on USB, or just a cheap thumb drive on USB.
They tend to work faster in my own experience. What kind of speeds do you get anyway?

You mean you plug a flash drive into the T3 micro-USB port and the T3 writes to that?
If so, how complicated was that? Do you have any examples?
 
You might want to look at the SDfat library. I just implemented a crystal and battery and my files are all time stamped correctly. Check out the code I posted in another thread http://forum.pjrc.com/threads/25532-ADC-library-update-now-with-support-for-Teensy-3-1/page2 and look for post #38. When I first started it seemed very complicated, but in the end it was more simple than I thought.

Hmm, i guess the basic SD.h library was just missing any reference to the dateTime function of SdFile, i guess i'll just switch libraries
Code:
/*
 * User provided date time callback function.
 * See SdFile::dateTimeCallback() for usage.
 */
void dateTime(uint16_t* date, uint16_t* time) {
  // clock in real callback function
  time_t now();
  // return date using FAT_DATE macro to format fields
  *date = FAT_DATE(year(), month(), day());

  // return time using FAT_TIME macro to format fields
  *time = FAT_TIME(hour(), minute(), second());
}
 
Got the SdFat working from the above source now with modified timestamps :)

Also, if anyone is curious, results from bench.ino
Code:
Free RAM: 57255
Type is FAT32
File size 5MB
Buffer size 100 bytes
Starting write test.  Please wait up to a minute
Write 384.35 KB/sec
Maximum latency: 190753 usec, Minimum Latency: 6 usec, Avg Latency: 259 usec

Starting read test.  Please wait up to a minute
Read 1023.12 KB/sec
Maximum latency: 2237 usec, Minimum Latency: 5 usec, Avg Latency: 96 usec

and, results from benchSD.ino
Code:
File size 5MB
Buffer size 100 bytes
Starting write test.  Please wait up to a minute
Write 258.42 KB/sec
Maximum latency: 191140 usec, Minimum Latency: 9 usec, Avg Latency: 386 usec

Starting read test.  Please wait up to a minute
Read 883.55 KB/sec
Maximum latency: 1668 usec, Minimum Latency: 9 usec, Avg Latency: 112 usec
 
Last edited:
You mean you plug a flash drive into the T3 micro-USB port and the T3 writes to that?
If so, how complicated was that? Do you have any examples?

No, I use the USB HOST Shield MINI from Circuitsathome.com. We have an entire article there on how to connect it, and even a Google+ community that provides the fastest help and tips.
 
Got the SdFat working from the above source now with modified timestamps :)

Also, if anyone is curious, results from bench.ino
Code:
Free RAM: 57255
Type is FAT32
File size 5MB
Buffer size 100 bytes
Starting write test.  Please wait up to a minute
Write 384.35 KB/sec
Maximum latency: 190753 usec, Minimum Latency: 6 usec, Avg Latency: 259 usec

Starting read test.  Please wait up to a minute
Read 1023.12 KB/sec
Maximum latency: 2237 usec, Minimum Latency: 5 usec, Avg Latency: 96 usec

and, results from benchSD.ino
Code:
File size 5MB
Buffer size 100 bytes
Starting write test.  Please wait up to a minute
Write 258.42 KB/sec
Maximum latency: 191140 usec, Minimum Latency: 9 usec, Avg Latency: 386 usec

Starting read test.  Please wait up to a minute
Read 883.55 KB/sec
Maximum latency: 1668 usec, Minimum Latency: 9 usec, Avg Latency: 112 usec
That is pretty good speed. What you lack though is long file-names...
Does it also handle FAT32? Ours does...
It also tries to ensure that changes are committed to all the FAT tables. I am considering adding a way to delay the FAT table syncing in order to speed up writes.
I'm not sure exactly how the SDFat library compares with respect to data consistency, however my library modifications try to do the right thing. Even if you yank the media, you hardly ever get corruption, unless you use an AVR with expanded memory, and then it can happen because it caches...

Here is a sample benchmark. Please note that this is a work-in-progress, and there is much that could be optimized yet. It also isn't really showing any long file names, with the exception of the etc directory that is listed. They are, however, fully supported.

Code:
Removing '/1MB.bin' file... completed with 0
1MB write timing test  2048 writes, (0), (0),  7785 ms (8 sec)
completed with 0
1MB read timing test 2048 reads, (20),  2186 ms (2 sec)
completed with 0
Directory of '/'
-rw--a      1048576 2012-10-07 01:18:36 1MB.bin
-rw--a           19 2012-10-07 01:18:28 newtest.txt
drw---            0 2014-05-10 20:11:24 ETC (etc)
1023455232 bytes available on disk.

Flushing caches...
More info here:
http://forum.pjrc.com/threads/25697...-Teensy-3-x-for-circuits-home-USB-Host-Shield
It includes a link to a video showing it operate.


Additional note:
Looked at SdFat, and I noticed that the benchmark uses 1000000 as a megabyte, not 1048576, so your bench marks are skewed to look faster than what they really are. :) My benchmark shows the real numbers in any case, and just do the math to get the speed.
 
Last edited:
That is pretty good speed. What you lack though is long file-names...
Does it also handle FAT32? Ours does...

Can this work directly with an micro SD sheild? same pins being used...

Here is a sample benchmark.....
Code:
Removing '/1MB.bin' file... completed with 0
1MB write timing test  2048 writes, (0), (0),  7785 ms (8 sec)
completed with 0
1MB read timing test 2048 reads, (20),  2186 ms (2 sec)
completed with 0
I must be reading this wrong is that 263MB/s write? and 936MB/s read???

More info here:
http://forum.pjrc.com/threads/25697...-Teensy-3-x-for-circuits-home-USB-Host-Shield
It includes a link to a video showing it operate.
Next time, cut out the build time from the video ;)
 
Can this work directly with an micro SD sheild? same pins being used...
Nope. Its results from a USB thumb drive...
I must be reading this wrong is that 263MB/s write? and 936MB/s read???
Yes, your math is incorrect.
134K/sec writes
479K/sec reads

These speeds are because it is only full-speed USB.

Next time, cut out the build time from the video ;)
I could... But it proves it is actually doing the real thing.
 
Last edited:
Status
Not open for further replies.
Back
Top