summaryrefslogtreecommitdiffstats
path: root/meta-agl-bsp
diff options
context:
space:
mode:
Diffstat (limited to 'meta-agl-bsp')
-rw-r--r--meta-agl-bsp/meta-agl-refhw-gen3/recipes-navigation/gpsd/files/gpsd.refhw5
-rw-r--r--meta-agl-bsp/meta-agl-refhw-gen3/recipes-navigation/gpsd/files/refhw-gpsd-helper.sh35
-rw-r--r--meta-agl-bsp/meta-agl-refhw-gen3/recipes-navigation/gpsd/files/refhw-gpsd-helper.sh.bak32
-rw-r--r--meta-agl-bsp/meta-agl-refhw-gen3/recipes-navigation/gpsd/files/refhw.conf2
-rw-r--r--meta-agl-bsp/meta-agl-refhw-gen3/recipes-navigation/gpsd/gpsd-conf-refhw_1.0.bb39
5 files changed, 113 insertions, 0 deletions
diff --git a/meta-agl-bsp/meta-agl-refhw-gen3/recipes-navigation/gpsd/files/gpsd.refhw b/meta-agl-bsp/meta-agl-refhw-gen3/recipes-navigation/gpsd/files/gpsd.refhw
new file mode 100644
index 000000000..d22970681
--- /dev/null
+++ b/meta-agl-bsp/meta-agl-refhw-gen3/recipes-navigation/gpsd/files/gpsd.refhw
@@ -0,0 +1,5 @@
+# Default settings for gpsd.
+START_DAEMON="true"
+GPSD_OPTIONS=""
+DEVICES="/dev/ttySC3"
+GPSD_SOCKET="/var/run/gpsd.sock"
diff --git a/meta-agl-bsp/meta-agl-refhw-gen3/recipes-navigation/gpsd/files/refhw-gpsd-helper.sh b/meta-agl-bsp/meta-agl-refhw-gen3/recipes-navigation/gpsd/files/refhw-gpsd-helper.sh
new file mode 100644
index 000000000..d183ba43c
--- /dev/null
+++ b/meta-agl-bsp/meta-agl-refhw-gen3/recipes-navigation/gpsd/files/refhw-gpsd-helper.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+#
+# Script to detect AGL Reference Hardware and switch gpsd
+# configuration as necessary.
+#
+# NOTE:
+# For the most part errors are ignored and the script returns
+# 0/success so gpsd still be started if the script is somehow
+# run on a board without the expected hardware.
+
+COMPAT=/sys/firmware/devicetree/base/compatible
+GPSTTY=/dev/ttySC3
+
+#if [ ! \( -f "$COMPAT" -a -c "$GPSTTY" -a -f /etc/default/gpsd.refhw \) ]; then
+if [ ! \( -f "$COMPAT" -a -f /etc/default/gpsd.refhw \) ]; then
+ exit 0
+fi
+
+found=false
+for c in `cat $COMPAT | tr '\0' ' '`; do
+ if echo $c | grep -q '^agl,refhw-h3$'; then
+ found=true
+ break
+ fi
+done
+
+if $found; then
+ if [ ! -c "$GPSTTY" ]; then
+ exit 0
+ fi
+ update-alternatives --install /etc/default/gpsd gpsd-defaults /etc/default/gpsd.refhw 20
+else
+ update-alternatives --install /etc/default/gpsd gpsd-defaults /etc/default/gpsd.refhw 5
+fi
+exit 0
diff --git a/meta-agl-bsp/meta-agl-refhw-gen3/recipes-navigation/gpsd/files/refhw-gpsd-helper.sh.bak b/meta-agl-bsp/meta-agl-refhw-gen3/recipes-navigation/gpsd/files/refhw-gpsd-helper.sh.bak
new file mode 100644
index 000000000..2c9089aa0
--- /dev/null
+++ b/meta-agl-bsp/meta-agl-refhw-gen3/recipes-navigation/gpsd/files/refhw-gpsd-helper.sh.bak
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# Script to detect AGL Reference Hardware and switch gpdf configuration
+# as needed.
+#
+# NOTE:
+# For the most part errors are ignored and the script returns
+# 0/success so gpsd still be started if the script is somehow
+# run on a board without the expected hardware.
+
+COMPAT=/sys/firmware/devicetree/base/compatible
+GPSTTY=/dev/ttySC3
+
+if [ ! \( -f "$COMPAT" -a -c "$GPSTTY" -a -f /etc/default/gpsd.refhw \) ]; then
+ exit 0
+fi
+
+found=false
+for c in `cat $COMPAT | tr '\0' ' '`; do
+ echo "c = $c"
+ if echo $c | grep -q '^agl,refhw-h3$'; then
+ found=true
+ break
+ fi
+done
+
+if $found; then
+ update-alternatives --install /etc/default/gpsd gpsd-defaults /etc/default/gpsd.refhw 20
+else
+ update-alternatives --remove gpsd-defaults /etc/default/gpsd.refhw
+fi
+exit 0
diff --git a/meta-agl-bsp/meta-agl-refhw-gen3/recipes-navigation/gpsd/files/refhw.conf b/meta-agl-bsp/meta-agl-refhw-gen3/recipes-navigation/gpsd/files/refhw.conf
new file mode 100644
index 000000000..b7e3a7b0d
--- /dev/null
+++ b/meta-agl-bsp/meta-agl-refhw-gen3/recipes-navigation/gpsd/files/refhw.conf
@@ -0,0 +1,2 @@
+[Service]
+ExecStartPre=-/usr/sbin/refhw-gpsd-helper.sh
diff --git a/meta-agl-bsp/meta-agl-refhw-gen3/recipes-navigation/gpsd/gpsd-conf-refhw_1.0.bb b/meta-agl-bsp/meta-agl-refhw-gen3/recipes-navigation/gpsd/gpsd-conf-refhw_1.0.bb
new file mode 100644
index 000000000..c87308eb7
--- /dev/null
+++ b/meta-agl-bsp/meta-agl-refhw-gen3/recipes-navigation/gpsd/gpsd-conf-refhw_1.0.bb
@@ -0,0 +1,39 @@
+SUMMARY = "AGL Reference Hardware specific gpsd configuration"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+
+COMPATIBLE_MACHINE = "agl-refhw-h3"
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+SRC_URI = "file://gpsd.refhw \
+ file://refhw-gpsd-helper.sh \
+ file://refhw.conf \
+"
+
+inherit update-alternatives
+
+do_configure[noexec] = "1"
+do_compile[noexec] = "1"
+
+do_install() {
+ install -D -m 0644 ${WORKDIR}/gpsd.refhw ${D}/${sysconfdir}/default/gpsd.refhw
+ if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
+ install -D -m 0755 ${WORKDIR}/refhw-gpsd-helper.sh ${D}/${sbindir}/refhw-gpsd-helper.sh
+ install -d ${D}${sysconfdir}/systemd/system/gpsd.service.d
+ install -D -m 0644 ${WORKDIR}/refhw.conf ${D}${sysconfdir}/systemd/system/gpsd.service.d/refhw.conf
+ fi
+}
+
+ALTERNATIVE_${PN} = "gpsd-defaults"
+ALTERNATIVE_LINK_NAME[gpsd-defaults] = "${sysconfdir}/default/gpsd"
+ALTERNATIVE_TARGET[gpsd-defaults] = "${sysconfdir}/default/gpsd.refhw"
+# NOTE: Priority needs to be below default of 10 to avoid overriding the
+# default configuration. The script run by the systemd drop-in
+# will tweak things on boot to handle h3ulcb vs refhw.
+ALTERNATIVE_PRIORITY[gpsd-defaults] = "5"
+
+CONFFILES_${PN} = "${sysconfdir}/default/gpsd.refhw"
+
+# NOTE: Explicitly not defining RPROVIDES of "virtual/gpsd-conf" to
+# avoid conflicting with the default configuration and potentially
+# changing behavior on m3ulcb/h3ulcb.