[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)



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: