Hi, I have put the line *dtb_overlay = /lib/firmware/BB-I2C2-RTC-DS3231.dtbo * in /boot/uEnv.txt but it does not create /dev/rtc1. The dmesg are
root@beaglebone:/dev# dmesg | grep 3231 [ 2.132312] console [ttyS0] enabled root@beaglebone:/dev# dmesg | grep rtc [ 2.221605] omap_rtc 44e3e000.rtc: already running [ 2.222249] omap_rtc 44e3e000.rtc: rtc core: registered 44e3e000.rtc as rtc0 [ 2.572035] PM: bootloader does not support rtc-only! [ 2.573042] omap_rtc 44e3e000.rtc: setting system clock to 2000-01-01 02:14:15 UTC (946692855) root@beaglebone:/dev# dmesg | grep rtc1 root@beaglebone:/dev# root@beaglebone:/dev# dmesg | grep rtc [ 2.221605] omap_rtc 44e3e000.rtc: already running [ 2.222249] omap_rtc 44e3e000.rtc: rtc core: registered 44e3e000.rtc as rtc0 [ 2.572035] PM: bootloader does not support rtc-only! [ 2.573042] omap_rtc 44e3e000.rtc: setting system clock to 2000-01-01 02:14:15 UTC (946692855) root@beaglebone:/dev# date Tue Jul 14 13:07:39 IST 2020 root@beaglebone:/dev# hwclock -r -f /dev/rtc Sat 01 Jan 2000 07:46:54 AM IST -0.651632 seconds On Thu, Aug 20, 2020 at 12:49 PM Niresh Kumar <[email protected]> wrote: > Hi, > 1). I have placed the following lines in the /etc/rc.local, and system > time gets updated with external RTC DS3231 automatically at every reboot > > *echo ds3231 0x68 > /sys/class/i2c-adapter/i2c-1/new_device* > > *hwclock -s -f /dev/rtc1* > > > dtb_overlay = /lib/firmware/BB-I2C2-RTC-DS3231.dtbo > > On Tue, Aug 18, 2020 at 8:25 PM Tarmo <[email protected]> wrote: > >> On Tuesday, 18 August 2020 17:47:00 UTC+3, Tarmo wrote: >>> >>> On Tuesday, 18 August 2020 14:45:23 UTC+3, Robert Heller wrote: >>>> >>>> At Tue, 18 Aug 2020 02:40:41 -0700 (PDT) [email protected] >>>> wrote: >>>> > I am using beagle Bone Black with debian image. Could any please >>>> suggest >>>> > how to automatically set the system time (on every reboot) by >>>> external RTC >>>> > module DS3231. Once internet is connected, i want to update both >>>> system >>>> > time and DS3231 with the network time. >>>> > >>>> > I am controlling a relay based on system time, my application should >>>> take >>>> > DS3231 time and run perfectly even if internet is disconnected and >>>> not >>>> > available for so many days. >>>> > >>>> > Few things i have tried, the following content has been kept in the >>>> script >>>> > and running @reboot script in crontab. The system time has been >>>> changed if >>>> > we enter this command manually after boot but not in auto start >>>> script. >>>> > Please advice. >>>> > >>>> > *echo ds3231 0x68 > /sys/class/i2c-adapter/i2c-1/new_device* >>>> > >>>> > *hwclock -r -f /dev/rtc1* >>>> >>>> Well, the simple / dumb option would be to put the above two lines in >>>> /etc/rc.local, which will restore the system clock from the RTC. >>>> >>>> The other option is to create a proper RTC service. A properly setup >>>> RTC >>>> service will restore the system clock from the RTC early in the boot >>>> process >>>> and save the system clock late in the shutdown process. >>>> >>> >>> A proper RTC service is already implemented by the systemd-timesyncd >>> service, installed by default on the debian images: >>> >>> https://www.freedesktop.org/software/systemd/man/systemd-timesyncd.service.html >>> >>> It does everything Niresh needs out of box. There's a caveat: >>> systemd-timesyncd only works with */dev/rtc0* device. By default >>> */dev/rtc0* is grabbed by the AM335x CPU-s internal RTC (which has no >>> battery backup) and the external RTC is left with */dev/rtc1* which >>> gets ignored. I did not find any way to configure systemd-timesyncd to use >>> the other device. >>> >>> Robert pointed me to a device tree which very conveniently swapped the >>> device nodes for those RTCs so the external one got */dev/rtc0*. I just >>> had to load the device tree via /boot/uEnv.txt and time syncing worked >>> beautifully. For Niresh, I suggest trying this one: >>> >>> >>> https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/BB-I2C2-RTC-DS3231.dts >>> <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fbeagleboard%2Fbb.org-overlays%2Fblob%2Fmaster%2Fsrc%2Farm%2FBB-I2C2-RTC-DS3231.dts&sa=D&sntz=1&usg=AFQjCNEt87UyBS-inpep25aZNVAfhEhfXw> >>> >> >> To clarify the "trying" step: you'll probably find the compiled device >> tree in the Beagle's file system: "/lib/firmware/BB-I2C2-RTC-DS3231.dtb". >> Just add this to /boot/uEnv.txt using standard method and reboot. >> Monitoring the boot log via dmesg should tell you which RTC device was >> awarded /dev/rtc0. >> >> -- >> Kind regards, >> Tarmo >> >> -- >> For more options, visit http://beagleboard.org/discuss >> --- >> You received this message because you are subscribed to a topic in the >> Google Groups "BeagleBoard" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/beagleboard/m4hZYsA-d8M/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/beagleboard/340040ae-d9d1-4f28-9518-ec4f5ab8ac1eo%40googlegroups.com >> <https://groups.google.com/d/msgid/beagleboard/340040ae-d9d1-4f28-9518-ec4f5ab8ac1eo%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/CAF7-PaTAasp1jjRuEFudByXqGsd1ZehqEbdzkjbV89WZFw8Svg%40mail.gmail.com.
