Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
en:pcf8563rtc [2017/01/22 12:53] odroid [Ubuntu] |
en:pcf8563rtc [2017/07/28 11:26] (current) luke.go [Android] |
||
---|---|---|---|
Line 16: | Line 16: | ||
===== Configuration ===== | ===== Configuration ===== | ||
==== Ubuntu ==== | ==== Ubuntu ==== | ||
- | - With your ODROID-C2 insert a PCF8563 RTC Module as the following picture. | + | - Insert the RTC Shield on your C2 as the above pictures and turn on the system. |
- Enable RTC Shield driver in Device Tree file and add the I2C driver <code> | - Enable RTC Shield driver in Device Tree file and add the I2C driver <code> | ||
odroid@odroid:~$ sudo apt install device-tree-compiler | odroid@odroid:~$ sudo apt install device-tree-compiler | ||
odroid@odroid:~$ sudo fdtput -t s /media/boot/meson64_odroidc2.dtb /i2c@c1108500/pcf8563@51 status "okay" | odroid@odroid:~$ sudo fdtput -t s /media/boot/meson64_odroidc2.dtb /i2c@c1108500/pcf8563@51 status "okay" | ||
- | odroid@odroid:~$ echo "aml_i2c"|sudo tee -a /etc/modules | + | odroid@odroid:~$ echo "aml_i2c"|sudo tee -a /etc/modules |
+ | odroid@odroid:~$ echo "rtc_pcf8563"|sudo tee -a /etc/modules | ||
odroid@odroid:~$ reboot</code> | odroid@odroid:~$ reboot</code> | ||
- | - Now you have the RTC on ODROID-C2 running with the current date and time the next step is to make it load when the ODROID-C2 boots.\\ | + | - Check the I2C & RTC module status after reboot: <code>odroid@odroid64:~$ cat /etc/modules |
+ | # /etc/modules: kernel modules to load at boot time. | ||
+ | # | ||
+ | # This file contains the names of kernel modules that should be loaded | ||
+ | # at boot time, one per line. Lines beginning with "#" are ignored. | ||
+ | aml_i2c | ||
- | - Check the I2C module status after reboot: <code> | + | odroid@odroid64:~$ ls /dev/rtc |
- | odroid@odroid:~$ cat /etc/modules | + | /dev/rtc |
- | aml_i2c | + | |
- | odroid@odroid:~$</code> Add **aml_i2c** at the end of the file. | + | odroid@odroid64:~$ lsmod |
- | - Next you want to add the RTC on ODROID-C2 at boot by editing /etc/rc.local.<code> | + | ..... |
+ | rtc_pcf8563 3996 0 | ||
+ | aml_i2c 16898 0 | ||
+ | ..... | ||
+ | </code> | ||
+ | - Next you want to update system Time/Calendar from the HW RTC at boot time by editing /etc/rc.local file<code> | ||
odroid@odroid:~$ sudo nano /etc/rc.local | odroid@odroid:~$ sudo nano /etc/rc.local | ||
Line 36: | Line 47: | ||
exit 0 | exit 0 | ||
- | |||
- | ^G Get Help ^O Write Out ^W Where Is ^K Cut Text ^J Justify ^C Cur Pos | ||
- | ^X Exit ^R Read File ^\ Replace ^U Uncut Text^T To Linter ^_ Go To Line | ||
odroid@odroid:~$</code> Add the following at the bottom of the page above exit 0. ^x exit and save the file. Reboot your ODROID-C2. <code>odroid@odroid:~$ sudo reboot</code> If everything worked correctly the RTC on ODROID-C2 should be initialised on boot and the current date and time will be loaded into Linux. You need to check the existence of "rtc-pcf8563" in the output of "lsmod" command when the HW RTC doesn't work correctly. | odroid@odroid:~$</code> Add the following at the bottom of the page above exit 0. ^x exit and save the file. Reboot your ODROID-C2. <code>odroid@odroid:~$ sudo reboot</code> If everything worked correctly the RTC on ODROID-C2 should be initialised on boot and the current date and time will be loaded into Linux. You need to check the existence of "rtc-pcf8563" in the output of "lsmod" command when the HW RTC doesn't work correctly. | ||
- You can check the current time on the RTC on ODROID-C2 with: <code>odroid@odroid:~$ sudo hwclock -r</code> If this is the first time you have run the RTC on ODROID-C2 it will display a date of APR 20th 2016. | - You can check the current time on the RTC on ODROID-C2 with: <code>odroid@odroid:~$ sudo hwclock -r</code> If this is the first time you have run the RTC on ODROID-C2 it will display a date of APR 20th 2016. | ||
- If the ODROID-C2 is connected to the internet the correct date and time should be set automatically otherwise you can set the current date and time using: <code>odroid@odroid:~$ sudo date -s "20 APR 2016 18:00:00" </code> You can check the current linux date with the command (date). | - If the ODROID-C2 is connected to the internet the correct date and time should be set automatically otherwise you can set the current date and time using: <code>odroid@odroid:~$ sudo date -s "20 APR 2016 18:00:00" </code> You can check the current linux date with the command (date). | ||
- To save the date into the RTC chip on ODROID-C2 use the following command: <code>odroid@odroid:~$ sudo hwclock -w </code> Verify the date has been saved onto the RTC on ODROID-C2 with: <code>odroid@odroid:~$ sudo hwclock -r</code> | - To save the date into the RTC chip on ODROID-C2 use the following command: <code>odroid@odroid:~$ sudo hwclock -w </code> Verify the date has been saved onto the RTC on ODROID-C2 with: <code>odroid@odroid:~$ sudo hwclock -r</code> | ||
+ | |||
+ | <WRAP left round important 100%> | ||
+ | ** Kernel update will break the RTC functionality **\\ | ||
+ | To avoid this problem, you can use this workaround that will patch the dtb all the time \\ | ||
+ | <code>sudo -s | ||
+ | echo '#!/bin/sh' > /etc/kernel/postinst.d/rtc | ||
+ | echp 'fdtput -t s /boot/meson64_odroidc2.dtb /i2c@c1108500/pcf8563@51 status "okay"' >> /etc/kernel/postinst.d/rtc | ||
+ | chmod +x /etc/kernel/postinst.d/rtc</code> | ||
+ | |||
+ | </WRAP> \\ | ||
==== Android ==== | ==== Android ==== | ||
- | This guide works on Android 5.1 V2.8 and V2.9 images only. | + | <note tip> |
+ | This guide works on Android 5.1.1 V2.8 and higher version and Android 6.0.1 . | ||
+ | </note> | ||
Open File Manager app. | Open File Manager app. | ||
Line 55: | Line 75: | ||
# load kernel from vat or boot partition. | # load kernel from vat or boot partition. | ||
movi read boot 0 ${loadaddr} | movi read boot 0 ${loadaddr} | ||
- | #fatload mmc 0:1 ${loadaddr} Image | + | #fatload mmc 0:1 ${loadaddr} Image_android |
booti ${loadaddr} - ${dtbaddr} | booti ${loadaddr} - ${dtbaddr} | ||
</code> | </code> | ||
Line 64: | Line 84: | ||
# load kernel from vat or boot partition. | # load kernel from vat or boot partition. | ||
#movi read boot 0 ${loadaddr} | #movi read boot 0 ${loadaddr} | ||
- | fatload mmc 0:1 ${loadaddr} Image | + | fatload mmc 0:1 ${loadaddr} Image_android |
booti ${loadaddr} - ${dtbaddr} | booti ${loadaddr} - ${dtbaddr} | ||
</code> | </code> | ||
Line 82: | Line 102: | ||
To stop ntpd: <code> sudo /etc/init.d/ntp stop </code> or <code> sudo service ntp stop </code> | To stop ntpd: <code> sudo /etc/init.d/ntp stop </code> or <code> sudo service ntp stop </code> | ||
To prevent it from starting at boot: <code> sudo update-rc.d -f ntp remove </code> | To prevent it from starting at boot: <code> sudo update-rc.d -f ntp remove </code> | ||
+ | |||
+ | ===== Estimated life cycle of the battery ===== | ||
+ | We cleanly installed Android 5.1 V3.3 image and measured the power consumption.\\ | ||
+ | When C2 turns on, it consumes less than 1uA.\\ | ||
+ | When C2 turns off, it consumes around 15uA.\\ | ||
+ | |||
+ | According to CR2032 Panasonic datasheet, its nominal capacity is 225mAh.\\ | ||
+ | [[http://www.cr2032.co/cms/prodimages/panasonic_cr2032_datasheet.pdf]]\\ | ||
+ | So its backup time could be around 15000 hours (~ two years).\\ | ||
+ | If on/off ratio is 1:1, it can be 3~4 years. |