Skip to content

Commit

Permalink
linuxptp: add systemd services
Browse files Browse the repository at this point in the history
Add systemd services phc2sys@.service and ptp4l@.service,
these services are taken from the Ubuntu/Debian linuxptp
package.

Update the recipe to install them when needed using the
systemd bbclass, the services are disabled by default.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
  • Loading branch information
luca-fancellu authored and kraj committed Oct 13, 2023
1 parent 7112ecb commit 65e54e3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Synchronize system clock or PTP hardware clock (PHC)
Documentation=man:phc2sys
Requires=ptp4l.service
After=ptp4l.service
Before=time-sync.target

[Service]
Type=simple
ExecStart=/usr/sbin/phc2sys -w -s %I

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Precision Time Protocol (PTP) service for %I
Documentation=man:ptp4l
After=sys-subsystem-net-devices-%i.device

[Service]
Type=simple
ExecStart=/usr/sbin/ptp4l -f /etc/linuxptp/ptp4l.conf -i %I

[Install]
WantedBy=multi-user.target
16 changes: 16 additions & 0 deletions meta-oe/recipes-connectivity/linuxptp/linuxptp_4.1.bb
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,24 @@ SRC_URI = "${LINUXPTP_SRC_URI}/files/v4.1/linuxptp-${PV}.tgz \
file://build-Allow-CC-and-prefix-to-be-overriden.patch \
file://Use-cross-cpp-in-incdefs.patch \
file://0001-include-string.h-for-strncpy.patch \
file://systemd/phc2sys@.service \
file://systemd/ptp4l@.service \
"

SRC_URI[md5sum] = "1db8699fc155965341759be5e5aad938"
SRC_URI[sha256sum] = "e1743d44f8208897e30895da3579e670ff919b914feb4b5a949f3e421ddde535"

inherit systemd

UPSTREAM_CHECK_URI = "${LINUXPTP_SRC_URI}/files/"
UPSTREAM_CHECK_REGEX = "(?P<pver>\d+(\.\d+)+)/"

EXTRA_OEMAKE = "ARCH=${TARGET_ARCH} EXTRA_CFLAGS='${CFLAGS}' mandir=${mandir}"

export KBUILD_OUTPUT="${RECIPE_SYSROOT}"

LINUXPTP_SYSTEMD_SERVICES = "phc2sys@.service ptp4l@.service"

do_install() {
oe_runmake install DESTDIR=${D} prefix=${prefix}

Expand All @@ -35,8 +41,18 @@ do_install() {
install -d ${D}/${sysconfdir}/linuxptp/
install -m 644 ${S}/configs/default.cfg \
${D}${sysconfdir}/linuxptp/ptp4l.conf

# Install systemd services
install -d ${D}/${systemd_unitdir}/system/
for service in ${LINUXPTP_SYSTEMD_SERVICES}; do
install -m 644 ${WORKDIR}/systemd/$service \
${D}/${systemd_unitdir}/system/$service
done
}

SYSTEMD_SERVICE:${PN} = "${LINUXPTP_SYSTEMD_SERVICES}"
SYSTEMD_AUTO_ENABLE:${PN} = "disable"

PACKAGES =+ "${PN}-configs"

FILES:${PN}-configs += "${docdir}"

0 comments on commit 65e54e3

Please sign in to comment.