Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 7 Dec 2024 23:53:04 +1030
From:      Daniel O'Connor <darius@dons.net.au>
To:        =?utf-8?B?6aKo5L6G5pWj5Lq6?= <furaisanjin@gmail.com>
Cc:        FreeBSD ARM List <freebsd-arm@freebsd.org>
Subject:   Re: DS1307 on rpi4B
Message-ID:  <431FB386-F515-4D77-A855-18055A48E432@dons.net.au>
In-Reply-To: <CAJzLSnxOALkCztZUa-zpUH30g1O0nUfQb4X2=4o_VDv3WTEdaQ@mail.gmail.com>
References:  <CAJzLSnxOALkCztZUa-zpUH30g1O0nUfQb4X2=4o_VDv3WTEdaQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help


> On 7 Dec 2024, at 20:26, =E9=A2=A8=E4=BE=86=E6=95=A3=E4=BA=BA =
<furaisanjin@gmail.com> wrote:
> I'm trying connect DS1307 on rpi4B (8M). I'm not sure how much I can =
rely on the description in =
https://github.com/raspberrypi/firmware/tree/master/boot/overlays =
because I don't know the difference between linux boot loader and =
FreeBSD one.
>=20
> I want to connect DS1307 on GPIO12/13 pin as i2c5 so I assumed i2c-rtc =
could be used so that I added one line in config.txt like below.
>=20
> dtoverlay=3Di2c-rtc,ds1307,i2c5,addr=3D0x68

I have the following in /boot/msdos/overlays/pijuice.dtso (which needs =
to be compiled to a dtbo):
// Definition for RPi3 I2C based Real Time Clock
/dts-v1/;
/plugin/;

/ {
        compatible =3D "brcm,bcm2835";

        fragment@0 {
                target =3D <&i2c1>;
                __overlay__ {
                        #address-cells =3D <1>;
                        #size-cells =3D <0>;
                        status =3D "okay";
                                ds1307: ds1307@68 {
                                        compatible =3D "maxim,ds1307";
                                        reg =3D <0x68>;
                                        status =3D "okay";
                        };
                };
        };
        __overrides__ {
                ds1307 =3D <&ds1307>,"status";
        };
};

And in /boot/msdos/config.txt:
[all]
...
# DS1307 RTC
dtoverlay=3Dds1307

[pi4]
gpio=3D2,3=3Da0

I got the last line from =
https://lists.freebsd.org/pipermail/freebsd-arm/2021-May/023713.html

After that=20
sudo i2c -f /dev/iic0 -m tr -s

Shows the device.

Also, be aware that currently the I2C frequency is quite a bit higher =
than it should be when the CPU is clocked at the maximum as the divisors =
are calculated based on the default clock. This doesn't seem to affect =
the DS1307 even though it is only rated for 100kHz.

--
Daniel O'Connor
"The nice thing about standards is that there
are so many of them to choose from."
-- Andrew Tanenbaum




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?431FB386-F515-4D77-A855-18055A48E432>