[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Activate a Real Time Clock chip on I2C in Raspberry Pi 4B with Debian (not Raspbian)



Thanks for your response, Georg!

Is there somewhere that these modules are documented that I can read-up for a more detailed understanding?

As an experiment, I tried running the following  (It didn't work, but maybe you can suggest a modification that will.  I'm probably not fully understanding something!):
    modprobe i2c_bcm2835 &&
    modprobe rtc_ds1307 &&
    sleep 1 &&
    echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device &&
    /sbin/hwclock -r
This is what I got when I tried it:
    hwclock: Cannot access the Hardware Clock via any known method.

and when I tried:
    i2cdetect -y 1
I got"
    Error: Could not open file `/dev/i2c-1' or `/dev/i2c/1': No such file or directory

I found this in journalctl :
    Apr 16 18:23:33 pi kernel: rtc-ds1307: probe of 1-0068 failed with error -121
    Apr 16 18:23:33 pi kernel: i2c i2c-1: new_device: Instantiated device ds1307 at 0x68

Is rtc_ds1307 the wrong module for my DS3231 rtc hardware?

Thanks!
Rick

=================================================================
On Sun, Apr 16, 2023, at 2:17 AM, Georg Gast wrote:
> Am Sun, 16 Apr 2023 10:01:08 +0200
> schrieb Diederik de Haas <didi.debian@cknow.org>:
>
>> On Sunday, 16 April 2023 04:47:37 CEST Rick Thomas wrote:
>> > I've got a Raspberry Pi 4B (4GB) with a DS3231 RTC module.  I can
>> > make the combo work with Ubuntu and RaspberryPI-OS.  I'd like to
>> > try it with the plain-vanilla Debian from
>> > <https://raspi.debian.net/tested-images/> but I can't find
>> > instructions for activating the I2C and RTC hardware in that OS.  
>> 
>> Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml in the kernel
>> source describes how one could use it ('compatible = "maxim,ds3231"'
>> for DS3231). I think you should make a DeviceTree Overlay, but I
>> don't know how to do that.
>
> I got this working with that systemd unit on a Rpi3 but should also
> work on a RPi4. Maybe you need to adjust the modprobe sequence. I guess
> the 2708 is 2835 on the Pi4.
>
> cat /etc/systemd/system/hwclock-pi.service
> [Unit]
> Description=HWClock at the I2C Bus of the Raspberry pi
> Before=basic.target
> Conflicts=shutdown.target
> DefaultDependencies=no
>
> [Service]
> Type=oneshot
> ExecStart=/bin/sh -c "modprobe i2c_bcm2835 && modprobe i2c_bcm2708 &&
> modprobe rtc_ds1307 && sleep 1 && echo ds1307 0x68 >
> /sys/class/i2c-adapter/i2c-1/new_device && /sbin/hwclock -s"
> ExecStop=/sbin/hwclock -w RemainAfterExit=yes
>
> [Install]
> WantedBy=basic.target


Reply to: