Re: [systemd-devel] Cannot find a way to get time read from RTC during boot

2020-03-31 Thread Kevin P. Fleming
The simple service unit I posted later in the thread (which invokes
hwclock) works great for me.

On Tue, Mar 31, 2020 at 1:29 PM Michał Zegan  wrote:
>
> I have used the embedded term unfortunately, but it seems to affect at
> least some devices like raspberry pi, odroid c2, like sbc's.
>
> W dniu 31.03.2020 o 17:57, Lennart Poettering pisze:
> > On Di, 31.03.20 17:39, Michał Zegan (webczat_...@poczta.onet.pl) wrote:
> >
> >> Seems like rtc drivers as module is quite often a thing for embedded.
> >> But not sure where this should be solved, maybe at initramfs? If one is
> >> unwilling to build all rtc drivers into the kernel (the case of generic
> >> kernels where you would have to build all of them in)...
> >
> > Is that realistic? embedded devices and fully generic kernels?
> >
> > Lennart
> >
> > --
> > Lennart Poettering, Berlin
> >
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Cannot find a way to get time read from RTC during boot

2020-03-31 Thread Michał Zegan
I have used the embedded term unfortunately, but it seems to affect at
least some devices like raspberry pi, odroid c2, like sbc's.

W dniu 31.03.2020 o 17:57, Lennart Poettering pisze:
> On Di, 31.03.20 17:39, Michał Zegan (webczat_...@poczta.onet.pl) wrote:
> 
>> Seems like rtc drivers as module is quite often a thing for embedded.
>> But not sure where this should be solved, maybe at initramfs? If one is
>> unwilling to build all rtc drivers into the kernel (the case of generic
>> kernels where you would have to build all of them in)...
> 
> Is that realistic? embedded devices and fully generic kernels?
> 
> Lennart
> 
> --
> Lennart Poettering, Berlin
> 



signature.asc
Description: OpenPGP digital signature
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Cannot find a way to get time read from RTC during boot

2020-03-31 Thread Lennart Poettering
On Di, 31.03.20 17:39, Michał Zegan (webczat_...@poczta.onet.pl) wrote:

> Seems like rtc drivers as module is quite often a thing for embedded.
> But not sure where this should be solved, maybe at initramfs? If one is
> unwilling to build all rtc drivers into the kernel (the case of generic
> kernels where you would have to build all of them in)...

Is that realistic? embedded devices and fully generic kernels?

Lennart

--
Lennart Poettering, Berlin
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Cannot find a way to get time read from RTC during boot

2020-03-31 Thread Michał Zegan
Seems like rtc drivers as module is quite often a thing for embedded.
But not sure where this should be solved, maybe at initramfs? If one is
unwilling to build all rtc drivers into the kernel (the case of generic
kernels where you would have to build all of them in)...

W dniu 31.03.2020 o 16:29, Lennart Poettering pisze:
> On Do, 12.03.20 07:13, Kevin P. Fleming (ke...@km6g.us) wrote:
> 
>> I've got some Debian Buster systems (so using the Debian systemd
>> package 241-7), which have battery-backed RTCs. However the driver for
>> these RTCs is loaded as a module, not built into the kernel. As a
>> result the kernel's feature of reading the RTC to set the system clock
>> is not available.
> 
> We generally assume that RTC drivers are built-in and the kernel does
> the initial initialization of the system clock from it.
> 
>> Prior to systemd, with the 'hwclock' package installed, a udev rule
>> would trigger reading of the RTC and setting the system clock when
>> /dev/rtc0 appeared. With systemd running, the script run by that udev
>> rule is suppressed, it doesn't do anything.
> 
>> I have systemd-timesyncd started at boot as well and syncing time with
>> an NTP server; that works fine when the system clock is set to
>> something reasonably close to the actual time. If it's not, then
>> timesyncd can't adjust the time because it's too far off (and in
>> addition I have the issue reported on GitHub where systemd-resolved
>> can't resolve NTP server names due to DNSSEC failing because the clock
>> is too far off...) The file that systemd-timesyncd stores for use on
>> reboot helps a little, but if the system is shut off for a period of
>> time (an hour or more) then the time at startup is quite far off from
>> reality, which is why I have an RTC :)
> 
> Hmm, timesyncd should be able to fix the clock in any case regardless
> how far things are off? Not sure I follow?
> 
>> With a system using solely systemd-provided services, what's the
>> proper mechanism to get the time read from an RTC whose driver is
>> loaded by systemd-modules-load.service?
> 
> There's no such mechanism. We assume that the rtc0 driver is built
> into the kernel...
> 
> Lennart
> 
> --
> Lennart Poettering, Berlin
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
> 



signature.asc
Description: OpenPGP digital signature
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Cannot find a way to get time read from RTC during boot

2020-03-31 Thread Lennart Poettering
On Do, 12.03.20 07:13, Kevin P. Fleming (ke...@km6g.us) wrote:

> I've got some Debian Buster systems (so using the Debian systemd
> package 241-7), which have battery-backed RTCs. However the driver for
> these RTCs is loaded as a module, not built into the kernel. As a
> result the kernel's feature of reading the RTC to set the system clock
> is not available.

We generally assume that RTC drivers are built-in and the kernel does
the initial initialization of the system clock from it.

> Prior to systemd, with the 'hwclock' package installed, a udev rule
> would trigger reading of the RTC and setting the system clock when
> /dev/rtc0 appeared. With systemd running, the script run by that udev
> rule is suppressed, it doesn't do anything.

> I have systemd-timesyncd started at boot as well and syncing time with
> an NTP server; that works fine when the system clock is set to
> something reasonably close to the actual time. If it's not, then
> timesyncd can't adjust the time because it's too far off (and in
> addition I have the issue reported on GitHub where systemd-resolved
> can't resolve NTP server names due to DNSSEC failing because the clock
> is too far off...) The file that systemd-timesyncd stores for use on
> reboot helps a little, but if the system is shut off for a period of
> time (an hour or more) then the time at startup is quite far off from
> reality, which is why I have an RTC :)

Hmm, timesyncd should be able to fix the clock in any case regardless
how far things are off? Not sure I follow?

> With a system using solely systemd-provided services, what's the
> proper mechanism to get the time read from an RTC whose driver is
> loaded by systemd-modules-load.service?

There's no such mechanism. We assume that the rtc0 driver is built
into the kernel...

Lennart

--
Lennart Poettering, Berlin
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Cannot find a way to get time read from RTC during boot

2020-03-12 Thread Kevin P. Fleming
Indeed, I landed there later after my reply. I'm disappointed that it
was never resolved, but I did add a service unit which works
perfectly.

-

[Unit]
Description=Set system clock from hardware clock
After=systemd-modules-load.service

[Service]
Type=oneshot
ExecStart=/sbin/hwclock --hctosys --utc

[Install]
WantedBy=basic.target

On Thu, Mar 12, 2020 at 7:26 PM Dave Howorth  wrote:
>
> On Thu, 12 Mar 2020 17:35:16 -0400
> "Kevin P. Fleming"  wrote:
> > Thanks, I agree. I could some up with something which ran timedatectl
> > to set the system time from the RTC, but the hwclock tool is already
> > there for that purpose.
> >
> > I'll need to investigate why this script exits without making any
> > changes when systemd is running; either the authors expected some part
> > of systemd to read the RTC, or they expect some other service/tool to
> > do it.
> >
> > On Thu, Mar 12, 2020 at 2:02 PM Mike Gilbert 
> > wrote:
> > >
> > > On Thu, Mar 12, 2020 at 7:13 AM Kevin P. Fleming 
> > > wrote:
> > > > Prior to systemd, with the 'hwclock' package installed, a udev
> > > > rule would trigger reading of the RTC and setting the system
> > > > clock when /dev/rtc0 appeared. With systemd running, the script
> > > > run by that udev rule is suppressed, it doesn't do anything.
> > > >
> > > > With a system using solely systemd-provided services, what's the
> > > > proper mechanism to get the time read from an RTC whose driver is
> > > > loaded by systemd-modules-load.service?
> > >
> > > Your use case is likely not covered by "systemd-provided" services.
> > >
> > > I think your best bet would be to "un-supress" that hwclock udev
> > > rule.
>
> I'm not sure but you might be interested to read
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=855203
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Cannot find a way to get time read from RTC during boot

2020-03-12 Thread Dave Howorth
On Thu, 12 Mar 2020 17:35:16 -0400
"Kevin P. Fleming"  wrote:
> Thanks, I agree. I could some up with something which ran timedatectl
> to set the system time from the RTC, but the hwclock tool is already
> there for that purpose.
> 
> I'll need to investigate why this script exits without making any
> changes when systemd is running; either the authors expected some part
> of systemd to read the RTC, or they expect some other service/tool to
> do it.
> 
> On Thu, Mar 12, 2020 at 2:02 PM Mike Gilbert 
> wrote:
> >
> > On Thu, Mar 12, 2020 at 7:13 AM Kevin P. Fleming 
> > wrote:  
> > > Prior to systemd, with the 'hwclock' package installed, a udev
> > > rule would trigger reading of the RTC and setting the system
> > > clock when /dev/rtc0 appeared. With systemd running, the script
> > > run by that udev rule is suppressed, it doesn't do anything.
> > >
> > > With a system using solely systemd-provided services, what's the
> > > proper mechanism to get the time read from an RTC whose driver is
> > > loaded by systemd-modules-load.service?  
> >
> > Your use case is likely not covered by "systemd-provided" services.
> >
> > I think your best bet would be to "un-supress" that hwclock udev
> > rule.  

I'm not sure but you might be interested to read
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=855203
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Cannot find a way to get time read from RTC during boot

2020-03-12 Thread Kevin P. Fleming
Thanks, I agree. I could some up with something which ran timedatectl
to set the system time from the RTC, but the hwclock tool is already
there for that purpose.

I'll need to investigate why this script exits without making any
changes when systemd is running; either the authors expected some part
of systemd to read the RTC, or they expect some other service/tool to
do it.

On Thu, Mar 12, 2020 at 2:02 PM Mike Gilbert  wrote:
>
> On Thu, Mar 12, 2020 at 7:13 AM Kevin P. Fleming  wrote:
> > Prior to systemd, with the 'hwclock' package installed, a udev rule
> > would trigger reading of the RTC and setting the system clock when
> > /dev/rtc0 appeared. With systemd running, the script run by that udev
> > rule is suppressed, it doesn't do anything.
> >
> > With a system using solely systemd-provided services, what's the
> > proper mechanism to get the time read from an RTC whose driver is
> > loaded by systemd-modules-load.service?
>
> Your use case is likely not covered by "systemd-provided" services.
>
> I think your best bet would be to "un-supress" that hwclock udev rule.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Cannot find a way to get time read from RTC during boot

2020-03-12 Thread Mike Gilbert
On Thu, Mar 12, 2020 at 7:13 AM Kevin P. Fleming  wrote:
> Prior to systemd, with the 'hwclock' package installed, a udev rule
> would trigger reading of the RTC and setting the system clock when
> /dev/rtc0 appeared. With systemd running, the script run by that udev
> rule is suppressed, it doesn't do anything.
>
> With a system using solely systemd-provided services, what's the
> proper mechanism to get the time read from an RTC whose driver is
> loaded by systemd-modules-load.service?

Your use case is likely not covered by "systemd-provided" services.

I think your best bet would be to "un-supress" that hwclock udev rule.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Cannot find a way to get time read from RTC during boot

2020-03-12 Thread Kevin P. Fleming
I've got some Debian Buster systems (so using the Debian systemd
package 241-7), which have battery-backed RTCs. However the driver for
these RTCs is loaded as a module, not built into the kernel. As a
result the kernel's feature of reading the RTC to set the system clock
is not available.

Prior to systemd, with the 'hwclock' package installed, a udev rule
would trigger reading of the RTC and setting the system clock when
/dev/rtc0 appeared. With systemd running, the script run by that udev
rule is suppressed, it doesn't do anything.

I have systemd-timesyncd started at boot as well and syncing time with
an NTP server; that works fine when the system clock is set to
something reasonably close to the actual time. If it's not, then
timesyncd can't adjust the time because it's too far off (and in
addition I have the issue reported on GitHub where systemd-resolved
can't resolve NTP server names due to DNSSEC failing because the clock
is too far off...) The file that systemd-timesyncd stores for use on
reboot helps a little, but if the system is shut off for a period of
time (an hour or more) then the time at startup is quite far off from
reality, which is why I have an RTC :)

With a system using solely systemd-provided services, what's the
proper mechanism to get the time read from an RTC whose driver is
loaded by systemd-modules-load.service?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel