Jump to content

RTC on Banana Pro


someone

Recommended Posts

Hello , How do I get RTC working on Banana Pro.

I think I have 2 options 1. Built in one 2. External [DS3231]

 

Here is  some info about the setup i got.

dmesg | grep -i rtc

[    1.928725] sunxi-rtc sunxi-rtc: Warning: RTC time is wrong!
[    1.934023] sunxi-rtc sunxi-rtc: rtc core: registered rtc as rtc0

 

hwclock --test -D

hwclock from util-linux 2.27.1
Using the /dev interface to the clock.
Last drift adjustment done at 1506000286 seconds after 1969
Last calibration done at 1506000286 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
select() to /dev/rtc to wait for clock tick timed out...synchronization failed

 

 ls -l /dev/rtc*
lrwxrwxrwx 1 root root      4 Oct 16 18:20 /dev/rtc -> rtc0
crw------- 1 root root 254, 0 Oct 16 18:20 /dev/rtc0

 

 

uname -ar
Linux bananapipro 3.4.113-sun7i #23 SMP PREEMPT Wed Jun 14 23:57:45 CEST 2017 armv7l armv7l armv7l GNU/Linux
 

When I attache DS3231 module it comes up on I2c 2 i think 

 

sudo i2cdetect -y 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                       

 

 

So how Do I set any one of them up?

Let me know if you need any more information. Thanks!

Link to comment
Share on other sites

You may try to use my script ( for external RTC - please adjust it as I do not know if paths for devices are the same as on H3 OrangePi ):

 

rtc-i2c.zip

 

the script "rtc-i2c.sh" (of course please add executable attribute) shall be located at /etc/conf.d (please create this folder or choose your own - but then you need to edit "rtc-i2c.service" content).

 

root@PKPRINT:/etc/conf.d# pwd
/etc/conf.d
root@PKPRINT:/etc/conf.d# ls -l rtc-i2c.sh
-rwxr-x--- 1 root root 1941 Mar  2  2017 rtc-i2c.sh
root@PKPRINT:/etc/conf.d# ./rtc-i2c.sh show
Current date on RTC (/dev/rtc0): Thu 01 Jan 1970 01:25:24 AM CET -1.749911 seconds
Current date on RTC (/dev/rtc1): Mon 16 Oct 2017 09:30:18 PM CEST -0.899079 seconds
Current system date: Mon 16 Oct 2017 09:30:18 PM CEST
root@PKPRINT:/etc/conf.d#

 

if everything is ok then you may try to put file "rtc-i2c.service" into /lib/systemd/system and execute:

 

systemctl enable rtc-i2c.service

 

Reboot and check if everything is working correctly:

 

systemctl status rtc-i2c.service

and in dmesg:

 

[    7.564372] systemd[1]: Starting Initialize i2c hardware RTC device driver...
[    7.691503] systemd[1]: Mounting FUSE Control File System...
[    7.821186] systemd[1]: Starting Apply Kernel Variables...
[    7.861767] rtc-ds1307 0-0068: rtc core: registered ds1307 as rtc1
[    7.861811] rtc-ds1307 0-0068: 56 bytes nvram
[    7.861882] i2c i2c-0: new_device: Instantiated device ds1307 at 0x68
[    7.892466] systemd[1]: Mounted Configuration File System.

 

Link to comment
Share on other sites

Sorry , was not able to try this until now!

So I think I was supposed to change following lines in .sh file


 

EXTERNAL_RTC="rtc0"

INTERNAL_RTC="rtc"

 

[I put rtc0 and rtc in there]

 

and I copied the .sh file to /etc/conf.d and ran it using sudo but I get only this output

 

Current date on RTC (/dev/rtc0):

 

And nothing else.

 

Thanks for helping me with this , but its still not working.

Edited by someone
spelling
Link to comment
Share on other sites

stephan@bananapipro:~$ dmesg | grep -i rtc
[    3.939338] sunxi-rtc 1c20d00.rtc: rtc core: registered rtc-sunxi as rtc0
[    3.939345] sunxi-rtc 1c20d00.rtc: RTC enabled
[    3.962747] axp20x-i2c 0-0034: Backup (RTC) battery charging is disabled
Welcome to ARMBIAN 5.31 stable Debian GNU/Linux 8 (jessie) 4.11.6-sunxi

 

 

Link to comment
Share on other sites

Hi,  what you need to do is just check this parameters (do not touch others):

 

BUS="0"

ADAPTER=/sys/class/i2c-adapter/i2c-$BUS

 

For example in my Orange Pis (all) it is:

 

root@PKSERVER:~# ls -l /sys/class/i2c-adapter/i2c-0
lrwxrwxrwx 1 root root 0 Jan  1  1970 /sys/class/i2c-adapter/i2c-0 -> ../../devices/platform/twi.0/i2c-0

 

 

I do not know Banana SBCs, so that's why I suggested to check and correct path (which is given by two variables as above). BTW. Have you tried running the script without any change?

 

Then try to run script as suggested. Expected result is that your rtc on i2c bus will be registered as /dev/rtc1 (please note that script is not changing original symlink which is /dev/rtc - it is explicitly running hwclock with /dev/rtc1)

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines