From nobody Fri Feb 18 14:22:30 2022 X-Original-To: freebsd-arm@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A862119D18A1 for ; Fri, 18 Feb 2022 14:22:51 +0000 (UTC) (envelope-from archimedes.gaviola@gmail.com) Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4K0YnR0BQMz4tCJ for ; Fri, 18 Feb 2022 14:22:51 +0000 (UTC) (envelope-from archimedes.gaviola@gmail.com) Received: by mail-ed1-x536.google.com with SMTP id w3so15770019edu.8 for ; Fri, 18 Feb 2022 06:22:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/EI90TByrVJJl7qG+KGdJY/sLVELSA5X+uHVT999PUc=; b=gyUwmFLgiyWiibkAvXjWurcuiPfAk8oysEoVWeZoWIPr4BlhsDn9vJpiD+eGJmgnFi F8qLat3pCDfsINTBmwpEcjhlAuBkSVIu6bdWX0iQBKqYlTClk6ieANIF8qWGPyCjJGJU 6NM/93ueL13it/Oj7f9OQ5lYasGsPB+YtFpZ5L1/erXoS0zYFs4jvOyjHrMkuInuhTs7 42JIY38Blm9dskIoxiKYWCDXMq+ka+VAGNqVmRMGuejn4J2l1hClRbOwKf8vZEn0TnF3 VHTlZuwd0D9q3R/qlW4N2dRuAGRa2ly4hFiiIdTRrZKx2RucVXwYkqb5JbbqWJHrwUZJ notw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/EI90TByrVJJl7qG+KGdJY/sLVELSA5X+uHVT999PUc=; b=pLtxU6EkR3i7RHnQbwBzpjureSGFQwfGeKyThfcnb3yUtevpJqFAvvvnk48SntcuJ4 a4cfiiXMQsANe1CuK5iIPeb8LFrcyLBswTVFR04m+3gEzTVp6z/VFpqFMq0ki1m0ySGR K2yBaLInNMvO+rgoivtZhDx3hq5kd3Uvdr/AX/YcV/oIMILeD3MtdN/lIfw2ogMY/e/3 iG1h68tbLLd4JAunswaCDZaVOOBsiAmryWAM3Dgfajcdgu9SzLt4tDhPdkNvuPiYkN15 luYcaBbB5SzCcKu2En7Htb6Wu2IIhKdgUUEv+UpGrIfmSLmKXR23EQgTYjFgkkk1NtmM FjDw== X-Gm-Message-State: AOAM533m7gcXzMIvWg2y/UDMSqFy88oZ726lG0jfkL5CgjBkMEaQKRsg w+68ajnyCZEisLb4QkrsBv4ixR+x8aE8gLxRp3Oox7MWMaLYZA== X-Google-Smtp-Source: ABdhPJwvyfRmVealhOA8+wE6+bfo/84ZSVMKlUNOnIal1j2s0gn71ZY63hHDQCRUVGgbLYz0i3DE/cJpodZ1YOgIF5Y= X-Received: by 2002:a50:c056:0:b0:40f:9c6d:7701 with SMTP id u22-20020a50c056000000b0040f9c6d7701mr8285280edd.110.1645194169982; Fri, 18 Feb 2022 06:22:49 -0800 (PST) List-Id: Porting FreeBSD to ARM processors List-Archive: https://lists.freebsd.org/archives/freebsd-arm List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-arm@freebsd.org MIME-Version: 1.0 References: In-Reply-To: From: Archimedes Gaviola Date: Fri, 18 Feb 2022 22:22:30 +0800 Message-ID: Subject: Re: DS3231 RTC module not detected To: "Daniel O'Connor" Cc: freebsd-arm@freebsd.org Content-Type: multipart/alternative; boundary="00000000000016a43205d84b9e1e" X-Rspamd-Queue-Id: 4K0YnR0BQMz4tCJ X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20210112 header.b=gyUwmFLg; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of archimedesgaviola@gmail.com designates 2a00:1450:4864:20::536 as permitted sender) smtp.mailfrom=archimedesgaviola@gmail.com X-Spamd-Result: default: False [-4.00 / 15.00]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; MID_RHS_MATCH_FROMTLD(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; TAGGED_FROM(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20210112]; FROM_HAS_DN(0.00)[]; SH_EMAIL_DBL_DONT_QUERY_IPS(0.00)[0.0.0.68:email,0.0.0.0:email]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-arm@freebsd.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DBL_PROHIBIT(0.00)[0.0.0.68:email,0.0.0.0:email]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::536:from]; MLMMJ_DEST(0.00)[freebsd-arm]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] X-ThisMailContainsUnwantedMimeParts: N --00000000000016a43205d84b9e1e Content-Type: text/plain; charset="UTF-8" On Fri, Feb 18, 2022 at 7:08 AM Daniel O'Connor wrote: > > > > On 18 Feb 2022, at 02:02, Archimedes Gaviola < > archimedes.gaviola@gmail.com> wrote: > > I have a DS3231 real-time clock module ( > http://wiki.sunfounder.cc/index.php?title=DS3231_Real_Time_Clock_Module_for_Raspberry_Pi) > but cannot be detected with FreeBSD 13.0-RELEASE and 14.0-CURRENT. My > config.txt have this following lines; > > > > dtparam=i2c_arm=on > > dtoverlay=i2c-rtc,ds3231 > > > > and then I fetched a copy of the i2c-rtc.dtbo file here > https://github.com/raspberrypi/firmware/blob/master/boot/overlays/i2c-rtc.dtbo > and put it in the /boot/msdos/overlays directory. > > I have a DS1307 board on an RPi4 and I made the following modifications: > > I have /boot/msdos/overlays/ds1307.dtso with the following contents: > // Definition for RPi3 I2C based Real Time Clock > /dts-v1/; > /plugin/; > > / { > compatible = "brcm,bcm2835"; > > fragment@0 { > target = <&i2c1>; > __overlay__ { > #address-cells = <1>; > #size-cells = <0>; > status = "okay"; > ds1307: ds1307@68 { > compatible = "maxim,ds1307"; > reg = <0x68>; > status = "okay"; > }; > }; > }; > __overrides__ { > ds1307 = <&ds1307>,"status"; > }; > }; > > Then compiled it with.. > sudo dtc -O dtb -o /boot/msdos/overlays/ds1307.dtbo -b 0 -@ > /boot/msdos/overlays/ds1307.dtso > > In /boot/msdos/config.txt I have.. > > [all] > ... > # DS1307 RTC > dtparam=i2c_arm=on > dtoverlay=ds1307 > ... > [pi4] > # For I2C as per > # https://lists.freebsd.org/pipermail/freebsd-arm/2021-May/023713.html > gpio=2,3=a0 > > If it doesn't work post your dmesg output, but I suspect changing the > config.txt as just above will fix it. > Hi Daniel, Thanks for the info! I followed similar with your DS1307 RTC by creating a ds3231.dtso file and then compiling it with dtc to generate a ds3231.dtbo. The result is it is detected as MAX77620 RTC on 0xd0 address but when I run an i2c scan, the address detected is 68. Does this should match? With this setup I could update the date and time now by initiating an ntpdate to match our time plus invoking tzsetup command for my timezone which is doing well without any issue. Now, the moment I shutdown the system and plug back the power cable (with disconnected Ethernet cable just to make sure NTP servers are not called for updates upon restart) the time remains as it was before shutting down and then upon bootup system clock continues. I am expecting that it should be real time even if the RPi4 system is shutdown or detached from power due to the battery that will sustain the continuity of the clock. I'm sure that I'm having good DS3231 modules as I also tested my existing and another new spare and it is tested with OpenBSD too. Below are the system info. Is there anything I've missed? FreeBSD 13.0-RELEASE have the same outcome and behavior. freebsd@generic:~ % uname -a FreeBSD generic 14.0-CURRENT FreeBSD 14.0-CURRENT #0 main-n253065-8dc42f98047: Thu Feb 10 09:27:01 UTC 2022 root@releng1.nyi.freebsd.org:/usr/obj/usr/src/arm64.aarch64/sys/GENERIC arm64 freebsd@generic:~ % dmesg | grep iic iichb0: mem 0x7e804000-0x7e804fff irq 26 on simplebus0 iicbus0: on iichb0 iic0: on iicbus0 rtc0: at addr 0xd0 on iicbus0 rtc0: registered as a time-of-day clock, resolution 1.000000s root@generic:~ # i2c -s 68 root@generic:~ # sysctl -a | grep rtc rtc0: at addr 0xd0 on iicbus0 rtc0: registered as a time-of-day clock, resolution 1.000000s "max77620_rtc","bcm_bsc" "rtc list","max77620_rtc" machdep.disable_rtc_set: 0 machdep.rtc_save_period: 1800 dev.rtc.0.%parent: iicbus0 dev.rtc.0.%pnpinfo: name=ds3231@68 compat=maxim,ds3231 dev.rtc.0.%location: addr=0xd0 dev.rtc.0.%driver: rtc dev.rtc.0.%desc: MAX77620 RTC dev.rtc.%parent: freebsd@generic:~ % cat /boot/msdos/overlays/ds3231.dtso // Definition for RPi3 I2C based Real Time Clock /dts-v1/; /plugin/; / { compatible = "brcm,bcm2835"; fragment@0 { target = <&i2c1>; __overlay__ { #address-cells = <1>; #size-cells = <0>; status = "okay"; ds3231: ds3231@68 { compatible = "maxim,ds3231"; reg = <0x68>; status = "okay"; }; }; }; __overrides__ { ds3231 = <&ds3231>,"status"; }; }; and my config.txt have dtparam=i2c_arm=on dtoverlay=ds3231 gpio=2,3=a0 Thanks, Archimedes --00000000000016a43205d84b9e1e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Fri, Feb 18, 2022 at 7:08 AM Danie= l O'Connor <darius@dons.net.au= > wrote:
=

> On 18 Feb 2022, at 02:02, Archimedes Gaviola <archimedes.gaviola@gmail.com> wrote:
> I have a DS3231 real-time clock module (
http://wiki.sunfounder.cc/index.php?titl= e=3DDS3231_Real_Time_Clock_Module_for_Raspberry_Pi) but cannot be detec= ted with FreeBSD 13.0-RELEASE and 14.0-CURRENT. My config.txt have this fol= lowing lines;
>
> dtparam=3Di2c_arm=3Don
> dtoverlay=3Di2c-rtc,ds3231
>
> and then I fetched a copy of the i2c-rtc.dtbo file here https://github.com/raspberrypi/firmw= are/blob/master/boot/overlays/i2c-rtc.dtbo and put it in the /boot/msdo= s/overlays directory.

I have a DS1307 board on an RPi4 and I made the following modifications:
I have /boot/msdos/overlays/ds1307.dtso with the following contents:
// Definition for RPi3 I2C based Real Time Clock
/dts-v1/;
/plugin/;

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

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

Then compiled it with..
sudo dtc -O dtb -o /boot/msdos/overlays/ds1307.dtbo -b 0 -@ /boot/msdos/ove= rlays/ds1307.dtso

In /boot/msdos/config.txt I have..

[all]
...
# DS1307 RTC
dtparam=3Di2c_arm=3Don
dtoverlay=3Dds1307
...
[pi4]
# For I2C as per
# https://lists.freebsd.org/pipe= rmail/freebsd-arm/2021-May/023713.html
gpio=3D2,3=3Da0

If it doesn't work post your dmesg output, but I suspect changing the c= onfig.txt as just above will fix it.

<= div class=3D"gmail_quote">Hi Daniel,

Thanks for the info! I followed similar with= your DS1307 RTC by creating a ds3231.dtso file and then compiling it with = dtc to generate a ds3231.dtbo. The result is it is detected as MAX77620 RTC= on 0xd0 address but when I run an i2c scan, the address detected is 68. Do= es this should match?

With this setup I could update the date and time now by= initiating an ntpdate to match our time plus invoking tzsetup command for = my timezone which is doing well without any issue. Now, the moment I shutdo= wn the system and plug back the power cable (with disconnected Ethernet cab= le just to make sure NTP servers are not called for updates upon restart) t= he time remains as it was before shutting down and then upon bootup system = clock continues. I am expecting that it should be real time even if the RPi= 4 system is shutdown or detached from power due to the battery that will su= stain the continuity of the clock. I'm sure that I'm having good DS= 3231 modules as I also tested my existing and another new spare and it is t= ested with OpenBSD too. Below are the system info. Is there anything I'= ve missed? FreeBSD 13.0-RELEASE have the same outcome and behavior.

freebsd@generic:~ % uname -a
FreeBSD generic 14.= 0-CURRENT FreeBSD 14.0-CURRENT #0 main-n253065-8dc42f98047: Thu Feb 10 09:2= 7:01 UTC 2022 =C2=A0 =C2=A0 root@releng1.nyi.freebsd.org:/usr/obj/usr/src/a= rm64.aarch64/sys/GENERIC =C2=A0arm64

freebsd@generic:~ % dmesg | grep iic
iich= b0: <BCM2708/2835 BSC controller> mem 0x7e804000-0x7e804fff irq 26 on= simplebus0
iicbus0: <OFW I2C bus> on iichb0
iic0: <I2C gene= ric I/O> on iicbus0
rtc0: <MAX77620 RTC> at addr 0xd0 on iicbus= 0
rtc0: registered as a time-of-day clock, resolution 1.000000s

root@generic:~ # i2c -s
68

root@generic:~ # sysctl -a | grep rtc
rtc0: <= MAX77620 RTC> at addr 0xd0 on iicbus0
rtc0: registered as a time-of-d= ay clock, resolution 1.000000s
"max77620_rtc","bcm_bsc&qu= ot;
"rtc list","max77620_rtc"
machdep.disable_rtc= _set: 0
machdep.rtc_save_period: 1800
dev.rtc.0.%parent: iicbus0
d= ev.rtc.0.%pnpinfo: name=3Dds3231@68 compat=3Dmaxim,ds3231
dev.rtc.0.%loc= ation: addr=3D0xd0
dev.rtc.0.%driver: rtc
dev.rtc.0.%desc: MAX77620 R= TC
dev.rtc.%parent:

freebsd@generic:~ % cat /= boot/msdos/overlays/ds3231.dtso
// Definition for RPi3 I2C based Real Ti= me Clock
/dts-v1/;
/plugin/;

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

=C2=A0 =C2=A0 =C2=A0 = =C2=A0 fragment@0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 target =3D <&i2c1>;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 __overlay__ {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 #address-cells =3D <1>;=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 #size-cells =3D <0>;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 status =3D "okay&= quot;;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ds3231: ds3231@68 {
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 compatible = =3D "maxim,ds3231";
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 reg =3D <0x68>;
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 status =3D "okay";
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 };
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 };=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 };
=C2=A0 =C2=A0 =C2=A0 =C2=A0 __overrid= es__ {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ds3231 = =3D <&ds3231>,"status";
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = };
};

and my config.txt have

dtparam=3Di2c_arm=3Don
= dtoverlay=3Dds3231
gpio=3D2,3=3Da0

Thanks,
<= div class=3D"gmail_quote">Archimedes --00000000000016a43205d84b9e1e--