Enable Time stamp on FatFs SD card
Re: Enable Time stamp on FatFs SD card
Thanks for reply. I will double check my f_utime function call in few days. sorry busy with other tasks.
Re: Enable Time stamp on FatFs SD card
Hi,
As my esp32 will not have public internet access. It will running on local LAN with private IP address.
I can upload via OTA. I can pass time stamp with upload file. I can keep save time stamp. when I create/update files using fopen. I need to set this same time stamp for all files after files/folder creation.
Just to clarify. After files/folders gets created.
I need to set time stamp.
Should f_utime works? or any other method.
Kindly do reply.
As my esp32 will not have public internet access. It will running on local LAN with private IP address.
I can upload via OTA. I can pass time stamp with upload file. I can keep save time stamp. when I create/update files using fopen. I need to set this same time stamp for all files after files/folder creation.
Just to clarify. After files/folders gets created.
I need to set time stamp.
Should f_utime works? or any other method.
Kindly do reply.
Re: Enable Time stamp on FatFs SD card
Yes, f_utime should work, provided that you pass the correct path (e.g. 0:file.txt where 0 is volume number and file.txt is the file name inside FAT partition)
Re: Enable Time stamp on FatFs SD card
Kindly check this example code. I am using SD card. how I specify volume?
Code: Select all
FRESULT set_timestamp (
char *obj, /* Pointer to the file name */
int year,
int month,
int mday,
int hour,
int min,
int sec
)
{
FILINFO fno;
fno.fdate = (WORD)(((year - 1980) * 512U) | month * 32U | mday);
fno.ftime = (WORD)(hour * 2048U | min * 32U | sec / 2U);
return f_utime(obj, &fno);
}
void app_main(void)
{
ESP_LOGI(TAG, "Initializing SD card");
sdmmc_card_t* card;
esp_err_t ret = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card);
if (ret != ESP_OK) {
if (ret == ESP_FAIL) {
ESP_LOGE(TAG, "Failed to mount filesystem. "
"If you want the card to be formatted, set format_if_mount_failed = true.");
} else {
ESP_LOGE(TAG, "Failed to initialize the card (%s). "
"Make sure SD card lines have pull-up resistors in place.", esp_err_to_name(ret));
}
return;
}
FRESULT result = set_timestamp("/sdcard/foo.txt", 2018, 9, 15, 1, 1, 1);
ESP_LOGI(TAG, "set_timestamp result=%d", (int)result);
}
Re: Enable Time stamp on FatFs SD card
In this case the path is going to be "0:foo.txt" (instead of "/sdcard/foo.txt").
See http://elm-chan.org/fsw/ff/doc/filename.html for the fatfs library format of file names.
Normally when you use C library functions or POSIX functions which work with files, these functions translate full paths (such as /sdcard/foo.txt) into paths inside specific filesystem (such as 0:/foo.txt). When you call a fatfs function directly, you have to pass the path in the format which fatfs expects.
See http://elm-chan.org/fsw/ff/doc/filename.html for the fatfs library format of file names.
Normally when you use C library functions or POSIX functions which work with files, these functions translate full paths (such as /sdcard/foo.txt) into paths inside specific filesystem (such as 0:/foo.txt). When you call a fatfs function directly, you have to pass the path in the format which fatfs expects.
Re: Enable Time stamp on FatFs SD card
ok, thanks. I will try this in few days time.
Re: Enable Time stamp on FatFs SD card
I saw in older posts, that overriding of get_fattime() is not supported by the IDF. I'm wondering if it is still the case, or has it been added to the framework already? I didn't find anything related though.
I modified the implementation of get_fattime() to be weak and implemented my custom solution. It did the trick, but I want to avoid using patched framework.
What is the official way of overriding get_fattime()?
I modified the implementation of get_fattime() to be weak and implemented my custom solution. It did the trick, but I want to avoid using patched framework.
What is the official way of overriding get_fattime()?
Re: Enable Time stamp on FatFs SD card
I think you can use -Wl,--wrap=get_fattime linker flag, and then implement __wrap_get_fattime function in your application or library code. This would allow you to override this function without patching ESP-IDF.
Who is online
Users browsing this forum: Bing [Bot] and 252 guests