Linux Kernel build

build/.config

ls arch/loongarch/boot/dts/loongson
./arch/loongarch/boot/dts/loongson/loongson_2k2100.dts

[*] Enable builtin dtb in kernel

(loongson_2k2100) Built in DTB

DTB设备树中带有earlycon参数,boot.cfg中又earlycon=uart,0x1fe001e0了一次,需要把boot.cfgearlycon参数删了。

console=ttyS0,115200 earlycon=uart,mmio,0x1fe001e0

TSN

PMON config

set run "ifconfig syn0 10.20.4.233;load http://10.20.4.61/vm;g console=ttyS0,115200 root=/dev/sda3"

set run "ifconfig syn0 10.20.4.234;load http://10.20.4.61/vm;g console=ttyS0,115200 root=/dev/sda3"

$run

ifconfig

# host1
ifconfig enp0s3f0 192.168.1.2/24
# host2
ifconfig enp0s3f1 192.168.1.3/24

LinuxPTP

# host1: 主时钟
ptp4l -i enp0s3f0 -m -H -2 -P
# host2: 从时钟
ptp4l -i enp0s3f1 -m -H -2 -P -s

LinuxPTP test

ptp4l参数说明:

主时钟:

从时钟:

测试中的参数说明:

  • master offset: 即PTP协议中定义的主从端时间差,单位:ns
  • s0,s1,s2: 表示时钟同步时的状态,s0表示未锁定,s1表示正在同步,s2表示锁定,锁定状态表示不会再发生阶跃行同步,只是缓慢调整
  • freq:
  • port 0:INITIALIZING to LISTENING on INIT_COMPLET : 本地PTP管理的Unix域socket;
  • port 1:new foreign … : eno1上的端口;
  • 从钟端口状态由UNCALIBRATED 变为SLAVE时,则从钟已经成功地与best master同步。

code

enum servo_state clock_synchronize(struct clock *c, tmv_t ingress, tmv_t origin) {
//......
    pr_info("master offset %10" PRId64 " s%d freq %+7.0f "
        "path delay %9" PRId64,
        tmv_to_nanoseconds(c->master_offset), state, adj,
        tmv_to_nanoseconds(c->path_delay));  
//......
    return state;
}

标签: tsn

添加新评论