diff options
22 files changed, 780 insertions, 212 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index e07d2a9..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,36 +0,0 @@ -variables: - GIT_STRATEGY: none - -before_script: - - test -d mlinux || git clone git@gitlab.multitech.net:mirrors/mlinux.git - - cd mlinux - - git pull - - (test -f env-oe.sh && ./setup.sh --update) || ./setup.sh - - source env-oe.sh - - cd layers/meta-mlinux - - git fetch - - git checkout $CI_BUILD_REF - - cd ../.. - -cache: - untracked: true - -mtcdt_mlinux: - stage: build - tags: - - mlinux - script: - - bitbake mlinux-factory-image - artifacts: - paths: - - mlinux/build/tmp/deploy/images/mtcdt/*-upgrade.bin - -mtcap_mlinux: - stage: build - tags: - - mlinux - script: - - MACHINE=mtcap bitbake mlinux-mtcap-image - artifacts: - paths: - - mlinux/build/tmp/deploy/images/mtcap/*-upgrade.bin diff --git a/conf/distro/mlinux.conf b/conf/distro/mlinux.conf index 9a8011d..e4b199e 100644 --- a/conf/distro/mlinux.conf +++ b/conf/distro/mlinux.conf @@ -1,7 +1,7 @@ DISTRO = "mlinux" DISTRO_NAME = "mLinux" DISTRO_BASE_VERSION = "3.2" -DISTRO_VERSION = "${DISTRO_BASE_VERSION}.4" +DISTRO_VERSION = "${DISTRO_BASE_VERSION}.5" DISTRO_CODENAME = "" SDK_VENDOR = "-mlinux" SDK_VERSION := "${@'${DISTRO_VERSION}'.replace('snapshot-${DATE}','snapshot')}" diff --git a/prod-scripts/MTCDT-0.1/cdteep.sh b/prod-scripts/MTCDT-0.1/cdteep.sh new file mode 100755 index 0000000..c0e1e14 --- /dev/null +++ b/prod-scripts/MTCDT-0.1/cdteep.sh @@ -0,0 +1,110 @@ +#!/bin/sh +# This scripts follows old school option rules, and all +# options must come before parameters. Four parameters +# are required. Options requiring parameters must be +# followed by their parameter, with or without a space. +# Options not requiring parameters can be ganged, and may +# precede a single option requiring a parameter. +# +MYNAME=cdteep.sh +out="/sys/bus/i2c/devices/0-0056/eeprom" +vendor_id="Multi-Tech Systems" +hw_version="MTCDT-0.1" + + +# Set the MTCDT EEPROM +function usage { + echo "${MYNAME}"' -d -g -b "bt_mac_addr" -w "wifi_mac_addr" -i "imei number" -l "product-id" "device-id" "uuid" "eth_mac_addr"' >&2 + cat <<!EOF >&2 + assumptions: + All options are optional and must come first. + -b and -w require a following mac address + -d displays the PROM, do not write. Ignores other parameters. + -g GPS capability. + -l lora capability. + -i requires a following imei number + + Example + cdteep.sh -lb 01:12:AB:C3:23:FE MTCDT-210L 3489235379 125-6356-2283-9792 12:34:AB:CD:8F:34 + To add wifimac and remove lora: + ${MYNAME} -b 01:12:AB:C3:23:FE -w 04:16:3C:C3:45:75 MTCDT-210L 3489235379 125-6356-2283-9792 12:34:AB:CD:8F:34 + + product-id, device-id, uuid and eth_mac_addr are required. + + -d display EEPROM + -g capa-GPS + -l capa-Lora + The following fields are fixed: + out-file ${out} + vendor-id ${vendor_id} + hw-version ${hw_version} +!EOF + exit 1 +} + +((display=0)) + +while getopts b:dgw:i:l opt ; do +echo looking at opt $opt + case $opt in + b) + bt_mac_addr="$OPTARG" + barg="--mac-bluetooth ${OPTARG} --capa-bluetooth" + ;; + w) + wifi_mac_addr="$OPTARG" + warg="--mac-wifi ${OPTARG} --capa-wifi" + ;; + i) + imei="$OPTARG" + if ((${#imei} == 0)) ; then + echo "i option requires an imei number." >&2 + usage + fi + iarg="--imei ${OPTARG}" + ;; + l) + larg="--capa-lora" + ;; + d) + echo -e "\n\nEEPROM contents" + echo "-----------------" + mts-id-eeprom --in-file $out + exit + ;; + g) + gps="--capa-gps" + ;; + \?) + usage + ;; + :) + echo "Option -$OPTARG requires an argument." >&2 + usage + ;; + esac +done + + +shift $((OPTIND-1)) + +if (($# != 4)) ; then + echo Need 4 parameters beyond the options. >&2 + echo "You specified $#." >&2 + usage + exit 1 +fi +product_id=$1 +device_id=$2 +uuid=$3 +mac=$4 + +mts-id-eeprom --out-file $out --out-format bin --vendor-id "$vendor_id" \ + --product-id "$product_id" --device-id "$device_id" \ + --hw-version "$hw_version" --mac-addr $mac \ + ${warg} ${barg} \ + ${iarg} ${larg} ${gps} --uuid "$uuid" + +echo -e "\n\nNew contents" +echo "-----------------" +mts-id-eeprom --in-file $out diff --git a/recipes-connectivity/lora/lora-network-server_1.0.18.bb b/recipes-connectivity/lora/lora-network-server_1.0.21.bb index 1a7aab6..5091b9d 100644 --- a/recipes-connectivity/lora/lora-network-server_1.0.18.bb +++ b/recipes-connectivity/lora/lora-network-server_1.0.21.bb @@ -13,8 +13,8 @@ SRC_URI = "http://multitech.net/downloads/lora-network-server_${TUNE_PKGARCH}_${ file://lora-network-server.logrotate.conf \ " -SRC_URI[md5sum] = "9e83c88149fc9b9c969034edcc6371f8" -SRC_URI[sha256sum] = "1e94620eed249c0c431987ac64850e329f7506ddd2d3c2ff6de0a554cb76ed52" +SRC_URI[md5sum] = "5d8e6f207fa95c53844c8992a999a014" +SRC_URI[sha256sum] = "af454f942c8b441580b014087d4c707affc5016451a12ff493e63b4530ad10d9" # binaries are already stripped, so suppress warning INSANE_SKIP_${PN} = "already-stripped" diff --git a/recipes-connectivity/lora/lora-packet-forwarder/global_conf.json.3.0.0.MTCAP-LORA-1-5.EU868.basic b/recipes-connectivity/lora/lora-packet-forwarder/global_conf.json.3.0.0.MTCAP-LORA-1-5.EU868.basic index 8f8d93d..e29b1f1 100644 --- a/recipes-connectivity/lora/lora-packet-forwarder/global_conf.json.3.0.0.MTCAP-LORA-1-5.EU868.basic +++ b/recipes-connectivity/lora/lora-packet-forwarder/global_conf.json.3.0.0.MTCAP-LORA-1-5.EU868.basic @@ -1,17 +1,17 @@ { "SX1301_conf": { "lorawan_public": true, - "clksrc": 0, /* radio_0 provides clock to concentrator */ + "clksrc": 0, "lbt_cfg": { "enable": false, - "rssi_target": 160, /* rssi in dBm = -lbt_rssi_target/2 */ + "rssi_target": 160, "nb_channel": 1, "start_freq": 869525000, "scan_time_us": 5000, "tx_delay_1ch_us": 4000000, "tx_delay_2ch_us": 4000000 }, - "antenna_gain": 1.4, /* antenna gain, in dBi */ + "antenna_gain": 1.4, "radio_0": { "enable": true, "type": "SX1257", @@ -29,55 +29,46 @@ "tx_enable": false }, "chan_multiSF_0": { - /* Lora MAC channel, 125kHz, all SF, 868.1 MHz */ "enable": true, "radio": 1, "if": -400000 }, "chan_multiSF_1": { - /* Lora MAC channel, 125kHz, all SF, 868.3 MHz */ "enable": true, "radio": 1, "if": -200000 }, "chan_multiSF_2": { - /* Lora MAC channel, 125kHz, all SF, 868.5 MHz */ "enable": true, "radio": 1, "if": 0 }, "chan_multiSF_3": { - /* Lora MAC channel, 125kHz, all SF, 867.1 MHz */ "enable": true, "radio": 0, "if": -400000 }, "chan_multiSF_4": { - /* Lora MAC channel, 125kHz, all SF, 867.3 MHz */ "enable": true, "radio": 0, "if": -200000 }, "chan_multiSF_5": { - /* Lora MAC channel, 125kHz, all SF, 867.5 MHz */ "enable": true, "radio": 0, "if": 0 }, "chan_multiSF_6": { - /* Lora MAC channel, 125kHz, all SF, 867.7 MHz */ "enable": true, "radio": 0, "if": 200000 }, "chan_multiSF_7": { - /* Lora MAC channel, 125kHz, all SF, 867.9 MHz */ "enable": true, "radio": 0, "if": 400000 }, "chan_Lora_std": { - /* Lora MAC channel, 250kHz, SF7, 868.3 MHz */ "enable": true, "radio": 1, "if": -200000, @@ -85,7 +76,6 @@ "spread_factor": 7 }, "chan_FSK": { - /* FSK 50kbps channel, 868.8 MHz */ "enable": true, "radio": 1, "if": 300000, @@ -93,130 +83,110 @@ "datarate": 50000 }, "tx_lut_0": { - /* TX gain table, index 0 */ "pa_gain": 0, "mix_gain": 9, "rf_power": -6, "dig_gain": 1 }, "tx_lut_1": { - /* TX gain table, index 1 */ "pa_gain": 0, "mix_gain": 12, "rf_power": -3, "dig_gain": 1 }, "tx_lut_2": { - /* TX gain table, index 2 */ "pa_gain": 1, "mix_gain": 8, "rf_power": 0, "dig_gain": 2 }, "tx_lut_3": { - /* TX gain table, index 3 */ "pa_gain": 1, "mix_gain": 11, "rf_power": 3, "dig_gain": 3 }, "tx_lut_4": { - /* TX gain table, index 4 */ "pa_gain": 1, "mix_gain": 10, "rf_power": 6, "dig_gain": 0 }, "tx_lut_5": { - /* TX gain table, index 5 */ "pa_gain": 2, "mix_gain": 11, "rf_power": 10, "dig_gain": 3 }, "tx_lut_6": { - /* TX gain table, index 6 */ "pa_gain": 2, "mix_gain": 9, "rf_power": 11, "dig_gain": 1 }, "tx_lut_7": { - /* TX gain table, index 7 */ "pa_gain": 2, "mix_gain": 9, "rf_power": 12, "dig_gain": 0 }, "tx_lut_8": { - /* TX gain table, index 8 */ "pa_gain": 2, "mix_gain": 11, "rf_power": 13, "dig_gain": 2 }, "tx_lut_9": { - /* TX gain table, index 9 */ "pa_gain": 2, "mix_gain": 11, "rf_power": 14, "dig_gain": 1 }, "tx_lut_10": { - /* TX gain table, index 10 */ "pa_gain": 2, "mix_gain": 12, "rf_power": 16, "dig_gain": 0 }, "tx_lut_11": { - /* TX gain table, index 11 */ "pa_gain": 3, "mix_gain": 10, "rf_power": 20, "dig_gain": 3 }, "tx_lut_12": { - /* TX gain table, index 12 */ "pa_gain": 3, "mix_gain": 9, "rf_power": 23, "dig_gain": 0 }, "tx_lut_13": { - /* TX gain table, index 13 */ "pa_gain": 3, "mix_gain": 12, "rf_power": 25, "dig_gain": 2 }, "tx_lut_14": { - /* TX gain table, index 14 */ "pa_gain": 3, "mix_gain": 13, "rf_power": 26, "dig_gain": 0 }, "tx_lut_15": { - /* TX gain table, index 15 */ "pa_gain": 3, "mix_gain": 15, "rf_power": 27, "dig_gain": 0 } }, - "gateway_conf": { - "gateway_ID": "AA555A0000000000", - /* change with default server address/ports, or overwrite in local_conf.json */ + "gateway_ID": "<WILL-BE-AUTO-REPLACED-WITH-LORA-EUI>", "server_address": "localhost", "serv_port_up": 1680, "serv_port_down": 1680, - /* adjust the following parameters for your network */ "keepalive_interval": 10, "stat_interval": 30, "push_timeout_ms": 100, - /* forward only valid packets */ "forward_crc_valid": true, "forward_crc_error": false, "forward_crc_disabled": false diff --git a/recipes-connectivity/lora/lora-packet-forwarder_3.0.0.bb b/recipes-connectivity/lora/lora-packet-forwarder_3.0.0.bb index ada0493..e9ff489 100644 --- a/recipes-connectivity/lora/lora-packet-forwarder_3.0.0.bb +++ b/recipes-connectivity/lora/lora-packet-forwarder_3.0.0.bb @@ -47,26 +47,21 @@ do_install() { install -m 755 util_ack/util_ack ${D}${LORA_DIR}/forwarder-utils/ install -m 755 util_tx_test/util_tx_test ${D}${LORA_DIR}/forwarder-utils/ install -m 755 ${WORKDIR}/README.md ${D}${LORA_DIR}/ + + install -d ${D}${sysconfdir}/default + install -m 0644 ${WORKDIR}/lora-packet-forwarder.default ${D}${sysconfdir}/default/lora-packet-forwarder + install -d ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/lora-packet-forwarder.init ${D}${sysconfdir}/init.d/lora-packet-forwarder } do_install_append_mtcdt() { install -m 755 ${WORKDIR}/global_conf.json.3.0.0.MTAC_LORA_1_5.EU868.basic.clksrc0 ${D}${LORA_DIR}/global_conf.json install -m 755 ${WORKDIR}/global_conf.json.3.0.0.MTAC_LORA_1_0.EU868.basic.clksrc0 ${D}${LORA_DIR}/global_conf.json.MTAC_LORA_1_0 install -m 755 ${WORKDIR}/global_conf.json.3.0.0.MTAC_LORA_1_5.EU868.basic.clksrc0 ${D}${LORA_DIR}/global_conf.json.MTAC_LORA_1_5 - - install -d ${D}${sysconfdir}/default - install -m 0644 ${WORKDIR}/lora-packet-forwarder.default ${D}${sysconfdir}/default/lora-packet-forwarder - install -d ${D}${sysconfdir}/init.d - install -m 0755 ${WORKDIR}/lora-packet-forwarder.init ${D}${sysconfdir}/init.d/lora-packet-forwarder } do_install_append_mtcap() { install -m 755 ${WORKDIR}/global_conf.json.3.0.0.MTCAP-LORA-1-5.EU868.basic ${D}${LORA_DIR}/global_conf.json - - install -d ${D}${sysconfdir}/default - install -m 0644 ${WORKDIR}/lora-packet-forwarder.default ${D}${sysconfdir}/default/lora-packet-forwarder - install -d ${D}${sysconfdir}/init.d - install -m 0755 ${WORKDIR}/lora-packet-forwarder.init ${D}${sysconfdir}/init.d/lora-packet-forwarder } FILES_${PN} += "${LORA_DIR}" diff --git a/recipes-core/images/mlinux-factory-image.bb b/recipes-core/images/mlinux-factory-image.bb index 6ce05ab..c50619b 100644 --- a/recipes-core/images/mlinux-factory-image.bb +++ b/recipes-core/images/mlinux-factory-image.bb @@ -1,5 +1,6 @@ # Conduit 0.0 or 0.1 without RS9113 require mlinux-base-image.bb +DESCRIPTION = "mLinux factory image" LIGHTTPD = "lighttpd \ lighttpd-module-cgi lighttpd-module-indexfile \ @@ -80,6 +81,8 @@ IMAGE_INSTALL += "sms-utils" # Multi-Tech GPS Utility IMAGE_INSTALL += "venus-gps" IMAGE_INSTALL += "pps-tools" -IMAGE_INSTALL += "gpsd" + +# When ntp is to use the GPS, gps-utils is required +IMAGE_INSTALL += "gpsd ntp ntp-utils gps-utils gpsd-udev" IMAGE_INSTALL += "uvccapture" diff --git a/recipes-core/images/mlinux-rs9113-base-image.bb b/recipes-core/images/mlinux-rs9113-base-image.bb index a4e9f23..8aab186 100644 --- a/recipes-core/images/mlinux-rs9113-base-image.bb +++ b/recipes-core/images/mlinux-rs9113-base-image.bb @@ -1,5 +1,5 @@ require mlinux-base-image.bb -DESCRIPTION = "mLinux base image" +DESCRIPTION = "mLinux base image with rs9113 drivers" # Extra stuff to install IMAGE_INSTALL += " rs9113 " diff --git a/recipes-core/images/mlinux-rs9113-factory-image.bb b/recipes-core/images/mlinux-rs9113-factory-image.bb index bf2beaa..3fe2ca6 100644 --- a/recipes-core/images/mlinux-rs9113-factory-image.bb +++ b/recipes-core/images/mlinux-rs9113-factory-image.bb @@ -1,84 +1,5 @@ -require mlinux-rs9113-base-image.bb +require mlinux-factory-image.bb +DESCRIPTION = "mLinux factory image with rs9113 drivers" -LIGHTTPD = "lighttpd \ - lighttpd-module-cgi lighttpd-module-indexfile \ - lighttpd-module-redirect lighttpd-module-auth \ - lighttpd-module-access lighttpd-module-accesslog \ - lighttpd-module-rewrite lighttpd-module-proxy lighttpd-module-fastcgi \ - lighttpd-module-scgi lighttpd-module-alias \ - lighttpd-module-dirlisting lighttpd-module-staticfile \ - " - -# Lighttpd web server -IMAGE_INSTALL += "${LIGHTTPD}" - -IMAGE_INSTALL += "sqlite3" - -IMAGE_INSTALL += "autossh" - -# Monit system/process monitor -IMAGE_INSTALL += "monit" - -# LoRa support (MTAC-LORA accessory card) -IMAGE_INSTALL += "lora-gateway-utils lora-network-server lora-query" - -# MQTT server -IMAGE_INSTALL += "mosquitto mosquitto-clients" - -# Perl support -IMAGE_INSTALL += "perl" -IMAGE_INSTALL += "perl-module-io perl-module-fcntl" -# not in meta-oe or oe-core... -#IMAGE_INSTALL += "libdevice-serialport-perl" -#IMAGE_INSTALL += "libexpect-perl" - -# Python support -IMAGE_INSTALL += "python" -# Python modules -IMAGE_INSTALL += "python-async \ -python-argparse \ -python-compression \ -python-dateutil \ -python-html \ -python-psutil \ -python-pycurl \ -python-pyopenssl \ -python-pyserial \ -python-pyudev \ -python-pyusb \ -python-simplejson \ -python-sqlite3 \ -python-syslog \ -python-textutils \ -python-unixadmin \ -python-xml \ -" - -# Ruby support -IMAGE_INSTALL += "ruby" -IMAGE_INSTALL += "ruby-sqlite3" -IMAGE_INSTALL += "ruby-serialport" - -# OpenJDK Java runtime -IMAGE_INSTALL += "openjdk-7-jre" -# OpenJDK with JamVM VM (Multi-Tech default) -IMAGE_INSTALL += "openjdk-7-vm-jamvm" -# OpenJDK with CACAO VM (run with 'java -cacao') -IMAGE_INSTALL += "openjdk-7-vm-cacao" -# OpenJDK Zero VM (run with 'java -zero') -IMAGE_INSTALL += "openjdk-7-vm-zero" - -# PHP support -IMAGE_INSTALL += "php php-cli php-cgi" - -# Node.js support -IMAGE_INSTALL += "nodejs nodejs-npm" - -# Multi-Tech SMS Utility (see http://git.multitech.net) -IMAGE_INSTALL += "sms-utils" -# Multi-Tech GPS Utility -IMAGE_INSTALL += "venus-gps" -IMAGE_INSTALL += "pps-tools" -IMAGE_INSTALL += "gpsd" - -IMAGE_INSTALL += "uvccapture" +# Extra stuff to install +IMAGE_INSTALL += " rs9113 " diff --git a/recipes-navigation/gpsd/gpsd-3.16/0005-suppress-text-in-binary.patch b/recipes-navigation/gpsd/gpsd-3.16/0005-suppress-text-in-binary.patch index 34c9924..f338126 100644 --- a/recipes-navigation/gpsd/gpsd-3.16/0005-suppress-text-in-binary.patch +++ b/recipes-navigation/gpsd/gpsd-3.16/0005-suppress-text-in-binary.patch @@ -1,12 +1,12 @@ diff -u old/gpsctl.c new/gpsctl.c --- old/gpsctl.c 2017-01-03 15:57:50.517120891 -0600 -+++ new/gpsctl.c 2017-01-03 15:58:05.025120861 -0600 ++++ new/gpsctl.c 2017-01-03 18:31:21.421101434 -0600 @@ -175,7 +175,7 @@ int option, status; char *device = NULL, *devtype = NULL; char *speed = NULL, *control = NULL, *rate = NULL; - bool to_binary = false, to_nmea = false, reset = false; -+ bool to_binary = false, to_nmea = false, reset = false, cstring = false; ++ bool to_binary = false, to_nmea = false, reset = false, control_string = false; bool lowlevel=false, echo=false; struct gps_data_t gpsdata; const struct gps_type_t *forcetype = NULL; @@ -14,16 +14,17 @@ diff -u old/gpsctl.c new/gpsctl.c #ifdef CONTROLSEND_ENABLE control = optarg; lowlevel = true; -+ cstring = true; ++ control_string = true; if ((cooklen = hex_escapes(cooked, control)) <= 0) { gpsd_log(&context.errout, LOG_ERROR, "invalid escape string (error %d)\n", (int)cooklen); -@@ -443,7 +444,7 @@ +@@ -704,7 +705,8 @@ + } } - /* if no control operation was specified, just ID the device */ -- if (speed==NULL && rate == NULL && !to_nmea && !to_binary && !reset) { -+ if (speed==NULL && rate == NULL && !to_nmea && !to_binary && !reset && !cstring) { - (void)printf("%s identified as a %s", - gpsdata.dev.path, gpsdata.dev.driver); - if (gpsdata.dev.subtype[0] != '\0') { +- (void)printf("%s identified as a %s at %u baud.\n", ++ if(!control_string) ++ (void)printf("%s identified as a %s at %u baud.\n", + device, gpsd_id(&session), + session.gpsdata.dev.baudrate); + diff --git a/recipes-navigation/gpsd/gpsd-3.16/0006-itu_r_tf_460_6.patch b/recipes-navigation/gpsd/gpsd-3.16/0006-itu_r_tf_460_6.patch new file mode 100644 index 0000000..8e8d814 --- /dev/null +++ b/recipes-navigation/gpsd/gpsd-3.16/0006-itu_r_tf_460_6.patch @@ -0,0 +1,23 @@ +diff -Naur old/ntpshmwrite.c new/ntpshmwrite.c +--- old/ntpshmwrite.c 2017-01-23 10:00:05.497129473 -0600 ++++ new/ntpshmwrite.c 2017-01-23 09:47:58.881627772 -0600 +@@ -32,11 +32,18 @@ + * NTP expects leap pending for only 1 month prior to insertion + * Per http://bugs.ntp.org/1090 */ + (void)gmtime_r( &(td->real.tv_sec), &tm); ++/* This code contradicts page 3 section 2.1 of ITU-R RV.460-6 that ++ * leap second may occur at the last second of a month, with ++ * preference for December and June, 2nd preference to March and ++ * September. ++ * https://www.itu.int/dms_pubrec/itu-r/rec/tf/R-REC-TF.460-6-200202-I!!PDF-E.pdf ++ */ ++#ifdef NOTITU_R_TF_460_6 + if ( 5 != tm.tm_mon && 11 != tm.tm_mon ) { + /* Not june, not December, no way */ + leap_notify = LEAP_NOWARNING; + } +- ++#endif /* NOTITU_R_TF_460_6 */ + /* we use the shmTime mode 1 protocol + * + * ntpd does this: diff --git a/recipes-navigation/gpsd/gpsd-3.16/0006-ubxtimelps.patch b/recipes-navigation/gpsd/gpsd-3.16/0006-ubxtimelps.patch new file mode 100644 index 0000000..e715847 --- /dev/null +++ b/recipes-navigation/gpsd/gpsd-3.16/0006-ubxtimelps.patch @@ -0,0 +1,200 @@ +diff -Naur old/driver_ubx.c new/driver_ubx.c +--- old/driver_ubx.c 2017-01-19 14:12:25.099231346 -0600 ++++ new/driver_ubx.c 2017-01-19 15:13:58.552152991 -0600 +@@ -57,6 +57,29 @@ + #define UBX_CFG_LEN 20 + #define outProtoMask 14 + ++#ifdef UBLOXTIMELS_ENABLE ++/* UBX-NAV-TIMELS support */ ++static char *srcOfCurrLs[] = { ++ "firmware", ++ "GPS GLONASS difference", ++ "GPS", ++ "SBAS", ++ "BeiDou", ++ "Galileo", ++ "Aided data", ++ "Configured" ++}; ++static char *srcOfLsChange[] = { ++ "No Source", ++ "Undefined", ++ "GPS", ++ "SBAS", ++ "BeiDou", ++ "Galileo", ++ "GLONOSS", ++}; ++#endif /* UBLOXTIMELS_ENABLE */ ++ + static gps_mask_t ubx_parse(struct gps_device_t *session, unsigned char *buf, + size_t len); + static gps_mask_t ubx_msg_nav_dop(struct gps_device_t *session, +@@ -237,6 +260,89 @@ + return mask; + } + ++#ifdef UBLOXTIMELS_ENABLE ++/** ++ * Navigation time to leap second ++ * ++ * Sets leap_notify if leap second is < 23 hours away. ++ */ ++static void ++ubx_msg_nav_timels(struct gps_device_t *session, unsigned char *buf, ++ size_t data_len) ++{ ++ int version; ++ unsigned int flags; ++ int valid_curr_ls; ++ int valid_time_to_ls_event; ++ ++ if (data_len != 24) { ++ gpsd_log(&session->context->errout, LOG_WARN, ++ "UBX-NAV-TIMELS: unexpected length %d, expecting 24\n", ++ data_len); ++ return; ++ } ++ version = getsb(buf,4); ++ /* Only version 0 is defined so far. */ ++ flags = (unsigned int)getub(buf, 23); ++ gpsd_log(&session->context->errout, LOG_DATA, ++ "UBX-NAV-TIMELS: flags 0x%x message version %d\n",flags, version); ++ valid_curr_ls = flags & UBX_TIMELS_VALID_CURR_LS; ++ valid_time_to_ls_event = flags & UBX_TIMELS_VALID_TIME_LS_EVT; ++ if(valid_curr_ls) { ++ unsigned int src_of_curr_ls = getub(buf,8); ++ int curr_ls = getsb(buf,9); ++ char *src = "Unknown"; ++ ++ if(src_of_curr_ls < (sizeof srcOfCurrLs/(sizeof srcOfCurrLs[0]))) ++ src = srcOfCurrLs[src_of_curr_ls]; ++ ++ gpsd_log(&session->context->errout, LOG_DATA, ++ "UBX-NAV-TIMELS: source_of_current_leapsecond=%u:%s curr_ls=%d\n", ++ src_of_curr_ls,src,curr_ls); ++ session->context->leap_seconds = curr_ls; ++ session->context->valid |= LEAP_SECOND_VALID; ++ } /* Valid current leap second */ ++ if(valid_time_to_ls_event) { ++ char *src="Unknown"; ++ unsigned int src_of_ls_change; ++ unsigned short dateOfLSGpsWn, dateOfLSGpsDn; ++ int lsChange = getsb(buf,11); ++ int timeToLsEvent = getles32(buf,12); ++ src_of_ls_change = getub(buf,10); ++ if(src_of_ls_change < (sizeof srcOfLsChange/(sizeof srcOfLsChange[0]))) ++ src = srcOfLsChange[src_of_ls_change]; ++ dateOfLSGpsWn = getles16(buf,16); ++ dateOfLSGpsDn = getles16(buf,18); ++ gpsd_log(&session->context->errout, LOG_DATA, ++ "UBX_NAV_TIMELS: source_of_leapsecond_change=%u:%s " ++ "leapSecondChage=%d timeToLsEvent=%d\n", ++ src_of_ls_change,src,lsChange,timeToLsEvent); ++ gpsd_log(&session->context->errout, LOG_DATA, ++ "UBX_NAV_TIMELS: dateOfLSGpsWn=%d dateOfLSGpsDn=%d\n", ++ dateOfLSGpsWn,dateOfLSGpsDn); ++ if(timeToLsEvent < 60*60*23 && timeToLsEvent > 0) { ++ if(lsChange == 0) ++ session->context->leap_notify = LEAP_NOWARNING; ++ else if (lsChange == 1) ++ session->context->leap_notify = LEAP_ADDSECOND; ++ else if (lsChange == -1) ++ session->context->leap_notify = LEAP_DELSECOND; ++ } else ++ session->context->leap_notify = LEAP_NOWARNING; ++ ++ if (session->context->leap_notify == LEAP_ADDSECOND) ++ gpsd_log(&session->context->errout,LOG_INF, ++ "UBX_NAV_TIMELS: Add leap second today\n"); ++ else if (session->context->leap_notify == LEAP_DELSECOND) ++ gpsd_log(&session->context->errout,LOG_INF, ++ "UBX_NAV_TIMELS: Remove leap second today\n"); ++ ++ gpsd_log(&session->context->errout, LOG_DATA, ++ "UBX_NAV_TIMELS: leaving: leap_notify=%d\n", ++ session->context->leap_notify); ++ } ++} ++#endif /* UBLOXTIMELS_ENABLE */ + /** + * Geodetic position solution message + */ +@@ -523,13 +629,22 @@ + case UBX_NAV_EKFSTATUS: + gpsd_log(&session->context->errout, LOG_DATA, "UBX_NAV_EKFSTATUS\n"); + break; +- ++ case UBX_NAV_TIMELS: ++ gpsd_log(&session->context->errout, LOG_DATA, "UBX_NAV_TIMELS\n"); ++#ifdef UBLOXTIMELS_ENABLE ++ ubx_msg_nav_timels(session, &buf[UBX_PREFIX_LEN],data_len); ++#endif // UBLOXTIMELS_ENABLE ++ break; + case UBX_RXM_RAW: + gpsd_log(&session->context->errout, LOG_DATA, "UBX_RXM_RAW\n"); + break; + case UBX_RXM_SFRB: ++ gpsd_log(&session->context->errout, LOG_DATA, "UBX_RXM_SFRB\n"); + mask = ubx_msg_sfrb(session, &buf[UBX_PREFIX_LEN]); + break; ++ case UBX_RXM_SFRBX: ++ gpsd_log(&session->context->errout, LOG_DATA, "UBX_RXM_SFRBX\n"); ++ break; + case UBX_RXM_SVSI: + gpsd_log(&session->context->errout, LOG_PROG, "UBX_RXM_SVSI\n"); + break; +@@ -955,6 +1070,12 @@ + msg[1] = 0x20; /* msg id = UBX_NAV_TIMEGPS */ + msg[2] = 0x01; /* rate */ + (void)ubx_write(session, 0x06u, 0x01, msg, 3); ++#ifdef UBLOXTIMELS_ENABLE ++ msg[0] = 0x01; /* class */ ++ msg[1] = 0x26; /* msg id = UBX_NAV_TIMELS */ ++ msg[2] = 0xff; /* rate */ ++#endif /* UBLOXTIMELS_ENABLE */ ++ (void)ubx_write(session, 0x06u, 0x01, msg, 3); + msg[0] = 0x01; /* class */ + msg[1] = 0x30; /* msg id = NAV-SVINFO */ + msg[2] = 0x0a; /* rate */ +diff -Naur old/driver_ubx.h new/driver_ubx.h +--- old/driver_ubx.h 2017-01-19 14:12:25.099231346 -0600 ++++ new/driver_ubx.h 2017-01-19 14:01:48.177653001 -0600 +@@ -35,6 +35,7 @@ + UBX_NAV_TIMEGPS = UBX_MSGID(UBX_CLASS_NAV, 0x20), + UBX_NAV_TIMEUTC = UBX_MSGID(UBX_CLASS_NAV, 0x21), + UBX_NAV_CLOCK = UBX_MSGID(UBX_CLASS_NAV, 0x22), ++ UBX_NAV_TIMELS = UBX_MSGID(UBX_CLASS_NAV, 0x26), + UBX_NAV_SVINFO = UBX_MSGID(UBX_CLASS_NAV, 0x30), + UBX_NAV_DGPS = UBX_MSGID(UBX_CLASS_NAV, 0x31), + UBX_NAV_SBAS = UBX_MSGID(UBX_CLASS_NAV, 0x32), +@@ -42,6 +43,7 @@ + + UBX_RXM_RAW = UBX_MSGID(UBX_CLASS_RXM, 0x10), + UBX_RXM_SFRB = UBX_MSGID(UBX_CLASS_RXM, 0x11), ++ UBX_RXM_SFRBX = UBX_MSGID(UBX_CLASS_RXM, 0x13), + UBX_RXM_SVSI = UBX_MSGID(UBX_CLASS_RXM, 0x20), + UBX_RXM_ALM = UBX_MSGID(UBX_CLASS_RXM, 0x30), + UBX_RXM_EPH = UBX_MSGID(UBX_CLASS_RXM, 0x31), +@@ -102,6 +104,9 @@ + #define UBX_SOL_VALID_WEEK 0x04 + #define UBX_SOL_VALID_TIME 0x08 + ++#define UBX_TIMELS_VALID_CURR_LS 0x01 ++#define UBX_TIMELS_VALID_TIME_LS_EVT 0x01 ++ + /* from UBX_NAV_SVINFO */ + #define UBX_SAT_USED 0x01 + #define UBX_SAT_DGPS 0x02 +diff -Naur old/SConstruct new/SConstruct +--- old/SConstruct 2017-01-19 14:51:35.638466569 -0600 ++++ new/SConstruct 2017-01-19 15:20:02.488159765 -0600 +@@ -113,6 +113,7 @@ + ("tripmate", True, "DeLorme TripMate support"), + ("tsip", True, "Trimble TSIP support"), + ("ublox", True, "u-blox Protocol support"), ++ ("ubloxtimels", False, "u-blox UBX-NAV-TIMELS support (leap second)"), + ("fury", True, "Jackson Labs Fury and Firefly support"), + ("nmea2000", True, "NMEA2000/CAN support"), + # Non-GPS protocols diff --git a/recipes-navigation/gpsd/gpsd/gpsd b/recipes-navigation/gpsd/gpsd/gpsd index c08be9b..ed86ecf 100755 --- a/recipes-navigation/gpsd/gpsd/gpsd +++ b/recipes-navigation/gpsd/gpsd/gpsd @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash ### BEGIN INIT INFO # Provides: gpsd # Required-Start: $remote_fs $network @@ -29,12 +29,15 @@ DAEMON=/usr/sbin/$NAME PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME -# Exit if the package is not installed -[ -x "$DAEMON" ] || exit 0 - # Read configuration, if present [ -r /etc/default/$NAME ] && . /etc/default/$NAME +# Exit if no gps found +([[ -n $GPS_LINE ]] && [[ -c $GPS_LINE ]]) || exit 0 + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + if [ -z "$GPSD_SOCKET" ] && [ -z "$DEVICES" ]; then GPSD_SOCKET=/var/run/gpsd.sock fi @@ -48,13 +51,20 @@ fi # do_start() { + /usr/sbin/start-stop-daemon -N -20 --start --quiet --pidfile $PIDFILE --exec $DAEMON --test \ + -- $GPSD_OPTIONS -P $PIDFILE $GPS_DEVICES > /dev/null \ + || return 1 # Return # 0 if daemon has been started # 1 if daemon was already running # 2 if daemon could not be started - /usr/sbin/start-stop-daemon -N -20 --start --quiet --pidfile $PIDFILE --exec $DAEMON --test \ - -- $GPSD_OPTIONS -P $PIDFILE $GPS_DEVICES > /dev/null \ - || return 1 + # Set the baud rate. Works better with ntp at a higher baud rate. + gpsctl -t 'u-blox' -s $GPS_BAUD -b -f $GPS_LINE + # The next line is needed due to a bug in gpsctl. + # We will go back to the default baud rate if we don't do this step. + echo Expect a timeout error here. Need this error. + gpsctl -T 2 -f $GPS_LINE + stty -F $GPS_LINE $GPS_BAUD /usr/sbin/start-stop-daemon -N -20 --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ $GPSD_OPTIONS -P $PIDFILE $GPS_DEVICES \ || return 2 @@ -91,11 +101,27 @@ do_reload() { return 0 } +do_status() { + NAME=$1 + PIDFILE=$2 + # -t: test only but not stop + start-stop-daemon -K -t --quiet --pidfile $PIDFILE --name $NAME + # exit with status 0 if process is found + if [ "$?" = "0" ]; then + return 0 + else + return 1 + fi +} + case "$1" in start) - echo "Starting $DESC" "$NAME" - do_start - exit $? + if ! [[ $ENABLED =~ ^[yY][eE][sS]$ ]] ; then + exit 0 + fi + echo "Starting $DESC" "$NAME" + do_start + exit $? ;; stop) echo "Stopping $DESC" "$NAME" @@ -103,7 +129,16 @@ case "$1" in exit $? ;; status) - ;; + echo -n "status $NAME ... " + do_status "$NAME" "$PIDFILE" + if [ "$?" = "0" ]; then + echo "running" + exit 0 + else + echo "stopped" + exit 1 + fi + ;; reload|force-reload) echo "Reloading $DESC" "$NAME" do_reload diff --git a/recipes-navigation/gpsd/gpsd/gpsd-default b/recipes-navigation/gpsd/gpsd/gpsd-default index fe8576a..da697bc 100644 --- a/recipes-navigation/gpsd/gpsd/gpsd-default +++ b/recipes-navigation/gpsd/gpsd/gpsd-default @@ -1,6 +1,24 @@ -# If you must specify a non-NMEA driver, uncomment and modify the next line +ENABLED="yes" GPSD_SOCKET="/var/run/gpsd.sock" GPSD_OPTIONS="-n -D 1" # Conduit 0.1 GPS devices -GPS_DEVICES="/dev/ttyXRUSB2 /dev/pps0" +GPS_LINE=/dev/ttyXRUSB2 + +# Highest speed permitted by uBlox. +GPS_BAUD=115200 +GPS_DEVICES="$GPS_LINE /dev/pps0" + +GPS_FIXFILE=/var/run/gpsfix + +# GPSD/UBlox Lock requiremnt +# Create GPS_FIXFILE when reached. +# UBlox NAV SOL (0x01 0x06) at gpsFix value +# and above +# 00 No Fix +# 01 Dead reckoning only +# 02 2D fix +# 03 3D fix +# 04 GPS + dead reckoning combined +# 05 Time only fix +GPSFIX="03 05" diff --git a/recipes-navigation/gpsd/gpsd/60-gpsd.rules b/recipes-navigation/gpsd/gpsd/gpsd.rules index 61143b8..c314b54 100644 --- a/recipes-navigation/gpsd/gpsd/60-gpsd.rules +++ b/recipes-navigation/gpsd/gpsd/gpsd.rules @@ -44,4 +44,8 @@ ATTR{idVendor}=="1546", ATTR{idProduct}=="01a4", SYMLINK="gps%n", RUN+="/lib/ude ACTION=="remove", RUN+="/lib/udev/gpsd.hotplug.wrapper" +KERNEL=="ttyXRUSB2", SYMLINK+="gps0" +KERNEL=="pps0", OWNER="root", GROUP="tty", MODE="0660", SYMLINK+="gpspps0" +KERNEL=="ttyXRUSB2", RUN+="/bin/setserial -v /dev/%k low_latency + LABEL="gpsd_rules_end" diff --git a/recipes-navigation/gpsd/gpsd/gpsd_ubx_fixed.sh b/recipes-navigation/gpsd/gpsd/gpsd_ubx_fixed.sh new file mode 100755 index 0000000..9fd3f7f --- /dev/null +++ b/recipes-navigation/gpsd/gpsd/gpsd_ubx_fixed.sh @@ -0,0 +1,142 @@ +#!/bin/bash +# Fix file creation for U-Blox GPS. +# If GPS reaches expected +# fix level, file GSP_FIXFILE is created. +# This is to know when to set the system +# and hardware clock, and when +# it is safe to start ntp. +if [[ -r /etc/default/gpsd ]] ; then + . /etc/default/gpsd +else + echo "Must configure GPSD requirements" + exit 1 +fi +UBXNAVSOL='b56201063400' +UBXNAVSOLLEN=60 + +function rm_gps_file +{ + if [[ -n "${GPS_FIXFILE}" ]] && [[ -f ${GPS_FIXFILE} ]] ; then + rm -f "${GPS_FIXFILE}" + fi +} + +# Most exits are errors, so remove the GPS fix file. +trap rm_gps_file EXIT + +if ! [[ -x /usr/bin/gpsmon ]] ; then + logger -p user.err "gpsd_ubx_3dfix.sh: Please install gpsmon" + exit 0 +fi + + +# Terminate gpsmon after 10 seconds if it is our child +( + sleep 10 + ppid=$$ + # echo "looking for shell ${ppid}" + gpsmonpid=$(ps -o pid,ppid,comm -e | egrep "[[:space:]]${ppid}[[:space:]]+gpsmon$" | sed -r 's/^[[:space:]]*([0-9]*)[[:space:]]+.*/\1/') + # echo sleeper TERM found pid $gpsmonpid + if ((${#gpsmonpid})) ; then + logger -p user.info "terminating gpscat(${gpsmonpid}) with SIGTERM" + kill ${gpsmonpid} + else + exit 0 + fi + sleep 2 + gpsmonpid=$(ps -o pid,ppid,comm -e | egrep "[[:space:]]${ppid}[[:space:]]+gpsmon$" | sed -r 's/^[[:space:]]*([0-9]*)[[:space:]]+.*/\1/') + # echo sleeper KILL found pid $gpsmonpid + if ((${#gpsmonpid})) ; then + logger -p user.info "terminating gpscat(${gpsmonpid}) with SIGKILL" + kill -9 ${gpsmonpid} + fi +) & + +fix="" +status="" + +# egrep in busybox has a horrible buffering issue. +# echo My shell pid is $$ +# echo Place data fix, status +stuff="$(gpsmon -a 2>&1 | { + OIFS=${IFS} + IFS=$'\n' + while read ln ; do + if [[ $ln =~ ^[[:space:]]*\(${UBXNAVSOLLEN}\)[[:space:]]*${UBXNAVSOL}....................(..)(.) ]] ; then + IFS=${OIFS} + fix="${BASH_REMATCH[1]}" + if ((${#fix} == 0)) ; then + fix="unknown" + fi + status=$(echo "${BASH_REMATCH[2]}") + if ((${#status} == 0)) ; then + status="unknown" + fi + break; + fi + oldln="${ln}" + done + if ((${#fix})) && ((${#status})) ; then + echo "$fix,$status" + else + echo "${oldln}" + fi +})" + +if ((${#stuff} == 0)) ; then + logger -p user.err No data from GPS + exit 1 +fi + +if [[ -t 1 ]] ; then + stty echo icanon +fi + +OIFS=${IFS} +IFS=, +set $stuff +fix="$1" +status="$2" +IFS=${OIFS} + +# fixOK is the least significant bit of a hex single digit +case $status in + [13579bBdDfF]) + ((fixOK=1)) + ;; + [02468aAcCeE]) + ((fixOK=0)) + ;; + *) + logger -p user.err "Is GPSD running?" + logger -p user.err "FIX OK field should be single hex digit: gpsmon data: $stuff" + exit 1 + break + ;; +esac + +# echo "status is $status. fixOK is $fixOK" + + +if ((fixOK == 0)) ; then + logger -p user.err "Problem with the GPS fix. The fix is an even value, \"$status\", and should be an odd value. fixOK=${fixOK}" + exit 1 + # Retry later. How? +fi + +# echo "fix is $fix. Is it in $GPSFIX?" +# Test the GPS fixOK +for x in $GPSFIX ; do + # echo test $x with $fix + if [[ $x == $fix ]] ; then + logger user.info "GPS has fix $fix found in list GPSFIX: $GPSFIX" + echo $x >"${GPS_FIXFILE}" + GPS_FIXFILE="" + exit 0 + fi +done + +logger -p user.info "GPS fix is bad: $fix and should be one of: $GPSFIX" +# Start later +exit 1 + diff --git a/recipes-navigation/gpsd/gpsd/gpsd_ubx_settime.sh b/recipes-navigation/gpsd/gpsd/gpsd_ubx_settime.sh new file mode 100755 index 0000000..5644d57 --- /dev/null +++ b/recipes-navigation/gpsd/gpsd/gpsd_ubx_settime.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# PPS= 1484247472.29561104 clock= 1484247990.00000000 offset= 517.704388959 + +trap "stty echo icanon" exit + +OIFS=$IFS +IFS=$'\n' +if ! /usr/sbin/gpsd_ubx_fixed ; then + logger -s -p user.warn "GPS does not have a fix yet. Try again later." + exit 1 +fi +# This shell script is shaped by two things: +# Lousy performance of sed and grep when used with gpsmon +# Need to terminate +# Terminate gpsmon after 10 seconds if it is our child +( + sleep 10 + ppid=$$ + gpsmonpid=$(ps -o pid,ppid,comm -e | egrep "[[:space:]]${ppid}[[:space:]]+gpsmon$" | sed -r 's/^[[:space:]]*([0-9]*)[[:space:]]+.*/\1/') + if ((${#gpsmonpid})) ; then + logger -p user.info "terminating gpscat(${gpsmonpid}) with SIGTERM" + kill ${gpsmonpid} + else + exit 0 + fi + sleep 2 + gpsmonpid=$(ps -o pid,ppid,comm -e | egrep "[[:space:]]${ppid}[[:space:]]+gpsmon$" | sed -r 's/^[[:space:]]*([0-9]*)[[:space:]]+.*/\1/') + if ((${#gpsmonpid})) ; then + logger -p user.info "terminating gpscat(${gpsmonpid}) with SIGKILL" + kill -9 ${gpsmonpid} + fi +) & + + +epoch=$(gpsmon -a 2>&1 | ( while read ln ; do + if [[ $ln =~ ^[[:space:]]*PPS=.*clock=[[:space:]]*([0-9]*)\. ]] ; then + echo ${BASH_REMATCH[1]} + break + fi +done )) +if [[ $epoch =~ ^[0-9]+$ ]] ; then + date +%s -s @${epoch} >/dev/null +else + logger user.err "gpsmon output is bad." + exit 1 +fi +exit 0 diff --git a/recipes-navigation/gpsd/gpsd_3.16.bb b/recipes-navigation/gpsd/gpsd_3.16.bb index 100edcc..d6c51f4 100644 --- a/recipes-navigation/gpsd/gpsd_3.16.bb +++ b/recipes-navigation/gpsd/gpsd_3.16.bb @@ -4,6 +4,7 @@ LICENSE = "BSD" LIC_FILES_CHKSUM = "file://COPYING;md5=d217a23f408e91c94359447735bc1800" DEPENDS = "dbus dbus-glib ncurses python libusb1 chrpath-replacement-native pps-tools" PROVIDES = "virtual/gpsd" +PR="m2" EXTRANATIVEPATH += "chrpath-native" @@ -13,9 +14,13 @@ SRC_URI = "${SAVANNAH_GNU_MIRROR}/${BPN}/${BP}.tar.gz \ file://0004-SConstruct-disable-html-and-man-docs-building-becaus.patch \ file://0001-include-sys-ttydefaults.h.patch \ file://0005-suppress-text-in-binary.patch \ + file://0006-ubxtimelps.patch \ + file://0006-itu_r_tf_460_6.patch \ file://gpsd-default \ file://gpsd \ - file://60-gpsd.rules \ + file://gpsd_ubx_fixed.sh \ + file://gpsd_ubx_settime.sh \ + file://gpsd.rules \ file://gpsd.service \ " # Fixed @@ -32,7 +37,7 @@ SRC_URI[sha256sum] = "03579af13a4d3fe0c5b79fa44b5f75c9f3cac6749357f1d99ce5d38c09 inherit scons update-rc.d python-dir pythonnative systemd INITSCRIPT_NAME = "gpsd" -INITSCRIPT_PARAMS = "defaults 35" +INITSCRIPT_PARAMS = "defaults 10" SYSTEMD_OESCONS = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false',d)}" @@ -55,6 +60,7 @@ EXTRA_OESCONS = " \ systemd='${SYSTEMD_OESCONS}' \ libdir='${libdir}' \ ublox='yes' \ + ubloxtimels='yes' \ pps='yes' \ gpsd_group='gps' \ ntpshm='yes' \ @@ -87,10 +93,13 @@ do_install_append() { install -m 0755 ${WORKDIR}/gpsd ${D}/${sysconfdir}/init.d/ install -d ${D}/${sysconfdir}/default install -m 0644 ${WORKDIR}/gpsd-default ${D}/${sysconfdir}/default/gpsd.default + install -d ${D}${sbindir} + install -m 0755 ${WORKDIR}/gpsd_ubx_fixed.sh ${D}${sbindir}/gpsd_ubx_fixed + install -m 0755 ${WORKDIR}/gpsd_ubx_settime.sh ${D}${sbindir}/gpsd_ubx_settime #support for udev install -d ${D}/${sysconfdir}/udev/rules.d - install -m 0644 ${WORKDIR}/60-gpsd.rules ${D}/${sysconfdir}/udev/rules.d + install -m 0644 ${WORKDIR}/gpsd.rules ${D}/${sysconfdir}/udev/rules.d install -d ${D}${base_libdir}/udev/ install -m 0755 ${S}/gpsd.hotplug ${D}${base_libdir}/udev/ @@ -133,7 +142,7 @@ SUMMARY_libgps = "C service library used for communicating with gpsd" FILES_libgps = "${libdir}/libgps.so.*" SUMMARY_gpsd-conf = "gpsd configuration files and init scripts" -FILES_gpsd-conf = "${sysconfdir}" +FILES_gpsd-conf = "${sysconfdir} ${sbindir}/gpsd_ubx_fixed ${sbindir}/gpsd_ubx_settime" CONFFILES_gpsd-conf = "${sysconfdir}/default/gpsd.default" SUMMARY_gpsd-gpsctl = "Tool for tweaking GPS modes" diff --git a/recipes-support/ntp/files/ntp.conf.patch b/recipes-support/ntp/files/ntp.conf.patch index 499dac5..2fd26ef 100644 --- a/recipes-support/ntp/files/ntp.conf.patch +++ b/recipes-support/ntp/files/ntp.conf.patch @@ -1,7 +1,7 @@ -diff -u old/ntp.conf new/ntp.conf ---- old/ntp.conf 2016-12-21 08:36:33.887646960 -0600 -+++ new/ntp.conf 2016-12-21 08:37:41.115645756 -0600 -@@ -1,7 +1,20 @@ +diff -Naur old/ntp.conf new/ntp.conf +--- old/ntp.conf 2017-01-17 12:00:15.560426583 -0600 ++++ new/ntp.conf 2017-01-17 12:02:11.968426337 -0600 +@@ -1,16 +1,44 @@ -# This is the most basic ntp configuration file # The driftfile must remain in a place specific to this # machine - it records the machine specific clock error @@ -23,22 +23,21 @@ diff -u old/ntp.conf new/ntp.conf + # This should be a server that is close (in IP terms) # to the machine. Add other servers as required. - # Unless you un-comment the line below ntpd will sync -@@ -9,8 +22,26 @@ +-# Unless you un-comment the line below ntpd will sync +-# only against the local system clock. # # server time.server.example.com # + -+logfile /var/log/ntp.log -+ +restrict default kod nomodify notrap nopeer noquery +restrict -6 default kod nomodify notrap nopeer noquery +restrict 127.0.0.1 mask 255.255.255.0 +restrict -6 ::1 + +# GPS Serial data reference (NTP0) ++# This sets the GPS 50 milliseconds slower than the PPS. +server 127.127.28.0 -+fudge 127.127.28.0 time1 0.080 refid GPS ++fudge 127.127.28.0 time1 0.050 refid GPS + +# GPS PPS reference (NTP2) +server 127.127.28.2 prefer diff --git a/recipes-support/ntp/files/ntpd-default b/recipes-support/ntp/files/ntpd-default new file mode 100644 index 0000000..65e2119 --- /dev/null +++ b/recipes-support/ntp/files/ntpd-default @@ -0,0 +1,33 @@ +ENABLED="yes" + +# The GPSD_* parameters in this file are ignored +# if the uBlox GPS is not present. + +# Require a GPS lock/fix before starting NTP +# This is needed if we are not using NTP servers. +# NTP will not work with the GPS if the GPS is not +# locked before starting. +# See /etc/default/gpsd for the states required. +GPSD_REQUIRED=1 + +# Number of seconds between testing for a GPS +# lock prior to calling ntpd. +GPSD_WAIT_TIME=120 + +# Since the HW Clock could be off by a second or +# so, our GPS might get marked as a false ticker +# if we do not set the system clock to the GPS +# first. The current correct way to do this +# according to the ntp doc is ntpd -gq -c conffile +# which must be done before ntpd is started. +# conffile should exclude the local clock, so it is +# ignored while doing the initial sync. +# ntpd -gq apparently does not work with the GPS +# when tested with the clock more than one day off +# and no ntpd. The gps shared memory is never polled. +# +# If there is a uBlox GPS present, the time is +# read from the GPS to initialize the system time +# before NTP is started. +SET_SYSTEM_CLOCK=1 + diff --git a/recipes-support/ntp/files/ntpd-init.patch b/recipes-support/ntp/files/ntpd-init.patch index fc388f8..41c7549 100644 --- a/recipes-support/ntp/files/ntpd-init.patch +++ b/recipes-support/ntp/files/ntpd-init.patch @@ -1,11 +1,87 @@ ---- old/ntpd 2016-12-19 18:11:58.022663976 -0600 -+++ new/ntpd 2016-12-19 18:12:56.618663852 -0600 -@@ -23,7 +23,7 @@ - # this. If ntpd seems to disappear after a while assume TICKADJ - # above is set to a totally incorrect value. - echo -n "Starting ntpd: " +diff -Naur old/ntpd new/ntpd +--- old/ntpd 2017-01-17 16:26:47.427368196 -0600 ++++ new/ntpd 2017-01-20 16:26:52.154738981 -0600 +@@ -1,6 +1,8 @@ +-#! /bin/sh ++#! /bin/bash + # ++. /etc/default/ntpd + PATH=/sbin:/bin:/usr/bin:/usr/sbin ++GNSSRST=/sys/devices/platform/mts-io/gnss-reset + + # ntpd init.d script for ntpdc from ntp.isc.org + test -x /usr/sbin/ntpd -a -r /etc/ntp.conf || exit 0 +@@ -18,13 +20,32 @@ + } + } + startdaemon(){ +- # The -g option allows ntpd to step the time to correct it just +- # once. The daemon will exit if the clock drifts too much after +- # this. If ntpd seems to disappear after a while assume TICKADJ +- # above is set to a totally incorrect value. +- echo -n "Starting ntpd: " - start-stop-daemon --start -x /usr/sbin/ntpd -- -u ntp:ntp -p /var/run/ntp.pid "$@" -+ start-stop-daemon -N -20 --start -x /usr/sbin/ntpd -- -u ntp:ntp -p /var/run/ntp.pid "$@" - echo "done" +- echo "done" ++ /usr/sbin/start-stop-daemon -N -20 --start -x /usr/sbin/ntpd --test -- -u ntp:ntp -p /var/run/ntp.pid "$@" \ ++ || return 1 ++ if ((GPSD_REQUIRED == 1)) && [[ -L /dev/gps0 ]] && [[ -f "${GNSSRST}" ]]; then ++ . /etc/default/gpsd ++ # Could not get ntpd -gq to work with the GPS. ++ # So read the GPS time directly and set the system ++ # clock. ++ if ((SET_SYSTEM_CLOCK == 1)) && /usr/sbin/gpsd_ubx_settime ; then ++ # System time set by the GPS. ++ /usr/sbin/start-stop-daemon -N -20 --start -x /usr/sbin/ntpd -- -u ntp:ntp -p /var/run/ntp.pid "$@" ++ else ++ # Need a GPS fix before startint ntp. ++ /usr/sbin/start-stop-daemon -b -n z1e9d3qb -N -20 --start -x /bin/bash -- -c "sleep $GPSD_WAIT_TIME;/etc/init.d/ntpd start" ++ fi ++ else ++ if ((SET_SYSTEM_CLOCK == 1)) ; then ++ ntpd -gq ++ shift ++ fi ++ ++ # The -g option allows ntpd to step the time to correct it just ++ # once. The daemon will exit if the clock drifts too much after ++ # this. If ntpd seems to disappear after a while assume TICKADJ ++ # above is set to a totally incorrect value. ++ /usr/sbin/start-stop-daemon -N -20 --start -x /usr/sbin/ntpd -- -u ntp:ntp -p /var/run/ntp.pid "$@" ++ fi } stopdaemon(){ + echo -n "Stopping ntpd: " +@@ -34,24 +55,27 @@ + + case "$1" in + start) +- settick ++ if ! [[ $ENABLED =~ ^[yY][eE][sS]$ ]] ; then ++ exit 0 ++ fi ++ settick + startdaemon -g + ;; + stop) +- stopdaemon ++ stopdaemon + ;; + force-reload) +- stopdaemon +- settick ++ stopdaemon ++ settick + startdaemon -g + ;; + restart) +- # Don't reset the tick here ++ # Don't reset the tick here + stopdaemon + startdaemon -g + ;; + reload) +- # Must do this by hand, but don't do -g ++ # Must do this by hand, but don't do -g + stopdaemon + startdaemon + ;; diff --git a/recipes-support/ntp/ntp_4.2.6p5.bbappend b/recipes-support/ntp/ntp_4.2.6p5.bbappend index 7928608..b656256 100644 --- a/recipes-support/ntp/ntp_4.2.6p5.bbappend +++ b/recipes-support/ntp/ntp_4.2.6p5.bbappend @@ -2,6 +2,7 @@ PR .= ".mlinux1" SRC_URI += " file://ntpd-init.patch;patchdir=.. \ file://ntp.conf.patch;patchdir=.. \ + file://ntpd-default \ " FILESEXTRAPATHS_prepend := "${THISDIR}/files" @@ -26,3 +27,20 @@ pkg_postinst_${PN} () { chown -R ntp:ntp ${drdir} } + +do_install_prepend() { + echo JAK In do_install_append in directory $(pwd), and D is ${D} + echo JAK In do_install_append sysconfdir is ${sysconfdir} + install -d ${D}${sysconfdir}/default + install -m 0644 ${WORKDIR}/ntpd-default ${D}${sysconfdir}/default/ntpd.default + echo JAK In do_install_append default is $(ls ${D}cd${sysconfdir}/default/ntpd.default) +} +pkg_postinst_${PN}() { + update-alternatives --install ${sysconfdir}/default/ntpd ntpd-defaults ${sysconfdir}/default/ntpd.default 10 +} + +pkg_postrm_${PN}() { + update-alternatives --remove ntpd-defaults ${sysconfdir}/default/ntpd.default +} +FILES_${PN} += "${sysconfdir}/default/ntpd.default" +CONFFILES_${PN} += "${sysconfdir}/default/ntpd.default" |