From owner-freebsd-current@freebsd.org Tue Jan 2 14:37:46 2018 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5178EEA8A18 for ; Tue, 2 Jan 2018 14:37:46 +0000 (UTC) (envelope-from guru@unixarea.de) Received: from ms-10.1blu.de (ms-10.1blu.de [178.254.4.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0E4B51DCC; Tue, 2 Jan 2018 14:37:45 +0000 (UTC) (envelope-from guru@unixarea.de) Received: from [89.204.130.252] (helo=localhost.unixarea.de) by ms-10.1blu.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.86_2) (envelope-from ) id 1eWNhG-0002eL-GI; Tue, 02 Jan 2018 15:37:42 +0100 Received: from localhost.my.domain (localhost [127.0.0.1]) by localhost.unixarea.de (8.15.2/8.14.9) with ESMTPS id w02EbcrN002370 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 2 Jan 2018 15:37:38 +0100 (CET) (envelope-from guru@unixarea.de) Received: (from guru@localhost) by localhost.my.domain (8.15.2/8.14.9/Submit) id w02EbcRU002369; Tue, 2 Jan 2018 15:37:38 +0100 (CET) (envelope-from guru@unixarea.de) X-Authentication-Warning: localhost.my.domain: guru set sender to guru@unixarea.de using -f Date: Tue, 2 Jan 2018 15:37:37 +0100 From: Matthias Apitz To: Ian Lepore , freebsd-current@freebsd.org, cem@freebsd.org Subject: Re: panic: invalid bcd 194 Message-ID: <20180102143737.GA2286@c720-r314251> Reply-To: Matthias Apitz Mail-Followup-To: Matthias Apitz , Ian Lepore , freebsd-current@freebsd.org, cem@freebsd.org References: <20171230210711.GA75976@c720-r314251> <20171230211154.GT1684@kib.kiev.ua> <20171230214819.GA2191@c720-r314251> <20171231083624.GA2175@c720-r314251> <1514740790.12000.20.camel@freebsd.org> <20180101085425.GA2301@c720-r314251> <1514851362.1759.8.camel@freebsd.org> <20180102130020.GA2236@c720-r314251> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="2oS5YaxWCcQjTEyO" Content-Disposition: inline In-Reply-To: <20180102130020.GA2236@c720-r314251> X-Operating-System: FreeBSD 12.0-CURRENT r314251 (amd64) X-message-flag: Mails containing HTML will not be read! Please send only plain text. User-Agent: Mutt/1.8.0 (2017-02-23) X-Con-Id: 51246 X-Con-U: 0-guru X-Originating-IP: 89.204.130.252 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jan 2018 14:37:46 -0000 --2oS5YaxWCcQjTEyO Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable El d=C3=ADa martes, enero 02, 2018 a las 02:00:20p. m. +0100, Matthias Apit= z escribi=C3=B3: > # cp /usr/obj/usr/src/sys/GENERIC/kernel /boot/kernel/kernel >=20 > The kernel boots fine as: >=20 > FreeBSD c720-r314251 12.0-CURRENT FreeBSD 12.0-CURRENT #2 r314251M: Tue J= an 2 12:53:31 CET 2018 guru@c720-r314251:/usr/obj/usr/src/sys/GENERIC = amd64 >=20 > but: while the current date is read with the correct time, the year is 19= 70: >=20 > # date > Tue Jan 2 1970, 13:45:24 CET >=20 > One can set the date/time with the date(1) command or ntpdate. >=20 > The debug messages are (the first line is from boot, the others from the > date or ntpdate): >=20 > # 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= =2E 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 witho= ut USE_RTC_CENTURY Jan 2 15:08:02 c720-r314251 kernel: BCD DEBUG: atrtc_gettime() bct.year=3D= 24 Jan 2 15:13:00 c720-r314251 kernel: BCD DEBUG: atrtc_set() entry without U= SE_RTC_CENTURY Jan 2 15:14:34 c720-r314251 kernel: BCD DEBUG: atrtc_set() entry without U= SE_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 =3D rtcin(RTC_SEC); bct.min =3D rtcin(RTC_MIN); bct.hour =3D rtcin(RTC_HRS); bct.day =3D rtcin(RTC_DAY); bct.mon =3D rtcin(RTC_MONTH); bct.year =3D rtcin(RTC_YEAR); #ifdef USE_RTC_CENTURY bct.year |=3D rtcin(RTC_CENTURY) << 8; #endif critical_exit(); /* dow is unused in timespec conversion and we have no nsec info. */ bct.dow =3D 0; bct.nsec =3D 0; printf("BCD DEBUG: atrtc_gettime() bct.year=3D%d\n", bct.year); return (clock_bcd_to_ts(&bct, ts)); } --=20 Matthias Apitz, =E2=9C=89 guru@unixarea.de, =E2=8C=82 http://www.unixarea.d= e/ =F0=9F=93=B1 +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub --2oS5YaxWCcQjTEyO Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEXmn7rBYYViyzy/vBR8z35Hb+nREFAlpLmS8ACgkQR8z35Hb+ nRHuMhAAl0DON2T2bsrKNS1uoGweMKFhvZFinw1azVgfOM/1CEcWZRLMAxctuO2A R279bkJzbHaL2+c+uYF9Y1EXK0F5uNcb4hilJxaKTlg8Wgs3vIBnUGUDVsJZAudM wkKgn62Rf/7s5MaxoKLJgT36o9KSmnFdoRYdi5WOBJO8eb2p34HZGtISGwWrYMNw DJAg1wS9gclW+G4a2OnTyPb4Y4NAiMzxt6fA1QE2cjhZCjeSXqaE8WSw5i4BzI9b Md+pUkKOQBXBjPIthCrlHCzfZhGQzLJdrIyTF5yB+i6xgb+5aMfO6vCYKdd2PwtD ah+eU0V9jQIFM3xFLrm/x3uJhv9TX2eIyt6pkHPVCP7jmn+2wuaYZ5XoBTNWrsLX IqjnuMqETUbjNIWbsHypFHL+SDMdNjdfcl5XdQTKrxfK76Z/INzQaaHyuofyEYLz FioQfVBPxSDoOJo6fcg33AEugNVyLxhF/LrTkWoUpew8sc0Bpn1t2qVLxKm7Z41b yuS7DqdsF8Nv6AB0Ue8hUxMvKhgrE9VQ2sFSklNRMBV2mROzGNdjXy9OrrsgXnoJ YQtgHyM2gvlUQb/fpjLUv3txYVugQGNMTfu6AbuJWRnkro12VHpkRlVlp8hLLeDc NNu4WX/ip2iUvCQZQh2QFaEOreTUX+xcqMxic0ou71W9Sxfaem4= =IcwO -----END PGP SIGNATURE----- --2oS5YaxWCcQjTEyO--