-
Notifications
You must be signed in to change notification settings - Fork 8k
Description
Answers checklist.
- I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
- I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
- I have searched the issue tracker for a similar issue and not found a similar issue.
IDF version.
5.5.0
Espressif SoC revision.
ESP32-S3-N8R2, ESP32-S3FH4N2
Operating System used.
Linux
How did you build your project?
VS Code IDE
If you are using Windows, please specify command line type.
None
Development Kit.
rymcu-esp32-s3-devkitc-1
Power Supply used.
USB
What is the expected behavior?
I expect that - after system time has been set correctly via NTP, RTC, or GPS - FatFS correctly sets file creation and/or modification time.
I'm setting the clock a few ways:
- as soon as
app_main()is called, set time to the build time. If nothing else, that sets a reasonable lower bound on system time. - read time from an I2C. Update system time if it's after the build time.
- there's a task that handles the GPS connected to this device. it will update system time and rtc time once a fix is obtained, and every hour it checks that time hasn't drifted too much.
All this happens before I initialize SPI, SDSPI, and FATFS, so any filesystem operations should be using the correct time.
What is the actual behavior?
$ ls -l 20251123_214625.json
-rw-r--r-- 1 ckuethe ckuethe 20341248 Dec 25 2005 20251123_214625.json
$ tail -1 20251123_214625.json | cut -d , -f 1
{"tm":"2025-11-25T08:38:36"
$ stat 20251123_214625.json
File: 20251123_214625.json
Size: 20341248 Blocks: 39744 IO Block: 16384 regular file
Device: 179,1 Inode: 472 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ ckuethe) Gid: ( 1000/ ckuethe)
Access: 1979-12-31 16:00:00.000000000 -0800
Modify: 2005-12-25 00:39:20.000000000 -0800
Change: 2005-12-25 00:39:20.000000000 -0800
Birth: 2005-12-23 13:46:24.000000000 -0800
Here's a file that my ESP-IDF program (a data logger) created on an SD card. Among other things, it writes GPS logs so I'm sure the logged time is correct. The filename is also derived from GPS time. Unfortunately, the file times are about 20 years behind:
>>> datetime.datetime(2025,11,25,8,38,36) - datetime.datetime(2005,12,25,0,39,20)
datetime.timedelta(days=7275, seconds=28756)
Steps to reproduce.
Can't publish the code just yet, but here's roughly what I'm doing.
settimeofday(&build_time); // set clock from build-host timeupdate_sys_time_from_rtc(); // detects and reads from i2c rtc, updates system timewait_for_gps_fix(); // geotagged data logger, can't proceed until GPS has a fixsettimeofday(gps->timestamp);sd_hw_init(); // set GPIO pins, SPI host, clock frequency, initialize SPI bus, etc.esp_vfs_fat_sdspi_mount(mount_point, &spi_host, &sd_slot_config, &mount_config, &card); // mount the sdcardsnprintf(filename, sizeof(filename) - 1, "%s/%s.jsonl", outdir, current_time_str()); // construct a filename from the path to the sdcard and current timefp = fopen(filename, "wt"); // open the filefwrite(gps_msg, strlen(gps_msg), fp); // Assume that the current GPS solution has been converted to a stringfflush(fp); // flush to persistent storefclose(fp); // close the file
Debug Logs.
Diagnostic report archive.
No response
More Information.
VSCode 1.106.3-1764110892
PlatformIO Core, version 6.1.18
Resolving rymcu-esp32-s3-devkitc-1 dependencies...
Platform espressif32 @ 6.12.0 (required: espressif32)
├── framework-espidf @ 3.50500.0 (required: platformio/framework-espidf @ ~3.50500.0)
├── tool-cmake @ 3.30.2 (required: platformio/tool-cmake @ ~3.30.0)
├── tool-esp-rom-elfs @ 0.0.1+20241011 (required: platformio/tool-esp-rom-elfs @ 0.0.1+20241011)
├── tool-esptoolpy @ 2.40900.250804 (required: platformio/tool-esptoolpy @ ~2.40900.0)
├── tool-mkfatfs @ 2.0.1 (required: platformio/tool-mkfatfs @ ~2.0.0)
├── tool-mklittlefs @ 1.203.210628 (required: platformio/tool-mklittlefs @ ~1.203.0)
├── tool-mkspiffs @ 2.230.0 (required: platformio/tool-mkspiffs @ ~2.230.0)
├── tool-ninja @ 1.7.1 (required: platformio/tool-ninja @ ^1.7.0)
├── tool-riscv32-esp-elf-gdb @ 12.1.0+20221002 (required: espressif/tool-riscv32-esp-elf-gdb @ ~12.1.0)
├── tool-xtensa-esp-elf-gdb @ 12.1.0+20221002 (required: espressif/tool-xtensa-esp-elf-gdb @ ~12.1.0)
├── toolchain-esp32ulp @ 1.23800.240113 (required: platformio/toolchain-esp32ulp @ ~1.23800.0)
├── toolchain-riscv32-esp @ 14.2.0+20241119 (required: platformio/toolchain-riscv32-esp @ 14.2.0+20241119)
└── toolchain-xtensa-esp-elf @ 14.2.0+20241119 (required: platformio/toolchain-xtensa-esp-elf @ 14.2.0+20241119)