What is the relationship between TSC and PTP timestamp

Please provide the following info (tick the boxes after creating this topic):
Software Version
DRIVE OS 6.0.10.0
DRIVE OS 6.0.8.1
DRIVE OS 6.0.6
DRIVE OS 6.0.5
DRIVE OS 6.0.4 (rev. 1)
DRIVE OS 6.0.4 SDK
other

Target Operating System
Linux
QNX
other

Hardware Platform
DRIVE AGX Orin Developer Kit (940-63710-0010-300)
DRIVE AGX Orin Developer Kit (940-63710-0010-200)
DRIVE AGX Orin Developer Kit (940-63710-0010-100)
DRIVE AGX Orin Developer Kit (940-63710-0010-D00)
DRIVE AGX Orin Developer Kit (940-63710-0010-C00)
DRIVE AGX Orin Developer Kit (not sure its number)
other

SDK Manager Version
2.1.0
other

Host Machine Version
native Ubuntu Linux 20.04 Host installed with SDK Manager
native Ubuntu Linux 20.04 Host installed with DRIVE OS Docker Containers
native Ubuntu Linux 18.04 Host installed with DRIVE OS Docker Containers
other

Issue Description
hello nvidia support:
I am using drive agx orin and try to figure out camera frame sync design in orin. After I do a research in this forum I find that when interface mbge2_0 Synchronized time to extern grand time master , the PTP2 will send pps signals to Synchronize TSC clock. So I use Canoe as grand time master and do as asked, then through the “ret = ioctl(fd, NVPPS_GETEVENT, arg_event);” ioctl, I get result as below:
The NvPPS version is: 0204
The EVT Mode is Timer
The TSC Mode is NSec
Time event evt_nb: 56
Time event tsc: 63649624032
Time event ptp: 1706009668860961348
Time event secondary ptp: 0
Time event tsc_res_ns: 32
Time event evt_mode: 2
Time event tsc_mode: 0
Time event irq_latency: 0

after check the driver source code: nvpps_main.c
if (NVPPS_TSC_NSEC == pdev_data->tsc_mode) {
time_event.tsc *= pdev_data->tsc_res_ns;
}
I got confused.

so my question are:

  1. does that means both “Time event tsc: 63649624032” and “Time event ptp: 1706009668860961348” are nanoseconds?
  2. how can this two number prove that the TSC and PTP2 are aligned or Synchronized ?(what we expect after do a research in this forum is that this two clock should have the same millisecond, Microseconds while different seconds and nanoseconds, like 3 777 666 545 and 8 777 666 613 , this means they are full second aligned , by doing so the TSC generate camera frame sync signal aligned to the PTP2 clock and extern ptp time domain )
  3. If this two number can not prove this concept, how to do it in software level?

Are you asking if the returned values nano sec?

Note that TSC is monotonic clock. So it gets reset after every boot. When the synchronisation happens, the you get camera timestamps in PTP instead of TSC.

I am not just asking whether the Time event tsc: 63649624032 is nano sec. I mainly want to know the relationship between PTP2 clock and TSC clock.The nvidia drive OS develop docs says " PTP-TSC Sync:Orin SOC provides a hardware assisted mechanism to align/sync the TSC (clock/counter) with one of the Tegra SOC Ethernet MAC on second boundary using the PPS signal from the MAC. This feature is useful in synchronizing camera fsync signals". So how can the number got from “ret = ioctl(fd, NVPPS_GETEVENT, arg_event);” prove that?

1 Like

How can I know the synchronization is success? Why I still got the same camera timestamps as before? Is there any steps I missed?

Dear @justin.fu ,
Are you using DRIVE AGX Orin devkit? Could you please file a separate topic and all the details?

So your ask is how you can confirm if the number you got is in PTP domain only?

not exactly, what we expect: after the PTP time synced to TSC clock , the TSC clock counter should have the same value as the PTP clock, so we can use the TSC timestamp in captured camera buffer as every frame’s capture PTP timestamp . Or if there is a relationship between TSC clock and PTP clock which we can transfer TSC to PTP should also be fine.

As I understand, you want to get PTP timestamp in camera capture instead of TSC. Am I right?
Are you using nvsipl_camera to capture camera frames?

yes I am using nvsipl_camera to capture frames, the prints like:

Camera ID: 0; Frame Counter: 0; frameCaptureStartTSC: 33266287388;frameCaptureEndTSC: 33267066022
. So actually we just get TSC timestamps , but we need PTP clock timestamp.