Bananian

My humble experience with RTC and bananapi

2 13919
My fault for not doing my homework about the Allwinner A20 SOC. But I needed a battery backed RTC and didn't think that the A20 has a built-in one, so I purchased one of these:

http://www.amazon.com/gp/product/B00HF4NUSS/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1


After reading the A20 specs, I found that it does have an internal RTC, but just not backed up by battery. So may be this purchase is not a waste. So here's how I got it to work.


1) Figure out from here: http://wiki.bananapi.org/index.php/Bananapi_pin_definition to connect the RTC board on the CON3 header (pins 1, 3, 5, 7)
2) Install i2c-tools and found that the LTC is on bus 2, address 0x68


$ 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: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --


3) Found some info here but could not find the driver mentioned (i2c-bcm2708):


https://app.box.com/s/bs2csnrlylq8um1yy5gj


So after some digging, found that the driver linux/drivers/rtc/rtc-ds1307.c supports my purchased RTC chip (Maxim DS3221).


4) Could not find the ds1307 driver module in the current Bananian image, so had to rebuild the kernel. Info found in this formum:


http://forum.lemaker.org/2657-1-3-howto_build_and_install_a_modified_linux_kernel_directly_on_bananian.html


Add this config option to linux-bananapi/arch/arm/configs/sun7i_defconfig:


CONFIG_RTC_DRV_DS1307=m


and rebuild kernel and modules.

5) After installing the new uImage and kernel modules, try this out (reboot with the new kernel):


# modprobe rtc-ds1307
# echo ds1307 0x68 | sudo tee /sys/class/i2c-adapter/i2c-2/new_device


# ls /dev/rtc*


/dev/rtc0  /dev/rtc1


Note rtc0 is the internal, and rtc1 is the newly installed RTC.  Try it out:


# /sbin/hwclock --rtc=/dev/rtc1 -r

6) Change /etc/init.d/hwclock.sh to use the new RTC

HCTOSYS_DEVICE=rtc1


Change /etc/default/hwclock to use the new RTC:

HCTOSYS_DEVICE=rtc1


7) Change /etc/rc.local to load this device upon powering up. Add this line above the line "exit 0"


echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-2/new_device

8) Reboot




Edited by brandonburg at Tue Feb 24, 2015 12:02

A Bananian feature request is added for several reasons explained in the issue:

0000108: Kernel module rtc-ds1307 for the extremely accurate DS3231 RTC chip is missing
https://dev.bananian.org/view.php?id=108

That’s good you can complete this with your hard work and this project is helpful in your life. I can find a person fro grabmyessay review and I think that my search is complete now if you are interested for this then follow me in LinkedIn.

You have to log in before you can reply Login | Sign Up

Points Rules