FILE created on SD Card shows incorrect creation time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-07 2:22 PM
File created on SD Card shows incorrect creation time.
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
Solved! Go to Solution.
- Labels:
-
STM32CubeMX
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-07 5:32 PM
Seems like I need to do something like this for kiel5 to resolve the issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-07 2:27 PM
a) You'd need something on the system maintaining current time.
b) Function in DISKIO layer providing get_fattime() from the aforementioned.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-07 2:39 PM
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; }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-07 2:45 PM
Seems like filesystem interface does not write correct time. Probably something inside middleware.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-07 2:53 PM
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
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-07 3:48 PM
I added this function main.c file and added a print in the function to see if it gets called when I create a file.
uint64_t get_fattime(void) {
/* USER CODE BEGIN get_fattime */
RTC_TimeTypeDef rtc_time; // Structure to hold time information
RTC_DateTypeDef rtc_date; // Structure to hold date information
uint64_t attime;
HAL_RTC_GetTime(&hrtc, &rtc_time, RTC_FORMAT_BIN);
HAL_RTC_GetDate(&hrtc, &rtc_date, RTC_FORMAT_BIN);
attime = (((uint64_t)rtc_date.Year - 1980) << 25)
| ((uint64_t)rtc_date.Month << 21)
| ((uint64_t)rtc_date.Date << 16)
| (uint64_t)(rtc_time.Hours << 11)
| (uint64_t)(rtc_time.Minutes << 5)
| (uint64_t)(rtc_time.Seconds >> 1);
printf("\n\nget_fattime got called\n\n");
return attime;
/* USER CODE END get_fattime */
}
I don't see the print that this function gets called when I create the file and see same time stamp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-07 3:51 PM
By the time create the file RTC is already working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-07 4:41 PM
Check _FS_NORTC in ffconf.h
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-07 5:12 PM
I don't see ffconf.h file in my path or _FS_NORTC in the project, do I need to create this file and add it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-07 5:32 PM
Seems like I need to do something like this for kiel5 to resolve the issue.
