64bit time_t issue in RTCv1 section Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
ibrauns
Posts: 1
Joined: Wed Dec 08, 2010 11:56 am
Been thanked: 1 time

64bit time_t issue in RTCv1 section  Topic is solved

Postby ibrauns » Tue Aug 07, 2018 8:17 pm

Hi,

just switching my toolchain host from Win10 to Debian i had an issue with HAL 6.0.1 and STM32F103 mcu. I used the actual toolchain GNU MCU Eclipse ARM Embedded GCC which surprised me with 64-bit time_t type.

The function call localtime_r failed.

I solved that with a small patch in hal_rtc_ldd.c.

Maybe there exists a better solution?

Ingo

hal_rtc_ldd.c

Code: Select all

static void rtc_decode(uint32_t tv_sec,
                       uint32_t tv_msec,
                       RTCDateTime *timespec) {
  struct tm tim;
  struct tm *t;
  time_t tv64b;                                             /* XXX patched ibrauns 07082018*/

  /* If the conversion is successful the function returns a pointer
     to the object the result was written into.*/
#if defined(__GNUC__) || defined(__CC_ARM)
  tv64b = tv_sec;                                          /* XXX patched ibrauns 07082018*/             
  t = localtime_r((time_t *)&(tv64b), &tim);               /* XXX patched ibrauns 07082018   
  t = localtime_r((time_t *)&(tv_sec), &tim);               */
  osalDbgAssert(t != NULL, "conversion failed");
#else
  t = localtime(&tv_sec);
  memcpy(&tim, t, sizeof(struct tm));
#endif

  rtcConvertStructTmToDateTime(&tim, tv_msec, timespec);
}

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: 64bit time_t issue in RTCv1 section

Postby Giovanni » Mon Dec 31, 2018 11:06 am

Moving to bug reports.

Giovanni

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: 64bit time_t issue in RTCv1 section

Postby Giovanni » Sun Jun 30, 2019 4:56 pm

bump

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: 64bit time_t issue in RTCv1 section

Postby Giovanni » Sun Jul 14, 2019 7:30 am

This was fixed as bug #845, forgot to close, closing now.

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 14 guests