This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TDA4VM: j721e get gPTP timestamp error with Linux

Part Number: TDA4VM
Other Parts Discussed in Thread: AM6442

Dear TI:

with Linux kernel version : ti-processor-sdk-linux-rt-j7-evm-08_02_00_01/board-support/linux-rt-5.10.100, we run gPTP stack with two J721E EVM board, this can align the the eth0  hardware timestamp from master to slave;

but after six hours, can not get the right hardware timestamp(we test more times, it can duplicate with run more than six hours);

for example:   now get the hardware timestamp is 22414217445338ns,    but after 125ms,  get the hardware timestamp is  1654687951323214838,  it is abnormal.  the code get timestramp as below:

    param.fd = ifa->fd[ifa->fdType];
    param.buf = buf;
    param.buflen = len;
    param.use_swts = ifa->use_swts;
    param.timestamp = &timestamp;
    param.flags = MSG_DONTWAIT;

    (void)memset(control, 0, sizeof(control));
    (void)memset(&msg, 0, sizeof(msg));
    msg.msg_name = &ss;
    msg.msg_namelen = sizeof(ss);
    msg.msg_iov = &iov;
    msg.msg_iovlen = 1;
    msg.msg_control = control;
    msg.msg_controllen = sizeof(control);

    cnt = (int)recvmsg(param->fd, &msg, param->flags);
    if (cnt < 0) {
        GPTP_ERR("recvmsg%sfailed, fd %d: %m", (param->flags == MSG_ERRQUEUE) ? " tx timestamp " : " ", param->fd);
        return -3;
    }
    for (cm = CMSG_FIRSTHDR(&msg); cm != NULL; cm = CMSG_NXTHDR(&msg, cm)) {
        level = cm->cmsg_level;
        type  = cm->cmsg_type;
        if (SOL_SOCKET == level && SO_TIMESTAMPING == type) {
            if (cm->cmsg_len < sizeof(*ts) * 3) {
                GPTP_WARN("short  SO_TIMESTAMPING message");
                return -EMSGSIZE;
            }
            ts = (struct timespec *) CMSG_DATA(cm);
        }
    }

    if (!ts) {
        return cnt;
    }
    if (param->use_swts) {
        (void)memcpy(param->timestamp, &ts[0], sizeof(struct timespec));
    }
    else {
        (void)memcpy(param->timestamp, &ts[2], sizeof(struct timespec));
    }

we also do other test: 1, we run same gPTP stack code with AM6442 board for more than six hours  (AM6442 Linux  kernel is same as J721 EVM board),  it is normal; 

2. we run gPTP stack with same J721 evm board, but with QNX version for more than six hours,   it  is normal also.

so we think that maybe linux kernel eth0 mac driver have some overflow? do you meet same issue?

  • Hi,

    To test ptp on linux, we use linuxptp libraries. The details are documented here : https://software-dl.ti.com/jacinto7/esd/processor-sdk-linux-jacinto7/08_06_01_02/exports/docs/linux/Foundational_Components/Kernel/Kernel_Drivers/Network/CPSW-PTP.html

    I am not sure which gPTP stack you are using?

    Can you go through the above documentation and see if you are something differently.

    Regards,
    Tanmay

  • HI:

    we test use ptp4l, add some log as below:  same as our gPTP stack, about 7 hours  port1 link down and up;  so we stop ptp4l because the timestamp offset    -7274961116 is abnormal;  if we do not stop ptp, ptp4l can sync from master again. 

    ptp4l_exit[27987.959]: master offset 1 s3 freq +496 path delay 410
    ptp4l_exit[27988.083]: master offset 1 s3 freq +496 path delay 410
    ptp4l_exit[27988.209]: master offset 8 s3 freq +506 path delay 409
    ptp4l_exit[27988.334]: master offset 4 s3 freq +502 path delay 410
    ptp4l_exit[27988.459]: master offset 5 s3 freq +504 path delay 410
    ptp4l_exit[27988.584]: master offset 4 s3 freq +503 path delay 410
    ptp4l_exit[27988.709]: master offset 2 s3 freq +500 path delay 409
    ptp4l_exit[27988.834]: master offset 11 s3 freq +514 path delay 409
    ptp4l_exit[27988.959]: master offset 7 s3 freq +509 path delay 409
    ptp4l_exit[27988.970]: timed out while polling for tx timestamp
    ptp4l_exit[27988.971]: increasing tx_timestamp_timeout may correct this issue, but it is likely caused by a driver bug
    ptp4l_exit[27988.971]: port 1 (eth0): send peer delay request failed
    ptp4l_exit[27988.971]: port 1 (eth0): SLAVE to FAULTY on FAULT_DETECTED (FT_UNSPECIFIED)
    ptp4l_exit[27989.012]: port 1 (eth0): link down
    ptp4l_exit[27989.012]: selected local clock 247625.fffe.96226f as best master
    ptp4l_exit[28000.608]: port 1 (eth0): link up
    ptp4l_exit[28000.640]: port 1 (eth0): FAULTY to SLAVE on INIT_COMPLETE
    ptp4l_exit[28000.888]: master offset -287 s3 freq +88 path delay 409
    ptp4l_exit[28000.900]: recvmsg tx timestamp failed: Resource temporarily unavailable
    ptp4l_exit[28000.900]: port 1 (eth0): send peer delay request failed
    ptp4l_exit[28000.900]: port 1 (eth0): SLAVE to FAULTY on FAULT_DETECTED (FT_UNSPECIFIED)
    ptp4l_exit[28000.936]: port 1 (eth0): link down
    ptp4l_exit[28008.035]: port 1 (eth0): link up
    ptp4l_exit[28008.068]: port 1 (eth0): FAULTY to SLAVE on INIT_COMPLETE
    ptp4l_exit[28008.171]: master offset -7274961116 s0 freq +88 path delay 409
    ptp4l_exit[28008.171]: 33333!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!wrong

  • Hi,

    Sorry for the delay.

    Can you provide the ptp.cfg used on both sides and the exact commands used. I will try to replicate this issue.

    One more thing I wanted to confirm was that have you tried this with non-rt linux as well? Or is the issue seen only in rt-linux? This might be a non-rt vs rt issue as well.

    Regards,
    Tanmay

  • yes . non-rt linux ;

    ./ptp4l -i swp3 -f configs/automotive-master.cfg -m

    ./ptp4l -i swp3 -f configs/automotive-slave.cfg -m

  • Hi,

    Can you also provide the configs used so that I am able to recreate the issue as best as possible.

    Also, the interface used, swp3, is it a ethernet interface connected with CPSW? Are you using CPSW2G or CPSW9G?

    Regards,
    Tanmay 

  • ptp4l -i eth0,          useing CPSW2G;

    and -f configs file as below,

    automotive-master.cfg:

    #
    # Automotive Profile example configuration for master containing those
    # attributes which differ from the defaults. See the file, default.cfg, for
    # the complete list of available options.
    #
    [global]
    # Options carried over from gPTP.
    gmCapable 1
    priority1 248
    priority2 248
    logSyncInterval -3
    syncReceiptTimeout 3
    neighborPropDelayThresh 800
    min_neighbor_prop_delay -20000000
    assume_two_step 1
    path_trace_enabled 1
    follow_up_info 1
    transportSpecific 0x1
    ptp_dst_mac 01:80:C2:00:00:0E
    network_transport L2
    delay_mechanism P2P
    #
    # Automotive Profile specific options
    #
    BMCA noop
    serverOnly 1
    inhibit_announce 1
    asCapable true
    inhibit_delay_req 1

    automotive-slave.cfg:

    #
    # Automotive Profile example configuration for clients containing those
    # attributes which differ from the defaults. See the file, default.cfg, for
    # the complete list of available options.
    #
    [global]
    #
    # Options carried over from gPTP.
    #
    gmCapable 1
    priority1 248
    priority2 248
    logSyncInterval -3
    syncReceiptTimeout 3
    neighborPropDelayThresh 800
    min_neighbor_prop_delay -20000000
    assume_two_step 1
    path_trace_enabled 1
    follow_up_info 1
    transportSpecific 0x1
    ptp_dst_mac 01:80:C2:00:00:0E
    network_transport L2
    delay_mechanism P2P
    #
    # Automotive Profile specific options
    #
    BMCA noop
    clientOnly 1
    inhibit_announce 1
    asCapable true
    ignore_source_id 1
    # Required to quickly correct Time Jumps in master
    step_threshold 1
    operLogSyncInterval 0
    operLogPdelayReqInterval 2
    msg_interval_request 1
    servo_offset_threshold 30
    servo_num_offset_values 10

  • Hi,

    Sorry for the delay in response.

    Is this issue still observed?

    Regards,
    Tanmay