Showing results for 
Search instead for 
Did you mean: 

CLOCK_MONOTONIC(_RAW) and STGEN have ~8s difference -- how are they related?

Associate II

Hi again,

that's how i understood it so far, correct me if i'm wrong:

  • openstlinux on STM32MP1 uses arch_sys_counter as clocksource
cat /sys/devices/system/clocksource/clocksource0/available_clocksource 
  • which also serves as clock source for CLOCK_MONOTONIC
  • arch_sys_counter uses STGEN as time base.
  • this would imply that reading CLOCK_MONOTONIC(_RAW) (sec + nsec) should result in STGEN time values (/ STGEN_FREQ).

When i read STGENR (using the mmap on A7) and CLOCK_MONOTONIC(_RAW) I get the following:

STGEN: 179706903683 = 7487.787653
MON                   7479.443003674
MONR                  7479.474111358
STGEN: 179706906840 = 7487.787785

Do you have any explanation where the ~8 secs difference come from?

Also, what is the most efficient way of reading STGENR from the A7 side in userland? (is it the mmap or is there some more direct way?)

Thanks in advance,


Associate III

I`m interested in this question too. I`m looking for a robust way for synchronizing A7 and M4 timestamps. STGEN seems a proper clock source as it is accessible from both M4 and A7 side. I would like getting STGEN through CLOCK_MONOTONIC from linux userspace.

Associate II

Me too. All the documentation suggests STGENR is the way to share timestamps between domains yet I've not found any device or sys interface to do so on the Linux A7 side. We're using the M4 core to interface to a bunch of analog & digital I/O devices and I would like to be able to timestamp readings passed up to the A7 application and timing information passed down to the M4. Has anyone written a driver to expose the two 32-bit registers (STGENR_CNTCVU STGENR_CNTCVL) in a self-consistent way that they're willing to share?