turkerali

Members
  • Content Count

    5
  • Joined

  • Last visited

About turkerali

  • Rank
    Newbie

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Fair enough. I've just sent a pull request for this small change. Hope I won't break anything
  2. I had to recompile the Armbian kernel for the DS1307 RTC Module. The details are in this thread: https://forum.armbian.com/topic/8856-solved-how-to-add-an-external-rtc-module-to-rock64-board/
  3. ROCK64 is a RK3328 Quad-Core ARM Cortex A53 board with up to 4 GB of RAM. Unfortunately it has a non-functional RTC (/dev/rtc0), which is not battery backed. If your board is not connected to internet 7/24, you can not use the NTP or systemd-timesyncd. Therefore you need to connect a battery-backed external RTC module to the ROCK64 header, and get the time via the i2c protocol. The good news is, the GPIO headers on ROCK64 is compatible with Raspberry Pi headers. Therefore almost any Raspberry Pi RTC module will work on ROCK64. But you need to do some tweaking to communicate with the RTC module. I will explain the required steps which worked for me. 1. Buy an external RTC module for Raspberry Pi, preferably with DS1307 chip. Here is an example: https://www.abelectronics.co.uk/p/70/rtc-pi 2. Install i2c-tools package: sudo apt-get install i2c-tools 3. Connect the RTC module to the board as in the attached picture. 4. Right now, you can not probe the RTC module, because most of the GPIO headers on ROCK64 board is disabled by default. (See https://github.com/ayufan-rock64/linux-build/blob/master/recipes/additional-devices.md for details.) Therefore if you try to probe i2c-0, you will get the error below: root@rock64:~# sudo i2cdetect -y 0 Error: Could not open file `/dev/i2c-0' or `/dev/i2c/0': No such file or directory Ayufan wrote a nice script named "enable_dtoverlay" to enable the GPIO headers on-the-fly. Here is the link: https://raw.githubusercontent.com/ayufan-rock64/linux-package/master/root/usr/local/sbin/enable_dtoverlay Download this script and copy it under /bin and make it executable. We will enable "i2c-0" with this script, which we need for the RTC module. The command to enable i2c-0 is as follows: /bin/enable_dtoverlay i2c0 i2c@ff150000 okay After you run this command, /dev/i2c-0 becomes available, and we can probe it via the command below: root@rock64:~# sudo i2cdetect -y 0 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: -- -- -- -- -- -- -- -- If you see the number 68, you are on the right track. 5. Now we need the kernel driver for DS1307. Unfortunately DS1307 driver is not available with armbian kernel (see below). root@rock64:~# cat /boot/config-4.4.162-rockchip64 | grep DS1307 # CONFIG_RTC_DRV_DS1307 is not set So we need to recompile the Armbian kernel with this option enabled. I will not cover the steps to compile the kernel, you can find it here: https://docs.armbian.com/Developer-Guide_Build-Preparation/ Let's hope @Igor or any other Armbian developer will enable this module by default, and save us from this burden. After we compile the kernel with DS1307 driver, we are almost done. We need to tell the kernel that a DS1307 chip is using the i2c-0. Here is the way to do that: echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device After we execute this command, /dev/rtc1 becomes available, and points to our external RTC module. Please note that /dev/rtc0 is the onboard RTC, which does not work, and should be avoided. We need to update the date/time information from the system for the first time. Here is the command to do that: hwclock --rtc /dev/rtc1 --systohc Now our external RTC clock is set, and ready to take over NTP. 6. Edit /lib/udev/hwclock-set. Find the lines below, and update as shown: if [ -e /run/systemd/system ] ; then # exit 0 /bin/enable_dtoverlay i2c0 i2c@ff150000 okay echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device fi 7. Edit /etc/rc.local, add the following lines to set the system clock for every boot: /lib/udev/hwclock-set /dev/rtc1 8. Disable the below services, as we don't need them anymore: systemctl stop systemd-timesyncd.service systemctl disable systemd-timesyncd.service systemctl stop fake-hwclock.service systemctl disable fake-hwclock.service 9. Reboot and enjoy your RTC module.
  4. I have an external RTC module, which I bought from from AB electronics for my Rasberry Pi (see https://www.abelectronics.co.uk/p/70/rtc-pi). As the pinouts for Raspberry Pi and Rock64 are same, I can connect this RTC module to the ROCK 64 board and i2cdetect detects the module with some minor tweaks. The only missing part is the DS1307 kernel driver. I can change the armbian config and compile my own kernel, but I don't want to do that again and again whenever the kernel gets updated. Therefore if the CONFIG_RTC_DRV_DS1307 option is set to "m" in the default config, every ROCK64 owner can use DS1307 based external RTC modules with the default armbian kernel. I can even write a howto for that.
  5. Gentlemen, I have a rock64 board, and I would like to use an external RTC module with DS1307 chip. Unfortunately the armbian kernel does not provide DS1307 driver by default: root@rock64:~# cat /boot/config-4.4.162-rockchip64 | grep DS1307 # CONFIG_RTC_DRV_DS1307 is not set I don't have the programming skills for sending a pull request to enable this module. Could you please enable this module for ROCK64? I believe other ROCK64 owners may also benefit from this driver, as the board does not expose a working RTC, and DS1307 is a very common RTC chip. Thanks in advance.