时间类型
J6内部的时间类型如下

Linux系统时间是基于arm system counter抽象的,Linux的基于arm system counter抽象了很多种时间,图中画了两种。CLOCK_MONOTONIC_RAW是不会被时间同步调整的。
| leap second? | clock set? | clock tunning? | original point | resolution | active in suspend? | 获取时间的接口 |
realtime | yes | yes | yes | Linux epoch | ns | no | gettimeofday clock_gettime |
monotonic | yes | no | yes | Linux epoch | ns | no | clock_gettime |
monotonic raw | yes | no | no | Linux epoch | ns | no | clock_gettime |
realtime coarse | yes | yes | yes | Linux epoch | tick | no | clock_gettime |
monotonic coarse | yes | no | yes | Linux epoch | tick | no | clock_gettime |
boot time | yes | no | yes | machine start | ns | no | clock_gettime |
realtime alarm | yes | yes | yes | Linux epoch | ns | yes | clock_gettime |
boottime alarm | yes | no | yes | machine start | ns | yes | clock_gettime |
tai | no | no | no | Linux epoch | ns | no | clock_gettime |
Frame时间戳
从VIO侧获取的图像数据,带有时间戳信息,相关信息如下:
time_stamp:代表收到第一行到达时刻,获取的是system count;
struct timeval tv: 代表收到第一行到达时刻,时间戳来源有3个地方, 分别代表RTC时戳,wall time,PHC 时戳,可通过/sys/devices/platform/soc/soc:globaltime/globaltime配置;
struct timeval trig_tv: 同tv,代表LPWM trigger时刻;
类型 | value | 获取方式 | 是否受授时影响 |
GLOBAL_TIME_RTC | 2 | 硬件寄存器锁存 | Y |
GLOBAL_TIME_PHC | 1 | 依赖FS ISR软件获取 | Y |
GLOBAL_TIME_SYSTIME | 0 | 依赖FS ISR软件获取 | N |
RTC、PHC是可以被时间同步调整的,直接调整的是硬件counter。
PHC时间获取:驱动调用hobot_eth_get_phc_time接口
- RTC时间获取:CIM可以通过读寄存器直接拿到RTC时间,不建议调用接口获取RTC时间
RTC精确到秒的时间:应用层可以获取
RTC精确到纳秒的时间:
如果时间同步在同步RTC,不允许其他应用获取RTC时间,因为获取RTC时间可能导致RTC时间异常改变,这个是硬件限制。
如果不做RTC的时间同步,应用层可以获取RTC时间
车载系统一般使用PHC时间域,所以frame timestamps选择PHC时钟源的情况偏多,当前具体使用哪个时钟源,看具体方案;