This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP432E401Y: The SDFatFS Driver Does Not Generate Correct File Creation Date When Saving a File

Part Number: MSP432E401Y

Tool/software:

I have a firmware system using a MSP432E401 device using FreeRtos and using the SDFatFS driver provided as part of the TI driver or Third party.
I have an SD card attached to one of the SPI ports, and everything is working great. I can write and read files without any issues.
My problem is that the date stamp is wrong when a file is created. I do see the correct UNIX time when opening the file, but the file creation date does not show the corresponding date when looking at the created file.

I have set the Unix time below.
    SDFatFS_Handle sdHandle =NULL;

    //  add_device() should be called once and is used for all media types
    add_device(fatfsPrefix_2, _MSA, ffcio_open, ffcio_close, ffcio_read,
         ffcio_write, ffcio_lseek, ffcio_unlink, ffcio_rename);

    // Initialize real-time clock */
    clock_settime(CLOCK_REALTIME, &ts);

    // mount SD card
    sdHandle =  mOpenSdCardHandle();

I have tested on the TI provided examples, in which the Unix time is preset, and even in the example, the date is not correct. I also noted that no matter what you put month of December is not recorded as a file creation date at all.
Two fatFs examples are provided by TI: one without rtos and the other using FreeRtos. You can test the issue in any one of the two examples.

I want to note that in the hibernation module, I am not using the calendar mode of operation of the RTC.

Any help is appreciated.



  • Hi,

      I'm not an expert in answering why the date/time is not correct when creating a file on the filesystem. Below notes from the example readme file may provide some hints but I don't know if it will answer your question. 

    TI-RTOS:

    • The timespec structure must be initialized with the current UNIX seconds count in order to write files with accurate timestamps. This is due to the fact that the BIOS Seconds module rather than the RTS library time() function is used.

    • When building in Code Composer Studio, the kernel configuration project will be imported along with the example. The kernel configuration project is referenced by the example, so it will be built first. The “release” kernel configuration is the default project used. It has many debug features disabled. These feature include assert checking, logging and runtime stack checks. For a detailed difference between the “release” and “debug” kernel configurations and how to switch between them, please refer to the SimpleLink MCU SDK User’s Guide. The “release” and “debug” kernel configuration projects can be found under <SDK_INSTALL_DIR>/kernel/tirtos/builds/<BOARD>/(release|debug)/(ccs|gcc).

    FreeRTOS:

    • The compiler specific RTS library functions for time() and localtime() are used. It is not necessary to initialize the timespec structure.

    • Please view the FreeRTOSConfig.h header file for example configuration information.

  • Thank you for the response. I appreciate it very much. I am using FreeRtos and CCS for development. The relevant example is the FreeRtos version, which is given in the following location.

    https://dev.ti.com/tirex/explore/node?node=A__AHVfRL.LbnjqftYVDQ4Tag__com.ti.SIMPLELINK_MSP432E4_SDK__J4.hfJy__LATEST

    I should have clearly stated what I meant by file creation time not being correct, so let me state it better. I see that the month is incorrect, and the rest of the date and time values are good.

    Looking into the example that I used in my firmware implementation, it appears to me the "fatfs_getFatTime(void)" function may not be correct. In particular, the following section.

        fatTime = ((uint32_t)(pTime->tm_year - 80) << 25) |

            ((uint32_t)(pTime->tm_mon) << 21) |

            ((uint32_t)(pTime->tm_mday) << 16) |

            ((uint32_t)(pTime->tm_hour) << 11) |

            ((uint32_t)(pTime->tm_min) << 5) |

            ((uint32_t)(pTime->tm_sec) >> 1);

    The month field should be the following.

    ((uint32_t)(pTime->tm_mon+1) << 21) |

    When I make an adjustment for the month from "tm_mon," the creation time works correctly on the FreRtos implementation that I tested.

    Thank you.