A lot of the armv7/arm64 boards do not have a battery powered RTC.
Some of these boards actually do have an RTC, but if the board loses
power, the RTC resets itself. If you then power up the board again,
it will trust the time in the RTC and you find yourself back in 1970.
The diff below adds a sanity check to the sxirtc(4) driver. If the
year read back from the chip is the first year that can be represented
by the RTC, it considers the time to be invalid. It will then take
the time from the filesystem and print:
WARNING: preposterous clock chip time
WARNING: CHECK AND RESET THE DATE!
The downside of this is that it becomes impossible to set the time
back that far. But the upside is that if you haven't left a machine
powered off for a very long time, the ntpd constraint will actually
work.
ok?
Index: dev/fdt/sxirtc.c
===================================================================
RCS file: /cvs/src/sys/dev/fdt/sxirtc.c,v
retrieving revision 1.1
diff -u -p -r1.1 sxirtc.c
--- dev/fdt/sxirtc.c 21 Jan 2017 08:26:49 -0000 1.1
+++ dev/fdt/sxirtc.c 26 Mar 2017 21:12:23 -0000
@@ -149,7 +149,8 @@ sxirtc_gettime(todr_chip_handle_t handle
if (dt.dt_sec > 59 || dt.dt_min > 59 ||
dt.dt_hour > 23 || dt.dt_wday > 6 ||
dt.dt_day > 31 || dt.dt_day == 0 ||
- dt.dt_mon > 12 || dt.dt_mon == 0)
+ dt.dt_mon > 12 || dt.dt_mon == 0 ||
+ dt.dt_year <= sc->base_year)
return 1;
tv->tv_sec = clock_ymdhms_to_secs(&dt);