[1] MLD-5.x / Systems / Raspberry PI / DS3231 real-time clock
 

Offline koen

  • Newbie
  • *
  • Posts: 4
    • View Profile
DS3231 real-time clock
« on: April 05, 2016, 14:49:27 »
Hi.

I'm using MLD as vdr client on a raspberry pi 2. A question: is it possible to add support for DS3231 to the rpi-rtc system package?

DS3231 is a small real-time clock with battery back-up. Tested and works fine under raspbian. In case someone is interested where I bought mine: cost approx.1.07 euro, search for "DS3231 raspberry"  on aliexpress.com.

Thanks,

Koen

Online clausmuus

  • Administrator
  • Expert Member
  • ********
  • Posts: 20118
    • View Profile
    • ClausMuus.de
DS3231 real-time clock
« Reply #1 on: April 05, 2016, 20:57:12 »
Do you try the rpi-rtc package?

Claus
MLD 5.5 - Raspberry PI - 7" Touch TFT - Squeeze Play
MLD 5.5 - lirc yaUsbIR - OctopusNet - XFX GeForce 9300 mit Intel E3200 - 2GB RAM - 12TB HDD - Lian Li PC-C37B - Samsung LE40A559

Offline rfehr

  • MLD-Developer
  • Expert Member
  • ******
  • Posts: 1462
    • View Profile
DS3231 real-time clock
« Reply #2 on: April 06, 2016, 01:07:12 »
@Koen,

have you try this?

Code: [Select]
# Comment out the blacklist entry so the module can be loaded on boot
sudo sed -i 's/blacklist i2c-bcm2708/#blacklist i2c-bcm2708/' /etc/modprobe.d/raspi-blacklist.conf
# Load the module now
sudo modprobe i2c-bcm2708
# Notify Linux of the Dallas RTC device (use -0 for Model A or -1 for Model B)
echo ds3231 0x68 | sudo tee /sys/class/i2c-adapter/i2c-1/new_device
# Test whether Linux can see our RTC module.
sudo hwclock

I don't how if we already have the i2c-bcm2708 module?.

best regrads

Roland
1x OctopusNet 4x DVB-C
1x Zotac ITX-A Atom 330
1x RPI2 als Client
1x BananaPi
1x Wetekplay
1x MCC 100
2x RPI3
2x RPi4
1x https://www.zotac.com/at/product/mini_pcs/pi335

Offline koen

  • Newbie
  • *
  • Posts: 4
    • View Profile
DS3231 real-time clock
« Reply #3 on: April 06, 2016, 13:14:18 »
I have the system package  rpi-rtc installed. It detects a ds1307, not a ds3231. This is normal? hwclock seems to work.

Code: [Select]
MLD> dmesg | grep rtc
[   22.880255] rtc-ds1307 1-0068: rtc core: registered ds1307 as rtc0
[   22.880318] rtc-ds1307 1-0068: 56 bytes nvram
MLD>  hwclock -r -u
Wed 06 Apr 2016 13:05:40 CEST  0.000000 seconds
MLD> cat /sys/bus/i2c/drivers/rtc-ds1307/1-0068/name
ds1307

Online clausmuus

  • Administrator
  • Expert Member
  • ********
  • Posts: 20118
    • View Profile
    • ClausMuus.de
DS3231 real-time clock
« Reply #4 on: April 06, 2016, 16:50:42 »
The pckage also contain the rtc-ds3232 driver. You can use it by put it in the /etc/modules and remove the rtc-ds1307 driver there.
To test if the rtc work correct, you must boot without a connected network and without a dvb USB stick.

Claus
MLD 5.5 - Raspberry PI - 7" Touch TFT - Squeeze Play
MLD 5.5 - lirc yaUsbIR - OctopusNet - XFX GeForce 9300 mit Intel E3200 - 2GB RAM - 12TB HDD - Lian Li PC-C37B - Samsung LE40A559

Offline koen

  • Newbie
  • *
  • Posts: 4
    • View Profile
DS3231 real-time clock
« Reply #5 on: April 07, 2016, 11:52:37 »
The following seems to work. In /etc/init.d/rpi-rtc, change ds1307 to ds3231:
Code: [Select]
--- rpi-rtc.ORIG 2016-04-07 11:00:27.198366313 +0200
+++ rpi-rtc 2016-04-07 11:00:38.574365795 +0200
@@ -7,7 +7,7 @@
  echo "Activate rtc:"
  i=0; while [ ! -e /dev/i2c-0 -a $i -lt 10 ]; do i=$(($i+1)); sleep 1; done
  rev=$(i2cdetect -y 0 2>/dev/null | grep -q 68 && echo 0 || echo 1)
- echo ds1307 0x68 2>/dev/null > /sys/class/i2c-adapter/i2c-$rev/new_device
+ echo ds3231 0x68 2>/dev/null > /sys/class/i2c-adapter/i2c-$rev/new_device
  check_status
  ;;
  stop)
After rebooting dmesg then shows:
Code: [Select]
[   23.443693] rtc-ds1307 1-0068: rtc core: registered ds3231 as rtc0
[   23.443765] i2c i2c-1: new_device: Instantiated device ds3231 at 0x68
Thanks everyone.

Offline aa428

  • Newbie
  • *
  • Posts: 24
    • View Profile
DS3231 real-time clock
« Reply #6 on: March 11, 2018, 17:05:46 »
Habe mir ein ds3231 RTC modul zum aufstecken auf den GPIO am rpi3 besorgt und lt. o.g. Anleitung (mit der MLD 5.4 testing) versucht zu konfigurieren:

Raspi> dmesg | egrep 'ds3231|rtc'
[   24.226423] i2c i2c-1: new_device: Instantiated device ds3231 at 0x68
[   24.243659] rtc-ds1307 1-0068: registered as rtc0
[ 1314.649948] i2c i2c-1: Failed to register i2c client ds3231 at 0x68 (-16)
Raspi> i2cdetect -y 1
     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: -- -- -- -- -- -- -- --
Raspi> grep ds3231 /etc/modules | grep -v ^#
rtc-ds3231
Raspi> lsmod | grep rtc
rtc_ds1307             24576  0
hwmon                  16384  1 rtc_ds1307
Raspi> lsmod | grep ds3231
Raspi> grep dtoverlay  /boot/config.txt
dtoverlay=lirc-rpi,i2c-rtc,ds3231=on
Raspi> ls -al /dev/rtc
lrwxrwxrwx    1 root     root             4 Jan  1  1970 /dev/rtc -> rtc0
Raspi> cat /proc/driver/rtc
rtc_time        : 15:38:43
rtc_date        : 2018-03-11
alrm_time       : 00:00:00
alrm_date       : 1970-01-01
alarm_IRQ       : no
alrm_pending    : no
update IRQ enabled      : no
periodic IRQ enabled    : no
periodic IRQ frequency  : 1
max user IRQ frequency  : 64
24hr            : yes
Raspi> grep ds /etc/init.d/rpi-rtc
                ###echo ds1307 0x68 2>/dev/null > /sys/class/i2c-adapter/i2c-$rev/new_device
                echo ds3231 0x68 2>/dev/null > /sys/class/i2c-adapter/i2c-$rev/new_device
Raspi> ls -la /sys/class/i2c-adapter/i2c-*
lrwxrwxrwx    1 root     root             0 Jan  1  1970 /sys/class/i2c-adapter/i2c-1 -> ../../devices/platform/soc/3f804000.i2c/i2c-1
lrwxrwxrwx    1 root     root             0 Mar 11 16:25 /sys/class/i2c-adapter/i2c-3 -> ../../devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/i2c-3
lrwxrwxrwx    1 root     root             0 Mar 11 16:25 /sys/class/i2c-adapter/i2c-4 -> ../../devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/i2c-3/i2c-4
Raspi> Raspi> /etc/init.d/rpi-rtc start
-sh: Raspi: not found
Raspi> Activate rtc:
Raspi>                                                                                                                                   failed

ds3231 modul wird hw-mässig erkannt, korrekte Zeit aus dem rtc modul wird beim system start auch geladen, aber das schreiben der wakeup Zeit funktioniert noch nicht.
Scheinbar passt da noch was nicht mit der restlichen konfig.

Wäre für Tips dankbar.

Offline goerdi

  • Profi Member
  • ****
  • Posts: 363
    • View Profile
DS3231 real-time clock
« Reply #7 on: March 11, 2018, 18:45:04 »
Wakeup Zeit ? Wozu ? Der Pi kann das imho eh nicht...

Gruss Gerd

Online clausmuus

  • Administrator
  • Expert Member
  • ********
  • Posts: 20118
    • View Profile
    • ClausMuus.de
DS3231 real-time clock
« Reply #8 on: March 11, 2018, 23:00:33 »
Außer in der /etc/init.d/rpi-rtc muss auch noch in der /usr/bin/rtc-wakeup der Treibername geändert werden. Ob das hilft weiß ich aber nicht.

Außerdem muss ich goerdi zustimmen. Meines Wissens kann der RPI nicht per rtc geweckt werden, wenn dafür nicht zusätzlich Hardware hinzugefügt wird. Ich lass mich aber gerne eines besseren belehren...
MLD 5.5 - Raspberry PI - 7" Touch TFT - Squeeze Play
MLD 5.5 - lirc yaUsbIR - OctopusNet - XFX GeForce 9300 mit Intel E3200 - 2GB RAM - 12TB HDD - Lian Li PC-C37B - Samsung LE40A559

Offline gkd-berlin

  • MLD-Tester
  • Expert Member
  • ******
  • Posts: 1260
    • View Profile
DS3231 real-time clock
« Reply #9 on: March 12, 2018, 17:24:32 »
Hallo aa428,

Hier ist der Link zu meinem Hardware Controller

Ich habe das mit einer Tiny RTC (DS1307) aufgebaut. Siehe Teil 4.
Das DS3231 RTC-Modul hat eine andere Registerbelegung als die DS1307, somit müssen die Aufwachzeiten von Claus in andere Speicheradressen geschrieben werden.

Das Ding läuft auch mit einem RPI 2 + 3. Ich wollte damals nur wissen, ob meine Vorstellungen überhaupt machbar sind. Es ist, mit viel Hilfe von Claus, machbar. Ob der Aufwand gerechtfertigt ist, muß jeder selbst entscheiden. Heute bin ich der Meinung: Der Aufwand lohnt sich nicht.

Gruß Gerhard
Meine VDR:
Spoiler (show / hide)

Offline aa428

  • Newbie
  • *
  • Posts: 24
    • View Profile
DS3231 real-time clock
« Reply #10 on: March 13, 2018, 23:02:40 »
@clausmuus:
Danke - kleiner Typo bei dir oben es ist das Script: /usr/sbin/rtc-wakeup welches einen Verweis auf das entsprechend zu korrigierende ds Modul enthält:

Raspi> grep ds13 /usr/sbin/rtc-wakeup.orig
                echo ds1307 0x68 2>/dev/null > /sys/class/i2c-adapter/i2c-$rev/new_device


Aber leider ist nur das Module für den ds3232, aber nicht das für den ds3231 in der 5.4 testing enthalten:

Raspi> grep rtc /lib/modules/4.14.18.199.71/modules.dep
kernel/drivers/rtc/rtc-ds1307.ko: kernel/drivers/hwmon/hwmon.ko
kernel/drivers/rtc/rtc-ds3232.ko: kernel/drivers/hwmon/hwmon.ko

Wäre es möglich das ds3231 auch noch unterzubringen ?

Offline MarMic

  • Administrator
  • Expert Member
  • ********
  • Posts: 4822
    • View Profile
DS3231 real-time clock
« Reply #11 on: March 14, 2018, 08:36:59 »
hi,

es gibt kein modul 3231!
so wie ich das lese braucht man bei 3231 das 1307

https://www.raspberrypi-spy.co.uk/2015/05/adding-a-ds3231-real-time-clock-to-the-raspberry-pi/

Gruß

MarMic
SZVDR HD: Intel e5300@1,2ghz - Gigabyte GA-EP41-UD3L - 2GB ddr2 800 - Gainward G210 512mb - Silverstone LC16MR - DVBSky S952 - Astra 19,2 - MLD 5.4

WZVDR HD: Intel g1610@1,6ghz - Intel DH61BE - Scythe Big Shuriken 2 - 4GB ddr3 1333 - Asus GT610 1024mb - Chieftec Hi-Fi HM-02 - Tevii s480 - Astra 19,2 - MLD 5.4


Offline goerdi

  • Profi Member
  • ****
  • Posts: 363
    • View Profile
DS3231 real-time clock
« Reply #12 on: March 22, 2018, 17:01:57 »
hi !

Exakt die beiden Teile unterscheiden sich "nur" in der Hinsicht durch ihre Ganggenauigkeit. Das kernelmodul ist das selbe..

Gruss Gerd

[1] MLD-5.x / Systems / Raspberry PI / DS3231 real-time clock
 



Users Online Users Online

0 Members and 1 Guest are viewing this topic.