nvidia xavier nx平台上精确时间协议(PTP)调试记录3

free-jdx 2021-05-20 17:08:14 6979
1. 前言

承接上篇
https://www.ebaina.com/articles/140000012552

2. agx平台正常工作如下

将此文件保存为/boot/pps.dts

/dts-v1/;
/plugin/;

/ {
    overlay-name = "Jetson PPS";
    compatible = "nvidia,p3509-0000+p3668-0001";

    fragment {
        target-path = "/";
        __overlay__ {
            pps: pps_gpio {
                compatible = "pps-gpio";
                gpios = <&tegra_main_gpio 148 1>;
                assert-falling-edge;
                status = "okay";
            };
        };
    };
};

将gpio更改为GPIO09,这是40引脚头上的第7引脚,因为GPS帽我已经将PPS信号硬线到那个引脚。
将dts编译成dtb

cd /boot
$ sudo dtc -I dts -O dtb -@ -o pps.dtbo pps.dts

从库存dtb和pps.dtbo创建一个自定义dtb

sudo fdtoverlay -i tegra194-p3668-all-p3509-0000.dtb -o tegra194-p3668-all-p3509-0000-user-custom.dtb tegra194-p3668-all-p3509-0000-hdr40.dtbo pps.dtbo

现在编辑/boot/extlinux/extlinux.conf,
并将以下行添加到菜单项中…

 LINUX ...
    INITRD ...
    FDT /boot/tegra194-p3668-all-p3509-0000-user-custom.dtb
    APPEND ...

现在重新启动。
当系统恢复运行时,应该有一个/dev/pps0设备。
将PPS源代码连接到pin 7并安装了PPS -tools包,
应该能够运行

$ sudo ppstest /dev/pps0
trying PPS source "pps0"
found PPS source "pps0"
ok, found 1 source(s), now start fetching data...
source 0 - assert 1592529430.097600543, sequence: 2333 - clear  0.000000000, sequence: 0
source 0 - assert 1592529431.097604009, sequence: 2334 - clear  0.000000000, sequence: 0
source 0 - assert 1592529432.097600339, sequence: 2335 - clear  0.000000000, sequence: 0
source 0 - assert 1592529433.097601277, sequence: 2336 - clear  0.000000000, sequence: 0

下一步取决于希望如何同步内核时间,
以便ptpd可以发送内核时间
我用ntpd取两个源
第一个是可靠的上游ntp服务器
第二个是通用的nmea源,它接受来自gps单元的nmea句子和pps信号
一旦内核被同步,ptpd就可以被设置为主服务器

3.将sdcard安装到另一个设备上
/media/boot$ ls
dtb                                                              tegra186-quill-p3310-1000-c03-00-base-hdr40.dtbo
extlinux                                                         tegra186-quill-p3310-1000-c03-00-dsi-hdmi-dp.dtb
grub                                                             tegra186-quill-p3489-0888-a00-00-base.dtb
Image                                                            tegra186-quill-p3489-1000-a00-00-ucm1.dtb
Image.sig                                                        tegra186-quill-p3489-1000-a00-00-ucm2.dtb
initrd                                                           tegra194-p2888-0001-p2822-0000-adafruit-sph0645lm4h.dtbo
initrd.img                                                       tegra194-p2888-0001-p2822-0000.dtb
initrd.img-4.9.140-tegra                                         tegra194-p2888-0001-p2822-0000-fe-pi-audio-z-v2.dtbo
pps.dtbo                                                         tegra194-p2888-0001-p2822-0000-hdr40.dtbo
pps.dts                                                          tegra194-p2888-0001-p2822-0000-maxn.dtb
tegra186-quill-p3310-1000-a00-00-base.dtb                        tegra194-p3668-all-p3509-0000-adafruit-sph0645lm4h.dtbo
tegra186-quill-p3310-1000-as-0888.dtb                            tegra194-p3668-all-p3509-0000.dtb
tegra186-quill-p3310-1000-c03-00-base-adafruit-sph0645lm4h.dtbo  tegra194-p3668-all-p3509-0000-fe-pi-audio-z-v2.dtbo
tegra186-quill-p3310-1000-c03-00-base.dtb                        tegra194-p3668-all-p3509-0000-hdr40.dtbo
tegra186-quill-p3310-1000-c03-00-base-fe-pi-audio-z-v2.dtbo      tegra194-p3668-all-p3509-0000-user-custom.dtb
xavier@agx:/media/boot$ cat extlinux/extlinux.conf 
TIMEOUT 30
DEFAULT primary

MENU TITLE L4T boot options

LABEL primary
      MENU LABEL primary kernel
      LINUX /boot/Image
      INITRD /boot/initrd
      FDT /boot/tegra194-p3668-all-p3509-0000-user-custom.dtb
      APPEND ${cbootargs} quiet

# When testing a custom kernel, it is recommended that you create a backup of
# the original kernel and add a new entry to this file so that the device can
# fallback to the original kernel. To do this:
#
# 1, Make a backup of the original kernel
#      sudo cp /boot/Image /boot/Image.backup
#
# 2, Copy your custom kernel into /boot/Image
#
# 3, Uncomment below menu setting lines for the original kernel
#
# 4, Reboot

# LABEL backup
#    MENU LABEL backup kernel
#    LINUX /boot/Image.backup
#    INITRD /boot/initrd
#    APPEND ${cbootargs}

检查文件系统和日志不会提供任何提示。

cat pps.dts
/dts-v1/;
/plugin/;

/ {
    overlay-name = "Jetson PPS";
    compatible = "nvidia,p3509-0000+p3668-0001";

    fragment {
        target-path = "/";
        __overlay__ {
                        pps: pps_gpio {
                                compatible = "pps-gpio";
                                gpios = <&tegra_main_gpio 148 1>;
                                assert-falling-edge;
                                status = "okay";
                        };
        };
    };
};
4. 按照上述步骤运行
 sudo /opt/nvidia/jetson-io/config-by-hardware.py -l
Configurations for the following hardware modules are available:
1. Adafruit SPH0645LM4H
2. FE-PI Audio Z V2
3. Jetson PPS
**
**
sudo /opt/nvidia/jetson-io/config-by-hardware.py -n "Jetson PPS"
Configuration saved to /boot/tegra194-p3668-all-p3509-0000-jetson-pps.dtb.
then Reboot.
Then
ls /dev/pp
ppp   pps0
$ sudo ppstest /dev/pps0
trying PPS source "/dev/pps0"
found PPS source "/dev/pps0"
ok, found 1 source(s), now start fetching data...
time_pps_fetch() error -1 (Connection timed out)
time_pps_fetch() error -1 (Connection timed out).

是否需要把时间脉冲线连接到7号引脚上?
否则将不会启动

5. 如何将pps0输出转发到linuxptp

从硬件的角度来看,是否需要从PPS源连接一根线?
引脚N7?PPS来源的两根电线?
引脚N7和其他一些引脚?

肯定是需要物理连接的

我所做的是将GPS的PPS输出连接到脚7
GPS的TXD连接到脚10
GPS的RXD连接到脚8
这允许ntpd从gps获取NMEA语句来设置日期和时间,而PPS则同步秒数。
以下udev规则将创建正确的/dev符号链接

KERNEL=="ttyTHS0", SYMLINK+="gps0"
KERNEL=="pps0", MODE="0660", SYMLINK+="gpspps0"```c
KERNEL=="ttyTHS0", SYMLINK+="gps0"
KERNEL=="pps0", MODE="0660", SYMLINK+="gpspps0"

conf中的这些条目将告诉ntpd同时使用NMEA语句和PPS…

server 127.127.20.0 mode 80 minpoll 3 burst iburst prefer
fudge 127.127.20.0 stratum 1 flag1 1 flag2 0 flag3 1 flag4 0 time1 0.0 time2 0.095 refid GPP0

需要对time2值进行一点调整(参见ntp文档)

ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 0.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 1.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 2.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 3.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 ntp.ubuntu.com  .POOL.          16 p    -   64    0    0.000    0.000   0.000
 GPS_NMEA(0)     .GPP0.           1 l    -    8    0    0.000    0.000   0.000
+time.nullrouten 132.163.97.1     2 u   11   64    1   78.194    0.584   1.964
+159.203.82.102  225.254.30.190   4 u   12   64    1   13.616    0.098   1.958
#time.gac.edu    127.67.113.92    2 u   12   64    1   44.552   -1.930   1.933
+atl0.jane.mattn 159.203.158.197  3 u   11   64    1   27.501    0.242   2.295
+mirror1.sjc02.s 216.218.254.202  2 u    9   64    1   82.024    2.156   3.990
+50-205-244-109- 50.205.244.28    2 u   10   64    1   30.418    2.101   2.553
+undef.us        198.82.247.51    3 u    8   64    1   41.361    1.437   2.649
+dev.smatwebdesi 204.9.54.119     2 u   10   64    1   46.248    1.869   2.544
+srcf-ntp.stanfo 171.64.7.105     2 u    8   64    1   80.683    0.557   2.083
 alphyn.canonica 132.163.97.1     2 u   16   64    1    4.576   -2.268   0.000
+cmpublishers.co 209.51.161.238   2 u   10   64    1   27.733    0.665   3.785
#li290-38.member 199.102.46.72    2 u    7   64    1   46.609   -3.801   3.020
+LAX.CALTICK.NET 72.29.161.5      2 u    7   64    1   70.200    2.860   2.647
+199.102.46.79 ( .GPS.            1 u    6   64    1   34.969    0.075   1.991
*ntp2.wiktel.com .GPS.            1 u    7   64    1   46.731    1.271   2.434
 golem.canonical 145.238.203.14   2 u   16   64    1   77.500   -1.331   0.000

似乎不起作用

dev/gps0和/dev/gpspps0是否存在,是否分别链接到/dev/ttyTHS0和/dev/pps0 ?
是否能看到来自/dev/ttyTHS0的NMEA句子吗?
ppstest /dev/pps0是否显示事件?

 ls /dev/gps
gps0     gpspps0  

 cat  /dev/ttyTHS0
stty < /dev/ttyTHS0
speed 115200 baud; line = 0;
intr = <undef>; quit = <undef>; erase = <undef>; kill = <undef>; eof = <undef>; start = <undef>; stop = <undef>; susp = <undef>; rprnt = <undef>; werase = <undef>; lnext = <undef>; discard = <undef>;
ignbrk -brkint -imaxbel
-opost -onlcr
-isig -iexten -echo -echoe -echok -echoctl -echoke
6.ntp软件问题

Ubuntu 18的ntpd版本有一个问题。
可能需要获取最新的ntp源并编译自己的ntp源。

声明:本文内容由易百纳平台入驻作者撰写,文章观点仅代表作者本人,不代表易百纳立场。如有内容侵权或者其他问题,请联系本站进行删除。
free-jdx
红包 93 5 评论 打赏
评论
0个
内容存在敏感词
手气红包
    易百纳技术社区暂无数据
相关专栏
置顶时间设置
结束时间
删除原因
  • 广告/SPAM
  • 恶意灌水
  • 违规内容
  • 文不对题
  • 重复发帖
打赏作者
易百纳技术社区
free-jdx
您的支持将鼓励我继续创作!
打赏金额:
¥1易百纳技术社区
¥5易百纳技术社区
¥10易百纳技术社区
¥50易百纳技术社区
¥100易百纳技术社区
支付方式:
微信支付
支付宝支付
易百纳技术社区微信支付
易百纳技术社区
打赏成功!

感谢您的打赏,如若您也想被打赏,可前往 发表专栏 哦~

举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

审核成功

发布时间设置
发布时间:
是否关联周任务-专栏模块

审核失败

失败原因
备注
拼手气红包 红包规则
祝福语
恭喜发财,大吉大利!
红包金额
红包最小金额不能低于5元
红包数量
红包数量范围10~50个
余额支付
当前余额:
可前往问答、专栏板块获取收益 去获取
取 消 确 定

小包子的红包

恭喜发财,大吉大利

已领取20/40,共1.6元 红包规则

    易百纳技术社区