How to lock hardware clock from changes?

AmigaOne X5000 platform specific issues related to Linux only.
Post Reply
Roland
Posts: 825
Joined: Tue May 02, 2017 7:23 am

How to lock hardware clock from changes?

Post by Roland »

Some Linux distros, like Ubuntu, have the bad habit of changing the hardware clock, so that time is wrong on the AmigaOS side. How could I prevent this? I have set the same time zone set on both sides, though.
- Roland -
User avatar
nbache
Beta Tester
Beta Tester
Posts: 1714
Joined: Mon Dec 20, 2010 7:25 pm
Location: Copenhagen, Denmark
Contact:

Re: How to lock hardware clock from changes?

Post by nbache »

As far as I know, you can't.

You should rather let Linux set it as it wants and then, on the AmigaOS side, set the system clock using an NTC server during startup, without saving it to the hardware clock.

The problem is that Linux expects the hardware clock to be UTC, while AmigaOS wants the system clock to follow the local time. This way, you can humour both.

The NTC server setup is in the second tab of the Time prefs. Make sure you set it and save the prefs. Then, to set the time during startup, put the following line into your S:Network-Startup after the lines that start the network:

Date SERVER PREFS

The PREFS is a special value for the SERVER argument which makes Date use the server setup from the saved time.prefs.


Best regards,

Niels
User avatar
xeno74
Posts: 9349
Joined: Fri Mar 23, 2012 7:58 am

Re: How to lock hardware clock from changes?

Post by xeno74 »

Roland,

First, boot OS4.1 and disable the saving to the HW clock.
nbache wrote: You should rather let Linux set it as it wants and then, on the AmigaOS side, set the system clock using an NTC server during startup, without saving it to the hardware clock.
Then boot Linux and configure the time in UTC for the kernel clock with

Code: Select all

sudo date 112110052018
11 = Month
21 = Day of month
10 = Hour
05 = Minute
2018 = Year

You can figure out the UTC time with the following link: https://time.is/de/UTC

After that synchronize your HW clock with your kernel time:

Code: Select all

sudo hwclock --systohc
Then set up your HW clock for UTC with

Code: Select all

sudo hwclock --hctosys -u
Afterwards please reboot your X5000.

You can check the time from your HW clock with the command:

Code: Select all

sudo /sbin/hwclock
For example the following output:

Code: Select all

Wed 21 Nov 2018 10:40:37 CET  .713540 seconds
Then check the kernel time with date:

Code: Select all

Wed 21 Nov 11:42:06 CET 2018
The kernel time is synchronized with a NTP server.

Please test it.

Thanks,
Christian
http://www.amigalinux.org
http://www.supertuxkart-amiga.de

Running Linux on AmigaONEs can require some tinkering.
Roland
Posts: 825
Joined: Tue May 02, 2017 7:23 am

Re: How to lock hardware clock from changes?

Post by Roland »

I found finally a simple solution to this dilemma:

Code: Select all

timedatectl set-local-rtc 1 --adjust-system-clock
That forces also Linux to use local time, instead of UTC. No need to use external time servers to constantly adjust the time...
- Roland -
User avatar
xeno74
Posts: 9349
Joined: Fri Mar 23, 2012 7:58 am

Re: How to lock hardware clock from changes?

Post by xeno74 »

Great and thanks for sharing!
http://www.amigalinux.org
http://www.supertuxkart-amiga.de

Running Linux on AmigaONEs can require some tinkering.
Post Reply