El día martes, enero 02, 2018 a las 02:00:20p. m. +0100, Matthias Apitz escribió: > # cp /usr/obj/usr/src/sys/GENERIC/kernel /boot/kernel/kernel > > The kernel boots fine as: > > FreeBSD c720-r314251 12.0-CURRENT FreeBSD 12.0-CURRENT #2 r314251M: Tue Jan 2 12:53:31 CET 2018 guru_at_c720-r314251:/usr/obj/usr/src/sys/GENERIC amd64 > > but: while the current date is read with the correct time, the year is 1970: > > # date > Tue Jan 2 1970, 13:45:24 CET > > One can set the date/time with the date(1) command or ntpdate. > > The debug messages are (the first line is from boot, the others from the > date or ntpdate): > > # grep DEBUG /var/log/messages > Jan 2 13:43:02 c720-r314251 kernel: BCD DEBUG: atrtc_gettime() entry > Jan 2 13:43:02 c720-r314251 kernel: BCD DEBUG: atrtc_gettime() entry > Jan 2 13:44:00 c720-r314251 kernel: BCD DEBUG: atrtc_set() entry I've added one more printf to see what is coming as year from BCD. The code is attached below and bcd.year comes out as 24 (decimal) which is 0x18. I.e. it seems that the year from 2018 is stored in hex as 0x18, or? Jan 2 15:08:02 c720-r314251 kernel: BCD DEBUG: atrtc_gettime() entry without USE_RTC_CENTURY Jan 2 15:08:02 c720-r314251 kernel: BCD DEBUG: atrtc_gettime() bct.year=24 Jan 2 15:13:00 c720-r314251 kernel: BCD DEBUG: atrtc_set() entry without USE_RTC_CENTURY Jan 2 15:14:34 c720-r314251 kernel: BCD DEBUG: atrtc_set() entry without USE_RTC_CENTURY static int atrtc_gettime(device_t dev, struct timespec *ts) { struct bcd_clocktime bct; #ifdef USE_RTC_CENTURY printf("BCD DEBUG: atrtc_gettime() entry with USE_RTC_CENTURY\n"); #else printf("BCD DEBUG: atrtc_gettime() entry without USE_RTC_CENTURY\n"); #endif /* Look if we have a RTC present and the time is valid */ if (!(rtcin(RTC_STATUSD) & RTCSD_PWR)) { device_printf(dev, "WARNING: Battery failure indication\n"); return (EINVAL); } /* * wait for time update to complete * If RTCSA_TUP is zero, we have at least 244us before next update. * This is fast enough on most hardware, but a refinement would be * to make sure that no more than 240us pass after we start reading, * and try again if so. */ while (rtcin(RTC_STATUSA) & RTCSA_TUP) continue; critical_enter(); bct.sec = rtcin(RTC_SEC); bct.min = rtcin(RTC_MIN); bct.hour = rtcin(RTC_HRS); bct.day = rtcin(RTC_DAY); bct.mon = rtcin(RTC_MONTH); bct.year = rtcin(RTC_YEAR); #ifdef USE_RTC_CENTURY bct.year |= rtcin(RTC_CENTURY) << 8; #endif critical_exit(); /* dow is unused in timespec conversion and we have no nsec info. */ bct.dow = 0; bct.nsec = 0; printf("BCD DEBUG: atrtc_gettime() bct.year=%d\n", bct.year); return (clock_bcd_to_ts(&bct, ts)); } -- Matthias Apitz, ✉ guru_at_unixarea.de, ⌂ http://www.unixarea.de/ 📱 +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:14 UTC