Because of the holidays, TI E2E™ design support forum responses will be delayed from Dec. 25 through Jan. 2. Thank you for your patience.

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.

CCS/AM4379: PTP problem

Part Number: AM4379

Tool/software: Code Composer Studio

I am using  AM4379 board  IDK-AM437X

  running in Linux

I wnat to keep the PC(ubuntu) time the same to my Baord

using the ptp

following "Testing CPTS/PTP" in

 http://software-dl.ti.com/processor-sdk-linux/esd/docs/latest/linux/Foundational_Components_Kernel_Drivers.html#common-platform-time-sync-cpts

And I can see it works!

Host(ubuntu):sudo  ./ptp4l -E -2 -H -i enp4s0 -l 7 -m -q -p /dev/ptp0 
Slave(board):sudo ./ptp4l -E -2 -H -i eth0 -s -l 7 -m -q -p /dev/ptp0

But I have a problem:

My board shows:

PC shows:

But the timestamp is not the same!

timestamp of My PC:

My board timestamp:

So what is the reason maybe?

  • Hi,

    At the moment I am not sure if the time stamp printed out on the output is the same as time stamp used to synchronize the two platforms. Later on in the section there is an example on how to read the timestamps, did you see the link to the code on how to read the timestamps?

    Best Regards,

    Schuyler

  • Hi

    It works!!!

    Thank you!!!

    Regards;

  • Hi:

    I got a new problem ...

    Host(ubuntu):sudo  ./ptp4l -E -2 -H -i enp4s0 -l 7 -m -q -p /dev/ptp0 
    Slave(board):sudo ./ptp4l -E -2 -H -i eth0 -s -l 7 -m -q -p /dev/ptp0

    yes.It seems works...

    I use this code to read the timestamp.

    -----------------------------------------------------------------------------------------------------------------------

    #define _GNU_SOURCE
    #define __SANE_USERSPACE_TYPES__        /* For PPC64, to get LL64 types */
    #include <errno.h>
    #include <fcntl.h>
    #include <inttypes.h>
    #include <math.h>
    #include <signal.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <sys/ioctl.h>
    #include <sys/mman.h>
    #include <sys/stat.h>
    #include <sys/time.h>
    #include <sys/timex.h>
    #include <sys/types.h>
    #include <time.h>
    #include <unistd.h>
    #include <linux/ptp_clock.h>
    #define DEVICE "/dev/ptp0"
    
    /* clock_adjtime is not available in GLIBC < 2.14 */
    #if !__GLIBC_PREREQ(2, 14)
    #include <sys/syscall.h>
    static int clock_adjtime(clockid_t id, struct timex *tx)
    {
    	return syscall(__NR_clock_adjtime, id, tx);
    }
    #endif
    static clockid_t get_clockid(int fd)
    {
    #define CLOCKFD 3
    #define FD_TO_CLOCKID(fd)	((~(clockid_t) (fd) << 3) | CLOCKFD)
    	return FD_TO_CLOCKID(fd);
    }
    
    
    
    
     
    int main(int argc, char *argv[])
    {
    	
    	struct timespec ts;
    	struct timex tx;
    	static timer_t timerid;
    	struct itimerspec timeout;
    	int c, cnt, fd;
    	char *device = DEVICE;
    	clockid_t clkid;
    	int adjfreq = 0x7fffffff;
    	int adjtime = 0;
    	int capabilities = 0;
    	int extts = 0;
    	int gettime = 0;
    	int index = 0;
    	int list_pins = 0;
    	int oneshot = 0;
    	int pct_offset = 0;
    	int n_samples = 0;
    	int periodic = 0;
    	int perout = -1;
    	int pin_index = -1, pin_func;
    	
    	fd = open(device, O_RDWR);
    	if (fd < 0) {
    		fprintf(stderr, "opening %s: %s\n", device, strerror(errno));
    		return -1;
    	}
    	clkid = get_clockid(fd);
    	if (CLOCK_INVALID == clkid) {
    		fprintf(stderr, "failed to read clock id\n");
    		return -1;
    	}
    	 
     while(1){
    		if (clock_gettime(clkid, &ts)) {
    			perror("clock_gettime");
    		} else {
    			printf("clock time: %ld.%09ld or %s",
    			       ts.tv_sec, ts.tv_nsec, ctime(&ts.tv_sec));
    		}
    	}
     
    	close(fd);
    	return 0;
    }
    

    --------------------------------------------------------------------------------------------------

    and the Board shows :

    The date and time is right.but the timestamp is false:

    1.The timastamp  should  be 1570006833  in  my  country  at  that  moment while  not  1570035633.

    It  seems  just  8 hours  between  them.

    2.the code I used to read the timestamp is from here:

    https://www.mjmwired.net/kernel/Documentation/ptp/testptp.c

    I simplified it.

    just ./testptp -g

     

    And when I type "date".the Board shows this:


    SO where is the problem maybe ?

    Maybe the timezone isn't correct?

     

     

    Best Regards

  • Hi,

    I am closing this thread as the user has started a second thread here.

    Best Regards,

    Schuyler