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.

CC3220SF: Ti v20.2.2.LTS - Set the epoch start from 1970 instead of default

Part Number: CC3220SF

Hello,

I am looking to set the epoch start from 1970.
Currently, It is set the TI default (1900 and an offset of 6h).

I have found out the possibility to change it by setting the "__TI_TIME32_USES_POSIX_EPOCH" macro .
I set this macro on CCS -> Project properties -> Build -> Arm Compiler -> Predefined Symbols

But this did not work, I have also try to set "_TIME64_IMPLEMENTATION" but had the same result.

What I should do to set the epoch start from 1970?

Thanks,
Samuel

  • Hi,

    TI is aligned with the NTP epoch time and not the UNIX time as you observed.

    There is a define TI_EPOCH_OFFSET to compensate for it.

    You can also look at the startsntp example where this conversion is done using the TIME_BASEDIFF define.

    There is also this thread that mentions it https://e2e.ti.com/support/wireless-connectivity/wi-fi-group/wifi/f/wi-fi-forum/725932/cc3220sf-launchxl-cc3220sf-sntp-server/2678440#2678440

    Regards,

    Shlomi

  • Hi Shlomi,

    Thanks for the reply, but I think that could not help me.

    I did not expose my problem correctly.
    The TI epoch does not bothers me, my problem comes when I use the "mktime", this function seems to limit the year near to 2036, after that it gives me overflow and it backs to 1900.
    Currently time_t is an uint32_t, which means that can not handle 2037. ( (2037-1900) * 365.25 * 24 * 60 * 60) > 2^32.

    I had ask for help to set the "__TI_TIME32_USES_POSIX_EPOCH" macro to earn more 70 years, and therefore the time could handle until 2106.

    I had been reading the documentation and could achieve the goal by using "mklib" executable to recompile the lib with this macro.
    This solve my initial problem, but it will only apply under my PC...

    There is a way to configure it in the project, something like to say to compiler/linker to rebuild the lib (if needed) with this macro?
    Can you suggest some solution that can work under any computer without need to manually execute the mklib program?

    Thanks,
    Samuel

  • Hi,

    What lib are you referring to? how did you recompile it?

    Shlomi

  • Hi Itzhak,

    I had recompiled the "rtsv7M4_T_le_eabi.lib" library using the "mklib" executable, both of them are under the compiler folder ("ccs/tools/compiler/ti-cgt-arm_20.2.2.LTS/lib")

    Thanks,
    Samuel

  • Hi,

    If the library was compiled differently, why can't you use the recompiled library for all other usages? it should be compiled once.

    As far as I can tell, you cannot just add a MACRO as the library was compiled differently so it needs to get recompiled.

    Having said that, looking in the source code, I can see that __TI_TIME32_USES_POSIX_EPOCH is defined and this means that POSIX time is used, i.e. 1970 so it is not clear why you see 1900:

    #if defined(_TIME64_IMPLEMENTATION) || \
        defined(__TI_TIME32_USES_POSIX_EPOCH)
    #define EPOCH_WDAY  __POSIX_EPOCH_WDAY
    #define EPOCH_YEAR  __POSIX_EPOCH_YEAR
    #define EPOCH_TZONE __POSIX_EPOCH_TZONE
    #else
    #define EPOCH_WDAY  __TI_EPOCH_WDAY
    #define EPOCH_YEAR  __TI_EPOCH_YEAR
    #define EPOCH_TZONE __TI_EPOCH_TZONE
    #endif

    Regards,

    Shlomi

  • Hi Itzhak,

    This library is under a local directory, therefore every user that want to use this MACRO would also need to recompile the library in their computer.
    I understand now how to move and use this library under the project diroctory.

    This issue can be close.

    Thanks,
    Samuel