Skip to content
Snippets Groups Projects
Commit 2e3c677f authored by Adam Wujek's avatar Adam Wujek
Browse files

[FEATURE: #335] Kconfig: add external source of TOD updates (and NMEA)


Signed-off-by: default avatarAdam Wujek <dev_public@wujek.eu>
Signed-off-by: default avatarHarvey Leicester <harvey.macdonald.leicester@cern.ch>
parent 6ce24eb2
Branches
No related merge requests found
......@@ -127,6 +127,77 @@ config PPSI
bool
default y
menu "External source of Time of Day at boot"
choice
prompt "External source of local Time of Day at boot"
default TOD_SOURCE_NTP
help
Select the external time source of Time of Day at boot.
If device gets time from other PTP/WR device the time will be
overwritten.
config TOD_SOURCE_NONE
bool "None"
help
Don't use external source of local time at startup.
It will use date stored at the last reboot or it will stay
at the beginning of the epoch (1970).
config TOD_SOURCE_NTP
bool "Use NTP"
help
Use NTP as external source of local time at startup.
config TOD_SOURCE_NMEA
bool "Enable NMEA Interface to set time in GM"
help
Use NMEA (interface via RS-232) as external source of local
time at startup.
endchoice
config NTP_SERVER
string "IP address of NTP server"
depends on TOD_SOURCE_NTP
help
At boot time, the White Rabbit time can be primed by querying
an NTP server, if CONFIG_TOD_SOURCE_NTP is set.
Please write here the IPV4 address (e.g.: "192.168.16.1");
an empty string disables NTP-based priming.
choice
prompt "NMEA Baud Rate"
depends on TOD_SOURCE_NMEA
default NMEA_B9600
help
Set baud rate of NMEA interface
config NMEA_B9600
bool "9600"
config NMEA_B19200
bool "19200"
config NMEA_B38400
bool "38400"
config NMEA_B57600
bool "57600"
config NMEA_B115200
bool "115200"
endchoice
choice
prompt "NMEA Format"
depends on TOD_SOURCE_NMEA
default NMEA_GPZDA
help
Set the NMEA sentence to parse
config NMEA_GPZDA
bool "GPZDA"
config NMEA_GPRMC
bool "GPRMC"
endchoice
endmenu # "External Time of Day source at boot"
menu "Local Network Configuration"
choice
......@@ -335,13 +406,6 @@ endmenu
endmenu # "Authorization and authentication"
config NTP_SERVER
string "IP address of local NTP server (empty for none)"
help
At boot time, the White Rabbit time is primed by querying
an NTP server, if any is there. Please write here the
IPV4 address (e.g.: "192.168.16.1"); an empty string
disables NTP-based priming.
config DNS_SERVER
string "static IP address of local DNS server (empty for none)"
......@@ -643,6 +707,9 @@ config TIME_CUSTOM
endchoice
config PTP_OPT_PTP_VERSION_OVERWRITE
boolean "Allow the overwrite of the default PTP version per instance"
default n
......@@ -983,7 +1050,7 @@ config SNMP_SWCORESTATUS_DISABLE
menu "System clock monitor"
config SNMP_SYSTEM_CLOCK_MONITOR_ENABLED
depends on NTP_SERVER != ""
depends on TOD_SOURCE_NTP || TOD_SOURCE_NMEA
bool "Enable system clock monitor"
default y
help
......
......@@ -14,6 +14,14 @@ CONFIG_LEAPSEC_SOURCE_LOCAL=y
CONFIG_BR2_CONFIGFILE="wrs_release_br2_config"
CONFIG_PPSI=y
#
# External source of Time of Day at boot
#
# CONFIG_TOD_SOURCE_NONE is not set
CONFIG_TOD_SOURCE_NTP=y
# CONFIG_TOD_SOURCE_NMEA is not set
CONFIG_NTP_SERVER=""
#
# Local Network Configuration
#
......@@ -43,7 +51,6 @@ CONFIG_HOSTNAME_DHCP=y
#
# CONFIG_ROOT_PWD_IS_ENCRYPTED is not set
CONFIG_ROOT_PWD_CLEAR=""
CONFIG_NTP_SERVER=""
CONFIG_DNS_SERVER=""
CONFIG_DNS_DOMAIN=""
CONFIG_LOCAL_SYSLOG_FILE="/tmp/syslog"
......@@ -883,6 +890,12 @@ CONFIG_SNMP_TEMP_THOLD_PSR=80
#
# System clock monitor
#
CONFIG_SNMP_SYSTEM_CLOCK_MONITOR_ENABLED=y
CONFIG_SNMP_SYSTEM_CLOCK_DRIFT_THOLD=3
CONFIG_SNMP_SYSTEM_CLOCK_UNIT_MINUTES=y
# CONFIG_SNMP_SYSTEM_CLOCK_UNIT_HOURS is not set
# CONFIG_SNMP_SYSTEM_CLOCK_UNIT_DAYS is not set
CONFIG_SNMP_SYSTEM_CLOCK_CHECK_INTERVAL_MINUTES=10
#
# External clk2 clock signal configuration
......
......@@ -69,13 +69,11 @@ ntp_to_hwclk()
S=$1
ntp_ntries=1
# Get timing mode: Get it from dot-config ad wr_date is started before PPSi
TM=`grep -e '^CONFIG_TIME_' /wr/etc/dot-config | sed 's/^CONFIG_TIME_\(.*\)[=].*/\1/'`
if [ "$TM" == "GM" ] ; then
# Get timing mode: Get it from dot-config as wr_date is started before PPSi
if [ "$CONFIG_TIME_GM" = "y" ] || [ "$CONFIG_TIME_ARB_GM" = "y" ]; then
ntp_ntries=10
fi
#Request NTP server and set time to FPGA is okay
if ntp_retries $S ${ntp_ntries}; then
eval /wr/bin/wr_date -v set host $LOGPIPE
......@@ -83,14 +81,55 @@ ntp_to_hwclk()
fi
}
nmea_to_hwclk()
{
# Get NMEA settings from .config
if [ "$CONFIG_NMEA_B9600" = "y" ]; then NMEA_BAUD=9600; fi
if [ "$CONFIG_NMEA_B19200" = "y" ]; then NMEA_BAUD=19200; fi
if [ "$CONFIG_NMEA_B38400" = "y" ]; then NMEA_BAUD=38400; fi
if [ "$CONFIG_NMEA_B57600" = "y" ]; then NMEA_BAUD=57600; fi
if [ "$CONFIG_NMEA_B115200" = "y" ]; then NMEA_BAUD=115200; fi
if [ "$CONFIG_NMEA_GPZDA" = "y" ]; then NMEA_FMT=GPZDA; fi
if [ "$CONFIG_NMEA_GPRMC" = "y" ]; then NMEA_FMT=GPRMC; fi
# Use default baud if not found
if [ ! -n "$NMEA_BAUD" ]; then
NMEA_BAUD=9600
eval echo "NMEA baud not found, using default: $NMEA_BAUD" $LOGPIPE
fi
# Use default format if not found
if [ ! -n "$NMEA_FMT" ]; then
NMEA_FMT=GPZDA
eval echo "NMEA format not found, using default: $NMEA_FMT" $LOGPIPE
fi
#set host and time from nmea interface
eval echo "Using NMEA with baud=$NMEA_BAUD format=$NMEA_FMT" $LOGPIPE
eval /wr/bin/wr_date -v -g $NMEA_BAUD $NMEA_FMT get tohost $LOGPIPE
if [ $? -ne 0 ]; then
eval echo "Getting time from NMEA failed" $LOGPIPE
return
fi
eval /wr/bin/wr_date -v set host $LOGPIPE
date_set=1
}
date_set=0
# Check whether there is the config file
if [ -f $F ]; then
# pick the first server, if any
S=$(grep 'ntpserver' $F | sed 's/ntpserver//' | head -n 1)
# check whether server found
if [ -n "$S" ]; then
ntp_to_hwclk "$S"
if [ "$CONFIG_TOD_SOURCE_NMEA" = "y" ]; then
nmea_to_hwclk
elif [ "$CONFIG_TOD_SOURCE_NTP" = "y" ]; then
# Check whether there is the config file
if [ -f $F ]; then
# pick the first server, if any
S=$(grep 'ntpserver' $F | sed 's/ntpserver//' | head -n 1)
# check whether server found
if [ -n "$S" ]; then
ntp_to_hwclk "$S"
fi
fi
fi
......@@ -98,8 +137,9 @@ fi
# saved before the last reboot
if [ "$1" != "ppsi" ] && [ $date_set = 0 ] && [ -f /update/saved_date ]; then
#date is not accurate but no better idea.
eval echo "Restore saved time" $LOGPIPE
date -s `cat /update/saved_date`
curr_date=`cat /update/saved_date`
eval echo "Restore saved time $curr_date" $LOGPIPE
date -s $curr_date
eval echo "Setting WR time from host time" $LOGPIPE
eval /wr/bin/wr_date set host $LOGPIPE
fi
......@@ -62,8 +62,22 @@ else
fi
sed -i "s,^root:[^:]*:,root:$passwd:," /etc/shadow
# For backward compability with pre-v8.0 dot-configs, if NTP server is set,
# sume should be CONFIG_TOD_SOURCE_NTP=y
if [ ! -n "$CONFIG_TOD_SOURCE_NONE" ] \
&& [ ! -n "$CONFIG_TOD_SOURCE_NTP" ] \
&& [ ! -n "$CONFIG_TOD_SOURCE_NMEA" ]; then
if [ ! -z "$CONFIG_NTP_SERVER" ]; then
echo "NTP server set (CONFIG_NTP_SERVER=\"$CONFIG_NTP_SERVER\"), " \
"but no CONFIG_TOD_SOURCE_*=y in dot-config! " \
"Assume to use NTP as TOD source." | tee $log_output >& 2
CONFIG_TOD_SOURCE_NTP=y
fi
fi
# A non-existent wr_date.conf means no NTP. So "rm" if unconfigured
if [ ! -z "$CONFIG_NTP_SERVER" ]; then
if [ "$CONFIG_TOD_SOURCE_NTP" = "y" ] && [ ! -z "$CONFIG_NTP_SERVER" ]; then
echo "ntpserver $CONFIG_NTP_SERVER" > $T
mv $T /etc/wr_date.conf
fi
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment