Hi,
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
Best regards,
NK
At Tue, 18 Aug 2020 02:40:41 -0700 (PDT) beagl...@googlegroups.com 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.
echo ds3231 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
hwclock -s -f /dev/rtc1
--
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 beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/340040ae-d9d1-4f28-9518-ec4f5ab8ac1eo%40googlegroups.com.
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
echo ds3231 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
hwclock -s -f /dev/rtc1
2) 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 and system time not updated with external RTC DS3231. 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
Best regards,
NK
If it's in the uEnv.txt file properly, it should be loaded. That overlay is pre-built into the initrd.img.
Did you make changes to that .dts and properly rebuild it and install it with the install.sh script?
If it's in the uEnv.txt file properly, it should be loaded. That overlay is pre-built into the initrd.img.
--
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 beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/1b12d312-a238-42a9-8898-36c676a5bec2o%40googlegroups.com.
We did not make any changes to the .dts file. uEnv.txt file attached for your reference.There is no script "verison.sh" in the path /opt/scripts/tools/ in kernel version 4.4.30-ti-r64.
On Thu, 20 Aug 2020 00:40:38 -0700, Niresh Kumar writes:
>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*
...
>
>2) I have put the line *dtb_overlay =
>/lib/firmware/BB-I2C2-RTC-DS3231.dtbo * in /boot/uEnv.txt but it does not
the overlay you're using won't work because your rtc chip is
on i2c bus one: as its name (...I2C2...) indicates it's for a
clock chip being on i2c bus two.
use dtc to decompile that overlay, edit for i2c1 and dtc it back into
binary form.
$ git clone https://github.com/beagleboard/bb.org-overlays.git
$ cd bb.org-overlays
$ cp src/arm/BB-I2C2-RTC-DS3231.dts src/arm/BB-I2C1-RTC-DS3231.dts
$ vim src/arm/BB-I2C1-RTC-DS3231.dts
... update I2C bus number ...
$ make src/arm/BB-I2C1-RTC-DS3231.dtbo
$ cp src/arm/BB-I2C1-RTC-DS3231.dtbo /lib/firmware--
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 beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/ffd21cc3-37ea-4526-80da-b4e1ae428d66o%40googlegroups.com.
I've have tested both BB-I2C1-RTC-DS3231.dtbo and BB-I2C2-RTC-DS3231.dtbo in the new image 4.19.94-ti-r42, they mount rtc1 in /dev but system time is not updated with rtc1. Please let me know if any other procedure is required and also procedure to update external rtc1 time when the internet is connected.
One thing i have observed, with BB-I2C1-RTC-DS3231.dtbo the timedatectl command displayed "RTC time: n/a" not system time as in normal condition.
Please clarify the following points1. How do you say the rtc chip is in i2c bus one. Using i2cdetect command "i2cdetect -r 2" , 0x68 external device showed in i2c bus two.
2. I understand overlay is an out of box approach. In 4.4.30-ti-r64, system time updated with "echo ds3231 0x68 > /sys/class/i2c-adapter/i2c-1/new_device; hwclock -r -f /dev/rtc1" in /etc/rc.local. Is there any problem if I use this approach in older images?
debian@beaglebone:/boot$ dmesg | grep rtc1
[ 2.285972] omap_rtc 44e3e000.rtc: registered as rtc1
debian@beaglebone:/boot$ dmesg | grep rtc
[ 2.283660] rtc-ds1307: probe of 1-0068 failed with error -16
[ 2.285972] omap_rtc 44e3e000.rtc: registered as rtc1
[ 2.574770] [drm] Cannot find any crtc or sizes
[ 2.603277] hctosys: unable to open rtc device (rtc0)
[ 3.592324] [drm] Cannot find any crtc or sizes
[ 57.824450] PM: rtc0 not available
[ 59.781548] PM: rtc0 not available
[ 59.958344] PM: rtc0 not available
[ 60.042066] PM: rtc0 not available
debian@beaglebone:/boot$
--
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 beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/CAOCHtYgrYbKzRcC3xfQWaqh1Yp5_ZSQBfyr%3Di-_a1fAxApYfoQ%40mail.gmail.com.
Attached output from "sudo /opt/scripts/tools/version.sh" and the content of your "/boot/uEnv.txt" file along with boot log message.
debian@beaglebone:/boot$ dmesg | grep rtc
[ 2.283660] rtc-ds1307: probe of 1-0068 failed with error -16
Please help me with bash scripts for external RTC and its procedure.
debian@beaglebone:/dev$ i2cdetect -r -y 2
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
debian@beaglebone:/dev$ i2cdetect -r -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
debian@beaglebone:/dev$ i2cdetect -r -y 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- UU -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- 34 -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: UU -- -- -- -- -- -- --
debian@beaglebone:/dev$
Regards,
NK
--
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 beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/500b2fb8-177f-4a6e-885a-1d0c612f2e24o%40googlegroups.com.
Hi,debian@beaglebone:/dev$ i2cdetect -r -y 2
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
root@beaglebone:/dev# hwclock -r -f /dev/rtc1
2000-01-01 00:49:21.771707+00:00
root@beaglebone:/dev# timedatectl
Local time: Tue 2020-09-01 04:34:29 UTC
Universal time: Tue 2020-09-01 04:34:29 UTC
RTC time: Tue 2020-09-01 04:34:29
Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: no
NTP service: active
RTC in local TZ: no
debian@beaglebone:/dev$ dmesg | grep rtc
[ 1.280996] rtc-ds1307 2-0068: registered as rtc0
[ 1.283636] omap_rtc 44e3e000.rtc: already running
[ 1.284312] omap_rtc 44e3e000.rtc: registered as rtc1
[ 1.574739] [drm] Cannot find any crtc or sizes
[ 1.604280] rtc-ds1307 2-0068: setting system clock to 2020-09-01 04:30:36 UTC (1598934636)
[ 2.600387] [drm] Cannot find any crtc or sizes
[ 56.285738] PM: bootloader does not support rtc-only!
debian@beaglebone:/dev$ dmesg | grep i2c
[ 0.315725] omap_i2c 4802a000.i2c: bus 1 rev0.11 at 100 kHz
[ 0.317402] omap_i2c 4819c000.i2c: bus 2 rev0.11 at 100 kHz
[ 1.286054] i2c /dev entries driver
[ 1.590657] input: tps65217_pwr_but as /devices/platform/ocp/44e0b000.i2c/i2c-0/0-0024/tps65217-pwrbutton/input/input0
[ 1.592768] omap_i2c 44e0b000.i2c: bus 0 rev0.11 at 400 kHz
--
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 beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/ed5f7cb9-873a-44d0-8715-c5c624f046d4o%40googlegroups.com.
debian@beaglebone:~$ timedatectl
Local time: Tue 2020-09-01 10:32:27 UTC
Universal time: Tue 2020-09-01 10:32:27 UTC
RTC time: Sat 2000-01-01 00:15:42
Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: no
NTP service: active
RTC in local TZ: no
Reconnecting internet connection.
debian@beaglebone:~$ timedatectl
Local time: Tue 2020-09-01 10:47:37 UTC
Universal time: Tue 2020-09-01 10:47:37 UTC
RTC time: Tue 2020-09-01 10:47:37
Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
debian@beaglebone:~$ hwclock -r -f /dev/rtc1
2000-01-01 00:17:30.204350+00:00
debian@beaglebone:~$ sudo hwclock -r -f /dev/rtc0
2020-09-01 10:48:49.965
Regards,
NK
--
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 beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/a8f8f997-41a5-8032-4c21-e8cc425b49ae%40gmail.com.
Local time: Tue 2020-09-01 10:32:27 UTC
Universal time: Tue 2020-09-01 10:32:27 UTC
RTC time: Sat 2000-01-01 00:15:42
--
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 beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/342c4a25-ccc0-f69b-3039-028c3cc59485%40gmail.com.
--
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 beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/338861fc-3973-12a5-e0e9-6fc979c9dfc3%40gmail.com.
--
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 beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/CAOCHtYgMqVpXgg6qJ1fgtkCbJCY2f8OtcDfVEYbYW3CWbFA0rw%40mail.gmail.com.
/usr/bin/ld: rtc_time.o: relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: jsparser.o: relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: populateListFromFile.o: relocation R_ARM_THM_MOVW_ABS_NC against `file1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: readFromFileNPopulateList.o: relocation R_ARM_THM_MOVW_ABS_NC against `file1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: jsparser.o(.text+0x46): unresolvable R_ARM_THM_CALL relocation against symbol `json_object_get_boolean'
/usr/bin/ld: final link failed: nonrepresentable section on output
collect2: error: ld returned 1 exit status
make: *** [Makefile:152: smartmeter] Error 1
Regards,
NK
--
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 beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/CAOCHtYgMqVpXgg6qJ1fgtkCbJCY2f8OtcDfVEYbYW3CWbFA0rw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/CAF7-PaQSOLy9q65Fth%3DjMkAEL5rQSaxGchrDM4%2Bzvtuj8%3D7jaA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/CAPW7rrJHwEoP7%2B1wLK4LWZb0UCapyw%3D_0HrP3%2BMExgF%2B1d%3D96g%40mail.gmail.com.
--
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 beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/CAOCHtYjBba%2Byja4ZMqXU4u68YLvxFvveycJM5CM%2BQSmkZJmsxA%40mail.gmail.com.