cancel
Showing results for 
Search instead for 
Did you mean: 

How can the cortex M4 access to RTC Timestamp?

victor.b
Associate II

Hi,

I would like to read the timestamp value of the RTC. I see that only the Cortex A7 have access to it and the documentation on the wiki does not give any clue to how we can read the timestamp from the m4.

On the linux side i can easily obtain it:

0690X000009ZdHdQAK.png

I know i can make a small service that gets the timestamp and sends it to the M4 using the rpmsg channels, but i would like to know if there is a better way to do it?

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
PatrickF
ST Employee

RTC time and date registers are accessible in read by Cortex-M4 even if managed by Linux (secure or not).

No driver is provided for this, you could simply read RTC->SR, RTC->DR or RTC->SSR with the recommendations stated in Reference manual, RTC section "Reading the calendar".

Note that if there is cases where Linux is in CStop mode and Cortex-M4 still need to access RTC, you should set the RTCAPBEN in RCC_MC_APB5ENSETR (not that this will have impact on system power as some bus clock will be kept running while M4 is in RUN to let access to the RTC)

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

6 REPLIES 6
PatrickF
ST Employee

RTC time and date registers are accessible in read by Cortex-M4 even if managed by Linux (secure or not).

No driver is provided for this, you could simply read RTC->SR, RTC->DR or RTC->SSR with the recommendations stated in Reference manual, RTC section "Reading the calendar".

Note that if there is cases where Linux is in CStop mode and Cortex-M4 still need to access RTC, you should set the RTCAPBEN in RCC_MC_APB5ENSETR (not that this will have impact on system power as some bus clock will be kept running while M4 is in RUN to let access to the RTC)

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
victor.b
Associate II

"No driver is provided for this,..."

Is it temporary or there are plans to make the stm32mp1xx_hal_rtc.h available? If so, what is the ETA?

Is can see that the hal conf can already handle it...

0690X000009ZfgGQAS.png

Thanks,

PatrickF
ST Employee

I'm quite sure there will be no driver for RTC in HAL in future as RTC always need to be controlled by Linux side, despite you can see some entry in hal_conf.f which need to be ignored.

If you want to retrieve similar functions than other MCUs, you could probably port some HAL function code from other STM32 products (e.g. STM32CubeH7), but need to be strip down the code to bare minimum to avoid initialization and access to any restricted RTC registers. Not sure it is worth the effort.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
victor.b
Associate II

Ok thanks for the input. For my use case, I only need to read the value or the date and time from the M4, no control needs here.

Hi @PatrickF​ 

I need to use the digital calibration function. Is it possible to configure the RTC from M4? I seem to be able to able to write to the RTC registers, after disabling write protect (RTC_WPR). But I am wondering whether the Linux core overrides/disables control from the M4?

Piranha
Chief II

Take a note that reading the RTC is not a trivial task on it's own:

http://efton.sk/STM32/gotcha/g82.html

http://efton.sk/STM32/gotcha/g95.html

And in addition in your case there can be potential synchronization issues because of accesses from the other cores.