Probleme with latest ARM Toolchain and time functions

Sysprogs forums Forums VisualGDB Probleme with latest ARM Toolchain and time functions

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #26856
    julieninnovel
    Participant

    Hello,

    I have a project based on a STM32 using the internal RTC.

    I was using the toolchain “arm-eabi-gcc7.2.0-r3” to translate a timestamp UNIX to a tm struct and sthen set my RTC like this :

    #include 
    #include <sys\time.h>
    
    void RTC_SetTimeByTimeStamp(uint32_t u32_TimeStamp)
    {
    struct tm* p_time;
    /* convert into unix time struct */
    p_time = gmtime((time_t*)&u32_TimeStamp);
    ...
    }

     

    All was OK. If I call this function with a timestamp at 1576158671, the p_time struct contain :

    12/12/2019  13:51:11

    But with the latset toolchain “arm-eabi-gcc9.2.1”, the same function, call with the same timestamp value set the p_time struct with random value like :

    2/1/1971721  11:25:06

     

    Thanks for your help.

     

    • This topic was modified 4 years, 10 months ago by support. Reason: formatting
    #26858
    support
    Keymaster

    Sorry, the latest ARM toolchain comes directly from ARM and we do not control the logic it uses for translating time.

    As a workaround, please try using a time conversion function from an external library, or try submitting a bugreport via ARM forums.

    #26954
    CrzyRndm
    Participant

    https://os.mbed.com/questions/80116/time_t-is-broken-with-2017-q4-releas-of-/

    time_t is now a 64 bit integer, a 32 bit pointer is not going to end well

    #26955
    support
    Keymaster

    Thanks for pointing this out!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.