Date: Sat, 7 Dec 2024 18:56:11 +0900 From: =?UTF-8?B?6aKo5L6G5pWj5Lq6?= <furaisanjin@gmail.com> To: FreeBSD ARM List <freebsd-arm@freebsd.org> Subject: DS1307 on rpi4B Message-ID: <CAJzLSnxOALkCztZUa-zpUH30g1O0nUfQb4X2=4o_VDv3WTEdaQ@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
--00000000000054161c0628ab26d8 Content-Type: text/plain; charset="UTF-8" Hello all, 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. 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. dtoverlay=i2c-rtc,ds1307,i2c5,addr=0x68 iic1 is detected at boot but it can't talk to DS1307. # dmesg | egrep iic\|ds1307 iichb0: <BCM2708/2835 BSC controller> mem 0x7e804000-0x7e804fff irq 27 on simplebus0 iichb1: <BCM2708/2835 BSC controller> mem 0x7e205a00-0x7e205bff irq 52 on simplebus0 iicbus0: <OFW I2C bus> on iichb0 iic0: <I2C generic I/O> on iicbus0 iicbus1: <OFW I2C bus> on iichb1 iic1: <I2C generic I/O> on iicbus1 ds13070: <Dallas DS1307> at addr 0xd0 on iicbus1 ds13070: is_dev_time_valid: cannot read from RTC: 35 ds13070: WARNING: RTC clock stopped, check the battery. ds13070: registered as a time-of-day clock, resolution 1.000000s ds13070: ds1307_gettime: cannot read from RTC: 35 ds13070: ds1307_settime: cannot write to RTC: 35 The command "i2c -s -v -f /dev/iic1" can't detect anything at all. The pin function doesn't seem to be correct. # sysctl -a dev.gpio.0.pin|grep 1[23] dev.gpio.0.pin.13.function: input dev.gpio.0.pin.12.function: input If I set alt5 on these pins by sysctl and change pin configuration by gpioctl to enable internal pullup, iic1 works fine. --- for p in 12 13 do sysctl dev.gpio.0.pin.$p.function=alt5 gpioctl -c $p PU done i2c -s -v -f /dev/iic1 /root/src/ds1307 -r -a 0x68 -f /dev/iic1 --- I'm not familiar with dts stuff but I wrote overlay dts like this. /dts-v1/; /plugin/; / { compatible = "raspberrypi,4-model-b", "brcm,bcm2711"; fragment@0 { target = <&i2c5>; __overlay__ { brcm,pins = <12 13>; brcm,function = <2>; brcm,pull = <2 2>; status = "okay"; }; }; }; However this doesn't work at all. How can I configure gpio12/13 for i2c5? Best regards, furaisanjin --00000000000054161c0628ab26d8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div>Hello all,</div><di= v><br></div><div>I'm trying connect DS1307 on rpi4B (8M). I'm not s= ure how much I can rely on the description in <a href=3D"https://github.com= /raspberrypi/firmware/tree/master/boot/overlays" target=3D"_blank">https://= github.com/raspberrypi/firmware/tree/master/boot/overlays</a> because I don= 't know the difference between linux boot loader and FreeBSD one.</div>= <div><br></div><div>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 b= elow.</div><div><br></div><div>dtoverlay=3Di2c-rtc,ds1307,i2c5,addr=3D0x68<= /div><div><br></div><div>iic1 is detected at boot but it can't talk to = DS1307.</div><div><br></div><div># dmesg | egrep iic\|ds1307<br>iichb0: <= ;BCM2708/2835 BSC controller> mem 0x7e804000-0x7e804fff irq 27 on simple= bus0<br>iichb1: <BCM2708/2835 BSC controller> mem 0x7e205a00-0x7e205b= ff irq 52 on simplebus0<br>iicbus0: <OFW I2C bus> on iichb0<br>iic0: = <I2C generic I/O> on iicbus0<br>iicbus1: <OFW I2C bus> on iichb= 1<br>iic1: <I2C generic I/O> on iicbus1<br>ds13070: <Dallas DS1307= > at addr 0xd0 on iicbus1<br>ds13070: is_dev_time_valid: cannot read fro= m RTC: 35<br>ds13070: WARNING: RTC clock stopped, check the battery.<br>ds1= 3070: registered as a time-of-day clock, resolution 1.000000s<br>ds13070: d= s1307_gettime: cannot read from RTC: 35<br>ds13070: ds1307_settime: cannot = write to RTC: 35</div><div><br></div><div>The command "i2c -s -v -f /d= ev/iic1" can't detect anything at all. The pin function doesn'= t seem to be correct.</div><div></div><div># sysctl -a dev.gpio.0.pin|grep = 1[23]</div><div>dev.gpio.0.pin.13.function: input<br>dev.gpio.0.pin.12.func= tion: input</div><div><br></div><div>If I set alt5 on these pins by sysctl = and change pin configuration by gpioctl to enable internal pullup, iic1 wor= ks fine.</div><div></div><div>---<br></div><div>for p in 12 13<br>do<br>=C2= =A0 sysctl dev.gpio.0.pin.$p.function=3Dalt5<br>=C2=A0 gpioctl -c $p PU<br>= done<br>i2c -s -v -f /dev/iic1<br>/root/src/ds1307 -r -a 0x68 -f /dev/iic1<= /div><div>---</div><div><br></div><div>I'm not familiar with dts stuff = but I wrote overlay dts like this.</div><div>/dts-v1/;<br>/plugin/;<br>/ = =C2=A0{<br><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 compatible =3D "raspberrypi= ,4-model-b", "brcm,bcm2711";<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 = fragment@0 {<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 target =3D <&i2c5>;<br>=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 __overla= y__ {<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 brcm,pins =3D <12 13>;<br>=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 brcm,function = =3D <2>;<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 brcm,pull =3D <2 2>;<br>=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";<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 };<br><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 };<br>};</div><div>However thi= s doesn't work at all. How can I configure gpio12/13 for i2c5?</div><di= v><br></div><div>Best regards,</div><div>furaisanjin</div><div><br></div><d= iv><br></div></div> </div> </div> --00000000000054161c0628ab26d8--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJzLSnxOALkCztZUa-zpUH30g1O0nUfQb4X2=4o_VDv3WTEdaQ>