[DONE] Broken RTC on ChibiOS 3

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
trunet
Posts: 54
Joined: Fri Apr 06, 2012 7:18 pm

[DONE] Broken RTC on ChibiOS 3

Post by trunet »

I'm trying to use RTC on my STM32F1 but I'm having compilation error:

Code: Select all

Compiling test.c
In file included from /Users/trunet/src/ChibiOS-RT/os/hal/include/rtc.h:97:0,
                 from /Users/trunet/src/ChibiOS-RT/os/hal/include/hal.h:59,
                 from /Users/trunet/src/ChibiOS-RT/test/rt/test.c:26:
/Users/trunet/src/ChibiOS-RT/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.h:169:3: error: unknown type name 'RTCTime'
   void rtc_lld_set_time(RTCDriver *rtcp, const RTCTime *timespec);
   ^
/Users/trunet/src/ChibiOS-RT/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.h:170:42: error: unknown type name 'RTCTime'
   void rtc_lld_get_time(RTCDriver *rtcp, RTCTime *timespec);


I could't find "typedef RTCTime RTCTime" anywhere, only the struct, so I guess it's missing.

I added and now I'm getting some warning:

Code: Select all

Compiling rtc.c
/Users/trunet/src/ChibiOS-RT/os/hal/src/rtc.c: In function 'rtcSetTime':
/Users/trunet/src/ChibiOS-RT/os/hal/src/rtc.c:82:3: warning: passing argument 2 of 'rtc_lld_set_time' from incompatible pointer type [enabled by default]
   rtcSetTimeI(rtcp, timespec);
   ^
In file included from /Users/trunet/src/ChibiOS-RT/os/hal/include/rtc.h:97:0,
                 from /Users/trunet/src/ChibiOS-RT/os/hal/include/hal.h:59,
                 from /Users/trunet/src/ChibiOS-RT/os/hal/src/rtc.c:33:
/Users/trunet/src/ChibiOS-RT/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.h:174:8: note: expected 'const struct RTCTime *' but argument is of type 'const struct RTCDateTime *'
   void rtc_lld_set_time(RTCDriver *rtcp, const RTCTime *timespec);
        ^
/Users/trunet/src/ChibiOS-RT/os/hal/src/rtc.c: In function 'rtcGetTime':
/Users/trunet/src/ChibiOS-RT/os/hal/src/rtc.c:99:3: warning: passing argument 2 of 'rtc_lld_get_time' from incompatible pointer type [enabled by default]
   rtcGetTimeI(rtcp, timespec);
   ^
In file included from /Users/trunet/src/ChibiOS-RT/os/hal/include/rtc.h:97:0,
                 from /Users/trunet/src/ChibiOS-RT/os/hal/include/hal.h:59,
                 from /Users/trunet/src/ChibiOS-RT/os/hal/src/rtc.c:33:
/Users/trunet/src/ChibiOS-RT/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.h:175:8: note: expected 'struct RTCTime *' but argument is of type 'struct RTCDateTime *'
   void rtc_lld_get_time(RTCDriver *rtcp, RTCTime *timespec);
        ^


Is RTC module incomplete?

Thanks,

Wagner
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Broken RTC on ChibiOS 3

Post by Giovanni »

It is not complete yet.

Giovanni
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Broken RTC on ChibiOS 3

Post by Giovanni »

Hi,

I committed the RTC code it is untested but compiles just fine. In case you want to give it a try please let me know how it works.

Giovanni
Legath
Posts: 21
Joined: Thu Oct 17, 2013 3:24 pm

Re: Broken RTC on ChibiOS 3

Post by Legath »

Hi Giovanny,
i have the same issue with F4 , as i see it use RTCv2 driver,
but i found RTCTime only in RTCv1,
cat you tell any hack for succesfully compilation?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Broken RTC on ChibiOS 3

Post by Giovanni »

There is no RTCTime in the new driver, only RTCDateTime. You are right that it is RTC_v2, v1 will have to wait until the RTC driver model is "final" or somebody starts porting it.

Giovanni
Legath
Posts: 21
Joined: Thu Oct 17, 2013 3:24 pm

Re: Broken RTC on ChibiOS 3

Post by Legath »

Hi Giovanny

Code: Select all

 grep -rns "RTCTime" *
os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c:175: * @param[in] timespec  pointer to a @p RTCTime structure
os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c:179:void rtc_lld_set_time(RTCDriver *rtcp, const RTCTime *timespec) {
os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c:193: * @param[in] timespec  pointer to a @p RTCTime structure
os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c:197:void rtc_lld_get_time(RTCDriver *rtcp, RTCTime *timespec) {
os/hal/ports/STM32/LLD/RTCv1/rtc_lld.h:121:struct RTCTime {
os/hal/ports/STM32/LLD/RTCv1/rtc_lld.h:169:  void rtc_lld_set_time(RTCDriver *rtcp, const RTCTime *timespec);
os/hal/ports/STM32/LLD/RTCv1/rtc_lld.h:170:  void rtc_lld_get_time(RTCDriver *rtcp, RTCTime *timespec);
os/various/chrtclib.c:45: * @param[in] timespec  pointer to a @p RTCTime structure
os/various/chrtclib.c:49:static void stm32_rtc_bcd2tm(struct tm *timp, RTCTime *timespec) {
os/various/chrtclib.c:97: * @param[out] timespec pointer to a @p RTCTime structure
os/various/chrtclib.c:101:static void stm32_rtc_tm2bcd(struct tm *timp, RTCTime *timespec) {
os/various/chrtclib.c:148:  RTCTime timespec = {0,0,FALSE,0};
os/various/chrtclib.c:150:  RTCTime timespec = {0,0,FALSE};
os/various/chrtclib.c:167:  RTCTime timespec = {0,0,FALSE,0};
os/various/chrtclib.c:169:  RTCTime timespec = {0,0,FALSE};
os/various/chrtclib.c:186:  RTCTime timespec = {0,0,FALSE,0};
os/various/chrtclib.c:188:  RTCTime timespec = {0,0,FALSE};
os/various/chrtclib.c:209:  RTCTime timespec = {0,0,FALSE,0};
os/various/chrtclib.c:211:  RTCTime timespec = {0,0,FALSE};
os/various/chrtclib.c:231:  RTCTime timespec = {0,0,FALSE,0};
os/various/chrtclib.c:254:  RTCTime timespec = {0};
os/various/chrtclib.c:269:  RTCTime timespec = {0};
os/various/chrtclib.c:287:  RTCTime timespec = {0};
os/various/chrtclib.c:303:  RTCTime timespec = {0};
os/various/chrtclib.c:323:  RTCTime timespec = {0,0};


so rtclib must be unused now?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Broken RTC on ChibiOS 3

Post by Giovanni »

chrtclib will be reworked or removed entirely, it shall be an optional part anyway, the driver will have everything inside.

Giovanni
trunet
Posts: 54
Joined: Fri Apr 06, 2012 7:18 pm

Re: Broken RTC on ChibiOS 3

Post by trunet »

Hi Giovanni,

I'm still have problems. I saw that you commited RTCv2 code, but I'm using RTCv1 as I'm using stm32f103... Complete make output is below.

Code: Select all

Compiling rtc_lld.c
In file included from /Users/trunet/src/ChibiOS-RT/os/hal/include/rtc.h:102:0,
                 from /Users/trunet/src/ChibiOS-RT/os/hal/include/hal.h:60,
                 from /Users/trunet/src/ChibiOS-RT/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c:29:
/Users/trunet/src/ChibiOS-RT/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.h:169:3: error: unknown type name 'RTCTime'
   void rtc_lld_set_time(RTCDriver *rtcp, const RTCTime *timespec);
   ^
/Users/trunet/src/ChibiOS-RT/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.h:170:42: error: unknown type name 'RTCTime'
   void rtc_lld_get_time(RTCDriver *rtcp, RTCTime *timespec);
                                          ^
/Users/trunet/src/ChibiOS-RT/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c: In function 'rtc_lld_init':
/Users/trunet/src/ChibiOS-RT/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c:166:3: warning: implicit declaration of function 'CORTEX_PRIORITY_MASK' [-Wimplicit-function-declaration]
   nvicEnableVector(RTC_IRQn, CORTEX_PRIORITY_MASK(STM32_RTC_IRQ_PRIORITY));
   ^
/Users/trunet/src/ChibiOS-RT/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c: At top level:
/Users/trunet/src/ChibiOS-RT/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c:179:1: error: unknown type name 'RTCTime'
 void rtc_lld_set_time(RTCDriver *rtcp, const RTCTime *timespec) {
 ^
/Users/trunet/src/ChibiOS-RT/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c: In function 'rtc_lld_set_time':
/Users/trunet/src/ChibiOS-RT/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c:184:34: error: request for member 'tv_sec' in something not a structure or union
   RTC->CNTH = (uint16_t)(timespec->tv_sec >> 16);
                                  ^
/Users/trunet/src/ChibiOS-RT/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c:185:34: error: request for member 'tv_sec' in something not a structure or union
   RTC->CNTL = (uint16_t)(timespec->tv_sec & 0xFFFF);
                                  ^
/Users/trunet/src/ChibiOS-RT/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c: At top level:
/Users/trunet/src/ChibiOS-RT/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c:197:40: error: unknown type name 'RTCTime'
 void rtc_lld_get_time(RTCDriver *rtcp, RTCTime *timespec) {
                                        ^
make: *** [build/obj/rtc_lld.o] Error 1


It's working with this patch:

Code: Select all

diff --git a/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c b/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c
index 094b569..9a5664c 100644
--- a/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c
+++ b/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c
@@ -163,7 +163,7 @@ void rtc_lld_init(void){
   RTCD1.callback = NULL;

   /* IRQ vector permanently assigned to this driver.*/
-  nvicEnableVector(RTC_IRQn, CORTEX_PRIORITY_MASK(STM32_RTC_IRQ_PRIORITY));
+  nvicEnableVector(RTC_IRQn, CORTEX_PRIO_MASK(STM32_RTC_IRQ_PRIORITY));
 }

 /**
diff --git a/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.h b/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.h
index 62b74cc..627a4e3 100644
--- a/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.h
+++ b/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.h
@@ -129,6 +129,8 @@ struct RTCTime {
   uint32_t tv_msec;
 };

+typedef struct RTCTime RTCTime;
+
 /**
  * @brief   Structure representing an RTC alarm time stamp.
  */
Michail
Posts: 28
Joined: Mon Aug 04, 2014 6:55 am

Re: Broken RTC on ChibiOS 3

Post by Michail »

Hello again!

Current trunk lost changes made by barthess in revision 6331, so STM32F0xx support was lost again in RTCv2 :(

Code: Select all

       [cc] C:\Work\CoIDE\ChibiOS_3.0_Test\os\hal\ports\STM32\LLD\RTCv2\rtc_lld.c:338:25: error: 'RTC_CR_ALRBE' undeclared (first use in this function)
       [cc] C:\Work\CoIDE\ChibiOS_3.0_Test\os\hal\ports\STM32\LLD\RTCv2\rtc_lld.c:339:33: error: 'RTC_ISR_ALRBWF' undeclared (first use in this function)
       [cc] C:\Work\CoIDE\ChibiOS_3.0_Test\os\hal\ports\STM32\LLD\RTCv2\rtc_lld.c:341:16: error: 'RTC_TypeDef' has no member named 'ALRMBR'
       [cc] C:\Work\CoIDE\ChibiOS_3.0_Test\os\hal\ports\STM32\LLD\RTCv2\rtc_lld.c:343:24: error: 'RTC_CR_ALRBIE' undeclared (first use in this function)
       [cc] C:\Work\CoIDE\ChibiOS_3.0_Test\os\hal\ports\STM32\LLD\RTCv2\rtc_lld.c:367:33: error: 'RTC_TypeDef' has no member named 'ALRMBR'
       [cc] C:\Work\CoIDE\ChibiOS_3.0_Test\os\hal\ports\STM32\LLD\RTCv2\rtc_lld.c:388:23: error: 'RTC_CR_WUTE' undeclared (first use in this function)
       [cc] C:\Work\CoIDE\ChibiOS_3.0_Test\os\hal\ports\STM32\LLD\RTCv2\rtc_lld.c:389:31: error: 'RTC_ISR_WUTWF' undeclared (first use in this function)
       [cc] C:\Work\CoIDE\ChibiOS_3.0_Test\os\hal\ports\STM32\LLD\RTCv2\rtc_lld.c:391:14: error: 'RTC_TypeDef' has no member named 'WUTR'
       [cc] C:\Work\CoIDE\ChibiOS_3.0_Test\os\hal\ports\STM32\LLD\RTCv2\rtc_lld.c:393:22: error: 'RTC_CR_WUTIE' undeclared (first use in this function)
       [cc] C:\Work\CoIDE\ChibiOS_3.0_Test\os\hal\ports\STM32\LLD\RTCv2\rtc_lld.c:415:32: error: 'RTC_TypeDef' has no member named 'WUTR'
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Broken RTC on ChibiOS 3

Post by Giovanni »

Adding to the TODO list.

Giovanni
Post Reply