DS1307 on rpi4B
- Reply: 風來散人 : "Re: DS1307 on rpi4B"
- Reply: Daniel O'Connor : "Re: DS1307 on rpi4B"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 07 Dec 2024 09:56:11 UTC
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