0

I am trying to compile a script that helps me test LinuxPTP. The testptp.c file is a script that helps do this. It is built into the Linux kernel. However, I am unable to compile it. Is this just me? I see tons of people talking about this utility script but the only tutorials online I see are this: https://docs.nvidia.com/networking/display/NVIDIA5TTechnologyUserManualv10/Testptp

It tells you to compile testptp.c using gcc. I compiled using the following command, in a directory with just testptp.c: gcc testptp.c -o testptp. I also pulled the Linux kernel from git and went into tools/testing/selftests/ptp and ran make. Both yielded the same results.

Here is my output:

Makefile:10: warning: overriding recipe for target 'clean' ../lib.mk:130: warning: ignoring old recipe for target 'clean' gcc -I../../../../usr/include/ testptp.c -lrt -o testptp testptp.c: In function ‘main’: testptp.c:295:15: error: ‘struct ptp_clock_caps’ has no member named ‘adjust_phase’ 295 | caps.adjust_phase); | ^ testptp.c:429:28: error: ‘PTP_PEROUT_DUTY_CYCLE’ undeclared (first use in this function) 429 | perout_request.flags |= PTP_PEROUT_DUTY_CYCLE; | ^~~~~~~~~~~~~~~~~~~~~ testptp.c:429:28: note: each undeclared identifier is reported only once for each function it appears in testptp.c:430:18: error: ‘struct ptp_perout_request’ has no member named ‘on’ 430 | perout_request.on.sec = pulsewidth / NSEC_PER_SEC; | ^ testptp.c:431:18: error: ‘struct ptp_perout_request’ has no member named ‘on’ 431 | perout_request.on.nsec = pulsewidth % NSEC_PER_SEC; | ^ testptp.c:434:28: error: ‘PTP_PEROUT_PHASE’ undeclared (first use in this function); did you mean ‘PTP_PEROUT_REQUEST’? 434 | perout_request.flags |= PTP_PEROUT_PHASE; | ^~~~~~~~~~~~~~~~ | PTP_PEROUT_REQUEST testptp.c:435:18: error: ‘struct ptp_perout_request’ has no member named ‘phase’ 435 | perout_request.phase.sec = perout_phase / NSEC_PER_SEC; | ^ testptp.c:436:18: error: ‘struct ptp_perout_request’ has no member named ‘phase’ 436 | perout_request.phase.nsec = perout_phase % NSEC_PER_SEC; | ^ make: *** [<builtin>: testptp] Error 1 

I am running Ubuntu 20.04. Linux Kernel Version: 5.15.0-53-generic

Does this work for anyone else?

1
  • You also need to tell us which kernel this refers to and if this is the running version. It certainly compiles here on opensuse 5.14.21-24.33 Commented Nov 23, 2022 at 11:31

1 Answer 1

0

Overriding the file /usr/include/linux/ptp_clock.h with the following file seems to work for me.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.