How do I make sure the RTC is started and in sync?
Hey there @jsmedley ,
Assuming the RTC is setup fine, then you should be able to run hwclock -w
to write the OS time to the RTC module, and once its in sync, you it should stay synced as long as you keep a battery on the RTC module.
Does BalenaOS connected to Balena Cloud automatically do this?
It should be done out of the box, but it’d be interesting to investigate if you find out that’s not the case. BTW, this is another thread you might find useful: Current state of hardware RTC support
It does work correctly. Just making sure as I was in the testing group and it was a fairly manual process at that time to start the clock and get it set.
Thank you for your help!
Jviotti, You commented “assuming the RTC is setup fine” then you should be able to run hwclock -w" well my RTC is not setup fine1. how do I setup the RTC on FIN running Raspian Buster?
hwclock -w
hwclock: Cannot access the Hardware Clock via any known method.
hwclock: Use the --verbose option to see the details of our search for an access method.
pi@DigiTrax:~ $ hwclock --verbose
hwclock from util-linux 2.33.1
System Time: 1609439852.294586
Trying to open: /dev/rtc0
No usable clock interface found.
hwclock: Cannot access the Hardware Clock via any known method.
Hi Paul
Just to confirm - where did you download Raspbian Buster for the balenaFin from?
This is where we have the Raspbian images for the Fin - https://github.com/balena-os/pi-gen/releases
I used the Full version from the url you mentioned above.
However, I got this info which ultimately resolved my issue:
The /boot/config.txt: “dtoverlay=balena-fin” didn’t seem to set the Rpi system clock to the RTC hw clock as Balena says. Maybe due to not up-to-date OS packages?
A suggestion of using /etc/modules: “rtc_ds1307” or dtoverlay=i2c-rtc,ds1307 also didn’t seem to work.
I was only able to get it going by first verifying the RTC clock had the right time then setting the system clock to the rtc clock:
-
I2C activated in raspi-config → Interfacing Options → I2C
-
Verify UTC and RTC times are SAME.
timedatectl status -
If RTC is NOT correct but system time is:
sudo hwclock --systohc -
Edit /etc/rc.local:
sudo vi /etc/rc.local
hwclock --hctosys
exit 0
echo “timedatectl status” >> /home/pi/.bashrc
sudo reboot
When you ssh in, you should see time messages and the UTC and RTC times the SAME.
IF this seems to solve the problem, then I can add this to the FIN build script, I believe.
These docs for RTC didn’t seem to work!!:
Painful,
Russell
Hey @asawizard ,
I’ve just tested in a newly flashed unit with a “full” raspbian version downloaded from the website and got the RTC working by following these steps:
- Enable I2C interfaces (you can do it by running
sudo raspi-config
→Interfacing options
→ ‘I2C’).- - Add the RTC module (
sudo modprobe rtc-ds1307
)
After that the RTC clock should start synchronizing. You can check that it’s happening if you see a UU
under the 0x68 address when running i2cdetect -y 3
.
Cheers,
Nico.