dragonlost Posted October 5, 2017 Posted October 5, 2017 Hello ! I see in config file of kernel 4.14 support for RTC ds1307. But in system i not see RTC. I just see RK808 RTC. I need your help for use DS1307 in my tinkerboard because rk808 is not fonctional ( no battery)
botfap Posted October 5, 2017 Posted October 5, 2017 The ds1307 should work on stock kernels from at least 2.6 without problem. I use the ds3231's which uses the same ds1307 driver that you need to use. Its working fine for me in 4.4 and 4.13 kernels on the tinker. I use the 3231 purely because we can buy them for < £1.50 each mounted with temp sensor and battery and it works on stock kernels. When you load the rtc-ds1307 module does /dev/rtc1 appear? (/dev/rtc0 is the rk808 normally) Are you using the miniarm device tree, custom or in kernel? Have you modified your udev rules to point at KERNEL=="rtc1" instead of KERNEL=="rtc0"? (default and hwclock rules) Have you set HCTOSYS_DEVICE=rtc1 in /etc/default/hwclock?
dragonlost Posted October 5, 2017 Author Posted October 5, 2017 hello. I use Next version for tinkerboard (kernel 4.13.3) When i plug RTC (it's DS3231) in my tinkerboard, i no see RTC1 in /dev/ just RTC0. with the command : i2cdetect -y 1 i see 68. I need to activate something to see RTC1? No have /etc/default/hwclock edit : With command : echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new-device and ls /dev/rtc* i see RTC1. with command : hwclock --rtc /dev/rtc1 i see time on RTC DS3231. But I do not understand how to ask the Tinkerboard to use it
botfap Posted October 5, 2017 Posted October 5, 2017 Can you post the output of the following: dmesg lsmod | while read i ; do echo "#### Module: $i ####" ; echo $i | cut -d" " -f1 ; modinfo `echo $i | cut -d" " -f1` ; done i2cdetect -l i2cdetect -y -a 1
martinayotte Posted October 5, 2017 Posted October 5, 2017 If you wish to synchronize system clock with this /dev/rtc1 : hwclock -rtc /dev/rtc1 --hctosys
TonyMac32 Posted October 5, 2017 Posted October 5, 2017 Please post the link provided by issuing armbianmonitor -u
TonyMac32 Posted October 5, 2017 Posted October 5, 2017 Is your RTC attached to GPIO 3 and 5 or GPIO 27-28? 3-5 are I2C1, 27-28 are I2C4 Just a sanity check.
dragonlost Posted October 5, 2017 Author Posted October 5, 2017 link for armbianmonitor : http://sprunge.us/iTBh
dragonlost Posted October 5, 2017 Author Posted October 5, 2017 My RTC is atached to GPIO 3 and 5 result of lsmod : Module Size Used by snd_soc_hdmi_codec 16384 0 mali_kbase 339968 0 dw_hdmi_i2s_audio 16384 0 uas 20480 0 1
TonyMac32 Posted October 5, 2017 Posted October 5, 2017 @botfap the armbianmonitor output will have everything but the I2C-specific info, for future reference. It's pretty handy. @dragonlost I had this open on my phone and didn't see your edit to the post, sorry about that. Thank you for the additional info.
botfap Posted October 5, 2017 Posted October 5, 2017 15 minutes ago, dragonlost said: My RTC is atached to GPIO 3 and 5 result of lsmod : Module Size Used by snd_soc_hdmi_codec 16384 0 mali_kbase 339968 0 dw_hdmi_i2s_audio 16384 0 uas 20480 0 Extra sanity check, did you connect the RTC Ground to pin4 on the tinker? Also you dont have the rtc-ds1307 kernel module loaded. If you reboot clean and "modprobe rtc-ds1307" does /dev/rtc1 appear without the "echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new-device"? If yes to both then the next steps for setup are easy. 1
botfap Posted October 5, 2017 Posted October 5, 2017 @TonyMac32 thanks! Steps to use the ds3231 as system clock: 1) Add "echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new-device" to /etc/rc.local (if needed and above "exit 0") 2) In /lib/udev/hwclock-set comment out the following: if [ -e /run/systemd/system ] ; then exit 0 fi if [ -e /run/udev/hwclock-set ]; then exit 0 fi then change the HCTOSYS_DEVICE=rtc0 to be HCTOSYS_DEVICE=rtc1 3)In /lib/udev/rules.d/50-udev-default.rules change the SUBSYSTEM=="rtc" line to: SUBSYSTEM=="rtc", KERNEL=="rtc1", SYMLINK+="rtc", OPTIONS+="link_priority=-100" 4) In your hwclock udev rule make sure you have (/lib/udev/rules.d/85-hwclock.rules): KERNEL=="rtc1", RUN+="/lib/udev/hwclock-set $root/$name" 1
dragonlost Posted October 5, 2017 Author Posted October 5, 2017 After modprobe rtc-ds1307 i not see rtc1. In my list of modprobe posibilty no have rtc-ds1307 just "rtc-cpcap"
botfap Posted October 5, 2017 Posted October 5, 2017 13 minutes ago, dragonlost said: After modprobe rtc-ds1307 i not see rtc1. In my list of modprobe posibilty no have rtc-ds1307 just "rtc-cpcap" Ahh, did you compile as kernel built in instead of module? Also is the RTC ground pin connected to GPIO pin 4 on the tinker?
dragonlost Posted October 5, 2017 Author Posted October 5, 2017 No have compile kernel just install Armbian Next image . I use this module : I plug this modul in 5 first GPIO ( 3.3v, SDA,SCL, None, GND) -> 1,3,5,7 and 9
botfap Posted October 5, 2017 Posted October 5, 2017 Yes thats the correct pins sorry, I had a different board in my mind when I was thinking about it. OK so if you ONLY do the command: "echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new-device" from a clean boot then you can read the RTC? Is that correct? You can read it without loading a kernel driver module?
dragonlost Posted October 5, 2017 Author Posted October 5, 2017 5 minutes ago, botfap said: Yes thats the correct pins sorry, I had a different board in my mind when I was thinking about it. OK so if you ONLY do the command: "echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new-device" from a clean boot then you can read the RTC? Is that correct? You can read it without loading a kernel driver module? yes from clean boot and i load the command : "echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new-device", i see rtc1 in device and i can read it with hwclock --rtc /dev/rtc1
dragonlost Posted October 5, 2017 Author Posted October 5, 2017 1 hour ago, botfap said: 4) In your hwclock udev rule make sure you have: KERNEL=="rtc1", RUN+="/lib/udev/hwclock-set $root/$name" I can not find the file in which to check this line
botfap Posted October 5, 2017 Posted October 5, 2017 Thats good, it means the driver is compiled into the kernel. Do the following: 1) Add "echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new-device" to /etc/rc.local, above the "exit 0" line at the bottom 2) In /lib/udev/hwclock-set comment out the lines below then change the HCTOSYS_DEVICE=rtc0 line to be HCTOSYS_DEVICE=rtc1 if [ -e /run/systemd/system ]; then exit 0 fi if [ -e /run/udev/hwclock-set ]; then exit 0 fi 3) In /lib/udev/rules.d/50-udev-default.rules change the SUBSYSTEM=="rtc" line to: SUBSYSTEM=="rtc", KERNEL=="rtc1", SYMLINK+="rtc", OPTIONS+="link_priority=-100" 4) In your hwclock udev rule make sure you have (/lib/udev/rules.d/85-hwclock.rules): KERNEL=="rtc1", RUN+="/lib/udev/hwclock-set $root/$name"
dragonlost Posted October 5, 2017 Author Posted October 5, 2017 1 hour ago, botfap said: 2) In /lib/udev/hwclock-set comment out the following: if [ -e /run/systemd/system ] ; then exit 0 fi if [ -e /run/udev/hwclock-set ]; then exit 0 fi I do not understand why it is necessary to comment his lines?
botfap Posted October 5, 2017 Posted October 5, 2017 1 minute ago, dragonlost said: I can not find the file in which to check this line If it doesnt exist create a new udev rule at: /lib/udev/rules.d/85-hwclock.rules
botfap Posted October 5, 2017 Posted October 5, 2017 7 minutes ago, dragonlost said: I do not understand why it is necessary to comment his lines? Becuase /run/systemd/system will always exist and that if statement terminates the script if it finds /run/systemd/system You can leave the second one in if you want, /run/udev/hwclock-set doesnt and wont exist, its just not relevant.
dragonlost Posted October 5, 2017 Author Posted October 5, 2017 53 minutes ago, botfap said: Thats good, it means the driver is compiled into the kernel. Do the following: 1) Add "echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new-device" to /etc/rc.local, above the "exit 0" line at the bottom 2) In /lib/udev/hwclock-set comment out the lines below then change the HCTOSYS_DEVICE=rtc0 line to be HCTOSYS_DEVICE=rtc1 if [ -e /run/systemd/system ]; then exit 0 fi if [ -e /run/udev/hwclock-set ]; then exit 0 fi 3) In /lib/udev/rules.d/50-udev-default.rules change the SUBSYSTEM=="rtc" line to: SUBSYSTEM=="rtc", KERNEL=="rtc1", SYMLINK+="rtc", OPTIONS+="link_priority=-100" 4) In your hwclock udev rule make sure you have: KERNEL=="rtc1", RUN+="/lib/udev/hwclock-set $root/$name" I made the changes you gave me but it does not work. The rtc1 is detected but does not update the system clock at startup. On the other hand, the rtc0 does not do it either. The rtc1 is on time. The rtc0 is in 2013. The system clock is staying at the time it was before extinction. to test I disconnected the networks and I left off for 20min. Then I rode without networks.
botfap Posted October 5, 2017 Posted October 5, 2017 what happens if you manually run: /sbin/hwclock --rtc=/dev/rtc1 --systz /sbin/hwclock --rtc=/dev/rtc1 --hctosys
dragonlost Posted October 5, 2017 Author Posted October 5, 2017 5 minutes ago, botfap said: what happens if you manually run: /sbin/hwclock --rtc=/dev/rtc1 --systz /sbin/hwclock --rtc=/dev/rtc1 --hctosys for systz nothing append for hctosys the tim system is update at the good time
botfap Posted October 5, 2017 Posted October 5, 2017 --systz sets the time zone and only needs to be called once per boot, it wont show you any time changes --hctosys sets the system time from the rtc --systohc sets the rtc clock with the system time (after ntp sync for example) What happens if you run just: /lib/udev/hwclock-set /dev/rtc1
TonyMac32 Posted October 5, 2017 Posted October 5, 2017 https://github.com/armbian/build/blob/bd86656819af402a8d301d823dd76e8877ca809b/config/kernel/linux-rockchip-next.config#L3790 The driver is built in.
dragonlost Posted October 5, 2017 Author Posted October 5, 2017 17 minutes ago, botfap said: --systz sets the time zone and only needs to be called once per boot, it wont show you any time changes --hctosys sets the actual time from the rtc --systohc sets the rtc clock with the system time (after ntp sync for example) What happens if you run just: /lib/udev/hwclock-set hwclock: Cannot access the Hardware Clock via any known method
botfap Posted October 5, 2017 Posted October 5, 2017 2 minutes ago, dragonlost said: hwclock: Cannot access the Hardware Clock via any known method What about with the device specified? /lib/udev/hwclock-set /dev/rtc1
dragonlost Posted October 5, 2017 Author Posted October 5, 2017 16 minutes ago, botfap said: What about with the device specified? /lib/udev/hwclock-set /dev/rtc1 No error and set system at the good time
Recommended Posts