Avnu / OpenAvnu

OpenAvnu - an Avnu sponsored repository for Time Sensitive Network (TSN and AVB) technology
472 stars 292 forks source link

Can't run PTP daemon on Raspberry Pi for AirPlay service #845

Closed zzaponka closed 6 years ago

zzaponka commented 6 years ago

Hi, everybody!

I would ask for help with using OpenAvnu PTP daemon implementation with AirPlay 2 service on Raspberry Pi Model 3 B+ board.

First, here comes the issue. When I try to run the daemon, I have the following error:

pi@raspberrypi:~/git/OpenAvnu/daemons/gptp/linux/build/obj $ ./daemon_cl eth0
INFO     : GPTP [12:31:28:812] gPTP starting
ERROR    : GPTP [12:31:28:815] shm_open(): Failed to set ownership
ERROR    : GPTP [12:31:28:816] failed to open general socket: Operation not
permitted
ERROR    : GPTP [12:31:28:816] failed to initialize port

When I run the daemon with sudo prefix, the error changes:

pi@raspberrypi:~/git/OpenAvnu/daemons/gptp/linux/build/obj $ sudo ./daemon_cl
eth0
INFO     : GPTP [12:32:04:586] gPTP starting
ERROR    : GPTP [12:32:04:589] Failed to configure timestamping: Operation not supported
ERROR    : GPTP [12:32:04:589] post_init failed

ERROR    : GPTP [12:32:04:590] failed to initialize port

Looking into the code, it can be seen that error is caused by these lines inside daemons/gptp/linux/src/linux_hal_generic.cpp file:

err = ioctl( sd, SIOCSHWTSTAMP, &device );
if( err == -1 ) {
    GPTP_LOG_ERROR("Failed to configure timestamping: %s", strerror(errno));
    return false;
}

But as far as I know, RPi's built-in Ethernet controller doesn't support HW timestamping, only SW one. After I have opened the Makefile, there's a check for that, it seeks for ptp_clock.h header and if it exists, adds appropriate compilation flag. Don't think that it's okay in my case.

Also I have tried to rebuild the kernel to add timestamping support, only to realize that in current version (for now, 4.14.71-v7+ version is used) the patch is already present.

What gives me hope is that I have found READMEaPTP.rst file inside feature-aptp-experimental branch which states that there a fork exists that was tested on RPi with AirPlay service running and using several speakers to play the same stream in sync, that's exactly my case.

Also I can to add that I have tried to build the daemon both with orignial repo (this one, on master branch as well as on feature-aptp-experimental one) and on the fork (also on master branch and on ArtAndLogic-aPTP-changes, adding in the latter case ARCH=RPI variable before make clean all command). But I have managed to get working binary only on the fork's master branch. In all other cases, there were compilation errors or Segmentation fault error. Cross-compilation didn't help either (the binary wasn't actually built for ARM architecture).

Bottom line, any ideas how to get PTP daemon run on RPi are highly appreciated.

Thanks for the attention.

zzaponka commented 6 years ago

Finally, have managed to run the daemon in standalone mode after building it on proposed repo/fork.