Skip to main content
Associate III
November 7, 2023
Solved

FILE created on SD Card shows incorrect creation time.

  • November 7, 2023
  • 4 replies
  • 3539 views

File created on SD Card shows incorrect creation time.

aahsan_1-1699395632760.png

shown in above fig in red all files which gets created on SD card carry same creation time.

Wondering if missing something in CubeMX settings 

This topic has been closed for replies.
Best answer by aahsan

Seems like I need to do something like this for kiel5 to resolve the issue.

aahsan_0-1699407111316.png

 

4 replies

Tesla DeLorean
Guru
November 7, 2023

a) You'd need something on the system maintaining current time.

b) Function in DISKIO layer providing get_fattime() from the aforementioned.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
aahsanAuthor
Associate III
November 7, 2023

Thank you for quick response.


a) You'd need something on the system maintaining current time.

    We have RTC working that's how getting correct time for the timestamps, not sure if that's what you meant here.

b) Function in DISKIO layer providing get_fattime() from the aforementioned.

    I see following function, I can implement something like this but not sure, how and where that needs to be called so that file created will reflect correct system time.

DWORD get_fattime (void)
{
 time_t t;
 struct tm *stm;

 t = time(0);
 stm = localtime(&t);

 return (DWORD)(stm->tm_year - 80) << 25 |
 (DWORD)(stm->tm_mon + 1) << 21 |
 (DWORD)stm->tm_mday << 16 |
 (DWORD)stm->tm_hour << 11 |
 (DWORD)stm->tm_min << 5 |
 (DWORD)stm->tm_sec >> 1;
}  

 

Tesla DeLorean
Guru
November 7, 2023

It's a call-out function from within the FatFs implementation, it is there for YOU to furnish current time upon request. You can recover it from the RTC, or your own SYSTEMTIME ticker, or whatever.

It uses this to fill in the fields of the file system structure you currently see as 1-Jan-2016 4:00 AM

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
MKanc.1
Associate III
November 7, 2023

Seems like filesystem interface does not write correct time. Probably something inside middleware.

aahsanAuthorBest answer
Associate III
November 8, 2023

Seems like I need to do something like this for kiel5 to resolve the issue.

aahsan_0-1699407111316.png

 

aahsanAuthor
Associate III
November 10, 2023

With fs_get_time() implemented I can get creation time on the file correct.

aahsan_0-1699659973003.png